public Action(OzHuman oz, float duration) { this.oz = oz; this.duration = duration; beginningTime = Time.time; lastTime = beginningTime; }
public override void Step(OzAI ai, OzHuman human) { if (!HasAction()) { RowFront(); } }
public override void Step(OzAI ai, OzHuman human) { Debug.Log("Seeking"); var sight = human.transform.rotation * new Vector3(0f, 0f, 1f); var objects = GameObject.FindGameObjectsWithTag("Player"); foreach (var obj in objects) { var h = obj.transform.Find("human2a"); var d = h.position - human.transform.position; if (d.magnitude < 15f && Vector3.Dot(sight, d) > 0f) { ChangeAI(new ChasingAI1(h.GetComponent <OzHuman>())); return; } } if (human.rigid.velocity.magnitude < targetVelo) { RowFront(); PauseFor(1f); targetDir = Random.Range(0, 2); } else { if (targetDir == 0) { RowLeft(); } else { RowRight(); } PauseFor(0.4f); } }
// Start is called before the first frame update void Start() { humanObject = transform.Find("human2a").gameObject; human = humanObject.GetComponent <OzHuman>(); switch (Random.Range(0, 6)) { case 0: ai = new WanderingAI1(); break; case 1: ai = new WanderingAI2(); break; case 2: ai = new ChasingAI1(GameObject.Find("Oz").transform.Find("human2a").GetComponent <OzHuman>()); break; case 3: ai = new ChasingAI2(GameObject.Find("Oz").transform.Find("human2a").GetComponent <OzHuman>()); break; case 4: ai = new SeekingAI1(); break; case 5: ai = new NpcKillerAI(); break; } }
public void RunStep(OzAI ai, OzHuman human) { actionTimer -= Time.deltaTime; this.ai = ai; this.human = human; if (actionTimer < 0) { Step(ai, human); } }
// Start is called before the first frame update void Start() { playerOz = GameObject.Find("Oz").transform.Find("human2a").GetComponent <OzHuman>(); for (int i = 0; i < 30; i++) { Vector3 p = new Vector3(Random.Range(-200f, 200f), 0.2f, Random.Range(-200f, 200f)); Instantiate(ozAI, p, Quaternion.Euler(0, Random.Range(0f, 360f), 0)); } }
public override void Step(OzAI ai, OzHuman human) { if (target == null) { return; } if (target.lassitude) { ChangeAI(new SeekingAI1()); return; } Debug.Log("Chasing"); var d = target.gameObject.transform.position - human.transform.position; var v = d.normalized; var w = human.transform.rotation * new Vector3(0, 0, 1); var dot = Vector3.Dot(v, w); var cross = Vector3.Cross(v, w).y; //Debug.Log("d = " + d); if (d.magnitude < 6f && cross < 0 && dot > 0) { HSwing(); PauseFor(1f); } else if (human.rigid.velocity.magnitude < 2f) { RowFront(); PauseFor(1f); } else { if (dot >= 0.9f) { RowFront(); PauseFor(0.8f); } else if (cross > 0.1) { RowLeft(); PauseFor(0.3f); } else { RowRight(); PauseFor(0.3f); } } }
public override void Step(OzAI ai, OzHuman human) { if (target == null) { PauseFor(5.0f); target = GameObject.FindGameObjectsWithTag("NPC")[0]; } var d = target.transform.position - human.transform.position; var v = d.normalized; var w = human.transform.rotation * new Vector3(0, 0, 1); var dot = Vector3.Dot(v, w); var cross = Vector3.Cross(v, w).y; //Debug.Log("d = " + d); if (d.magnitude < 5f && cross < 0 && dot > 0) { HSwing(); PauseFor(1f); } else if (human.rigid.velocity.magnitude < 2f) { RowFront(); PauseFor(1f); } else { if (dot >= 0.9f) { RowFront(); PauseFor(0.8f); } else if (cross > 0.1) { RowLeft(); PauseFor(0.3f); } else { RowRight(); PauseFor(0.3f); } } }
public override void Step(OzAI ai, OzHuman human) { if (human.rigid.velocity.magnitude < targetVelo) { RowFront(); PauseFor(1f); targetDir = Random.Range(0, 2); } else { if (targetDir == 0) { RowLeft(); } else { RowRight(); } PauseFor(0.4f); } targetVelo = Random.Range(5f, 8f); }
// Start is called before the first frame update void Start() { instance = this; bowlSize = 200; if (!PlayerPrefs.HasKey("gameCount")) { PlayerPrefs.SetInt("gameCount", 0); } gameCount = PlayerPrefs.GetInt("gameCount") + 1; PlayerPrefs.SetInt("gameCount", gameCount); killCount = 0; gameBeginningTime = Time.time; gameEndTime = float.NaN; maxSpeed = 0f; playerOz = GameObject.Find("Oz").transform.Find("human2a").GetComponent <OzHuman>(); for (int i = 0; i < 30; i++) { SpawnRowingNPC(); } GetComponent <SpawnRings>().Spawn(); GetComponent <SpawnSpoon>().Spawn(); fadeInPanel = GameObject.Find("FadeInPanel"); var image = fadeInPanel.GetComponent <Image>(); var text = fadeInPanel.transform.GetChild(0).GetComponent <Text>(); image.color = new Color(0f, 0f, 0f, 1f); text.color = new Color(1f, 1f, 1f, 1f); text.text = "O#" + gameCount; spawnTimer = 0f; }
public TestRowFront(OzHuman oz) : base(oz, DURATION) { }
public TestHSwing1(OzHuman oz) : base(oz, DURATION) { }
public void SetUp(OzAI ai, OzHuman human) { this.ai = ai; this.human = human; }
public TestRowRight(OzHuman oz) : base(oz, DURATION) { }
public ChasingAI2(OzHuman target) { this.target = target; }
public TestRowBack(OzHuman oz) : base(oz, DURATION) { }
public TestRowLeft(OzHuman oz) : base(oz, DURATION) { }
public abstract void Step(OzAI ai, OzHuman human);
public TestAction(OzHuman oz) : base(oz, DURATION) { }
// Start is called before the first frame update void Start() { human = transform.parent.gameObject; ozHuman = human.GetComponent <OzHuman>(); }