Skip to content

Commit

Permalink
Ghost Ai started
Browse files Browse the repository at this point in the history
  • Loading branch information
IssamAbushaban committed Nov 18, 2020
1 parent ab73519 commit d3573a6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 48 deletions.
21 changes: 5 additions & 16 deletions OdysseyNow/Assets/ModeDirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ public class ModeDirector : MonoBehaviour {
public GameObject calibration;
public GameObject AI;

// Start is called before the first frame update
private void Awake() {
switch (PlayerPrefs.GetString("game")) {
case "Cat and Mouse":
// load cat and mouse after calibration
calibration.GetComponent<CalibrationDirectorNew>().afterCalibration.AddListener(StartCatAndMouse);
break;
case "Super Cat and Mouse":
Expand Down Expand Up @@ -117,27 +115,18 @@ private void StartHauntedHouse()
PlayerPrefs.GetString("P1Input"));
var p2Input = (LocalInputManager.ControlScheme)System.Enum.Parse(typeof(LocalInputManager.ControlScheme),
PlayerPrefs.GetString("P2Input"));
if (p1Input == LocalInputManager.ControlScheme.AI)
{
p1.GetComponent<NavMeshAgent>().enabled = true;
game.GetComponent<GhostAI>().enabled = true;
game.GetComponent<GhostAI>().level = PlayerPrefs.GetInt("ai1");
}

if (p2Input == LocalInputManager.ControlScheme.AI)
{
Debug.Log("This needs to not be allowed.");
if (p1Input == LocalInputManager.ControlScheme.AI || p2Input == LocalInputManager.ControlScheme.AI) {
//Need to set it to the correct place near the door.
p2.GetComponent<NavMeshAgent>().SetDestination(new Vector3(Random.Range(-4, 4), Random.Range(-4, 4), 0));
p2.transform.localScale = new Vector3(10, 10, 10);

p2.GetComponent<NavMeshAgent>().enabled = true;
game.GetComponent<GhostAI>().enabled = true;
game.GetComponent<GhostAI>().level = PlayerPrefs.GetInt("ai2");
}

if (p1Input == LocalInputManager.ControlScheme.AI || p2Input == LocalInputManager.ControlScheme.AI)
{
game.SetActive(true);
AI.SetActive(true);
}

}

private void StartTennis() {
Expand Down
26 changes: 13 additions & 13 deletions OdysseyNow/Assets/Scenes/Card4.unity
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ GameObject:
- component: {fileID: 125695005}
- component: {fileID: 125695004}
- component: {fileID: 125695003}
m_Layer: 0
m_Layer: 10
m_Name: Ground
m_TagString: Untagged
m_Icon: {fileID: 0}
Expand Down Expand Up @@ -202822,7 +202822,7 @@ MonoBehaviour:
m_OverrideVoxelSize: 0
m_VoxelSize: 0.016666668
m_BuildHeightMesh: 0
m_NavMeshData: {fileID: 23800000, guid: 063ddded236e648c387cec974fc3aa6a, type: 2}
m_NavMeshData: {fileID: 23800000, guid: fb63d10a07f1a4a8384b129f46c25a24, type: 2}
--- !u!1 &656468553
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -203278,7 +203278,7 @@ GameObject:
m_Component:
- component: {fileID: 758153350}
- component: {fileID: 758153351}
m_Layer: 0
m_Layer: 10
m_Name: Grid
m_TagString: Untagged
m_Icon: {fileID: 0}
Expand Down Expand Up @@ -203541,7 +203541,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &832865732
Transform:
m_ObjectHideFlags: 0
Expand All @@ -203550,7 +203550,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 832865731}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -23.34, y: 17.88, z: 0}
m_LocalPosition: {x: -21.1, y: 7.1, z: 0}
m_LocalScale: {x: 1.0357001, y: 1.0393498, z: 1}
m_Children: []
m_Father: {fileID: 953254507}
Expand Down Expand Up @@ -206162,7 +206162,7 @@ GameObject:
- component: {fileID: 1078495472}
- component: {fileID: 1078495471}
- component: {fileID: 1078495470}
m_Layer: 0
m_Layer: 10
m_Name: Boundary
m_TagString: Untagged
m_Icon: {fileID: 0}
Expand Down Expand Up @@ -219669,7 +219669,7 @@ Transform:
m_GameObject: {fileID: 1353896473}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 1.0210017, y: 1.0210017, z: 1.0210017}
m_Children:
- {fileID: 910991344}
- {fileID: 1785562141}
Expand Down Expand Up @@ -219717,7 +219717,7 @@ SpriteRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: ddbef45ed05b84cd7b0bf8a96e511cfc, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 0.9019608}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
Expand Down Expand Up @@ -221253,7 +221253,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1405386637}
m_Enabled: 0
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b6aa0652006149c41b9fca129b5a01d5, type: 3}
m_Name:
Expand All @@ -221268,7 +221268,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1405386637}
m_Enabled: 0
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 293ba996f8d224288996decbbd8734e0, type: 3}
m_Name:
Expand Down Expand Up @@ -222484,7 +222484,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &1601926879
Transform:
m_ObjectHideFlags: 0
Expand All @@ -222508,7 +222508,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1601926878}
m_Enabled: 0
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 89e58825e9cc44c77bd3974251a48b81, type: 3}
m_Name:
Expand Down Expand Up @@ -244811,7 +244811,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1989816515}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 23.41, y: -17.44, z: 0}
m_LocalPosition: {x: 16.8, y: -17, z: 0}
m_LocalScale: {x: 1.0357143, y: 1.0393332, z: 1}
m_Children: []
m_Father: {fileID: 953254507}
Expand Down
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 8 additions & 10 deletions OdysseyNow/Assets/Scripts/AI/card4/HauntedHouse/ghost/GhostAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ public class GhostAI : MonoBehaviour {
private float nextActionTime = 0.0f;
private float period = 2f;
private NavMeshAgent agent;

public Transform target;
public GameObject ghost;
public int level;

// Start is called before the first frame update
// Start is called before the first frame updates
private void Start() {
// Agent tend to rotate game object, that can be
// undesirable
agent = ghost.GetComponent<NavMeshAgent>();

// The agent tends to rotate the game object, that can be undesirable
agent.updateRotation = false;
agent.updateUpAxis = false;
}
Expand All @@ -32,11 +29,12 @@ private void Update() {

switch (level) {
case 1:
agent.SetDestination(target.position);
// if (Time.time > nextActionTime) {
// nextActionTime += Time.time + period;
// agent.SetDestination(new Vector3(Random.Range(-4, 4), Random.Range(-4, 4), 0));
// }
//agent.SetDestination(target.position);
if (Time.time > nextActionTime)
{
nextActionTime += Time.time + period;
agent.SetDestination(new Vector3(Random.Range(-4, 4), Random.Range(-4, 4), 0));
}

break;
case 2:
Expand Down
8 changes: 0 additions & 8 deletions OdysseyNow/Assets/Scripts/CardDirection/MenuDirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,6 @@ public void UpdateAll(bool _secondPlayer, bool _includeBall, bool _includeWall,
UpdateAll();
}

/// <summary>
/// Redundant method; TODO: review dependancies and delete.
/// </summary>
void RemoveOptions()
{

}

/* The following methods update card variables.
* These methods are called by the UI elements in the menu.
*/
Expand Down

0 comments on commit d3573a6

Please sign in to comment.