Ejemplo n.º 1
0
Archivo: OzAI.cs Proyecto: lumiknit/mc4
        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);
            }
        }
Ejemplo n.º 2
0
Archivo: OzAI.cs Proyecto: lumiknit/mc4
 public override void Step(OzAI ai, OzHuman human)
 {
     if (!HasAction())
     {
         RowFront();
     }
 }
Ejemplo n.º 3
0
Archivo: OzAI.cs Proyecto: lumiknit/mc4
 public void RunStep(OzAI ai, OzHuman human)
 {
     actionTimer -= Time.deltaTime;
     this.ai      = ai;
     this.human   = human;
     if (actionTimer < 0)
     {
         Step(ai, human);
     }
 }
Ejemplo n.º 4
0
Archivo: OzAI.cs Proyecto: lumiknit/mc4
        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);
                }
            }
        }
Ejemplo n.º 5
0
Archivo: OzAI.cs Proyecto: lumiknit/mc4
        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);
                }
            }
        }
Ejemplo n.º 6
0
Archivo: OzAI.cs Proyecto: lumiknit/mc4
 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);
 }
Ejemplo n.º 7
0
Archivo: OzAI.cs Proyecto: lumiknit/mc4
 public void SetUp(OzAI ai, OzHuman human)
 {
     this.ai    = ai;
     this.human = human;
 }
Ejemplo n.º 8
0
Archivo: OzAI.cs Proyecto: lumiknit/mc4
 public abstract void Step(OzAI ai, OzHuman human);