Exemple #1
0
        public override void Reason(GameObject player, AIAdvanced aicompnet)
        {
            GameObject murdeer = Npc.GetComponent <SqAI>().Murdeer;

            if (IsAttacked)
            {
                IsAttacked = false;
                aicompnet.PerformTransition(AIAdvanced.Transition.BeAttacked);
            }
            if (Vector3.Distance(murdeer.transform.position, Npc.transform.position) > Distance)
            {
                aicompnet.PerformTransition(AIAdvanced.Transition.LostPlayer);
            }
            else
            {
                Vector3    direction = murdeer.transform.position - Npc.transform.position;
                RaycastHit hit;
                if (Physics.Raycast(Npc.transform.position, direction, out hit, Distance))
                {
                    if (hit.collider.gameObject != murdeer)
                    {
                        aicompnet.PerformTransition(AIAdvanced.Transition.LostPlayer);
                    }
                }
            }
        }
Exemple #2
0
        public override void Reason(GameObject player, AIAdvanced aicompnet)
        {
            Vector3 direction = player.transform.position - Npc.transform.position;

            if ((Vector3.Angle(direction, Npc.transform.forward) < 80))
            {
                RaycastHit hit;
                if (Physics.Raycast(Npc.transform.position, direction, out hit, 80))
                {
                    if (hit.collider.gameObject == player)
                    {
                        aicompnet.PerformTransition(AIAdvanced.Transition.SawPlayer);
                    }
                }
            }
            if (IsAttacked)
            {
                IsAttacked = false;
                aicompnet.PerformTransition(AIAdvanced.Transition.BeAttacked);
            }
        }
Exemple #3
0
 public override void Act(GameObject player, AIAdvanced aicompnet)
 {
     if (ActO != null)
     {
         ActO();
     }
     if (flag)
     {
         float e = 0;
         if (Npc.GetComponent <SqAI>().Murdeer != null)
         {
             e = Vector3.Angle(Npc.GetComponent <SqAI>().Murdeer.transform.position, Npc.transform.position);
         }
         else
         {
             e = Vector3.Angle(player.transform.position, Npc.transform.position);
         }
         float x = 1.5f * Distance * Mathf.Cos(e);
         float z = 1.5f * Distance * Mathf.Sin(e);
         float y = Terrain.activeTerrain.SampleHeight(new Vector3(Pointer.x + x, Pointer.y, Pointer.z + z));
         Npc.GetComponent <NavMeshAgent>().destination = new Vector3(Pointer.x + x, y, Pointer.z + z);
         flag = false;
     }
     else
     {
         if (Npc.transform.position.x < 110 || Npc.transform.position.x > 420 || Npc.transform.position.z < 70 || Npc.transform.position.z > 420)
         {
             Npc.GetComponent <NavMeshAgent>().destination = Pointer;
             flag = true;
             //Npc.transform.Rotate(Npc.transform.up * (90 + UnityEngine.Random.Range(0, 180)));
         }
         if (Vector3.Distance(Npc.transform.position, Pointer) > Distance)
         {
             Pointer = Npc.transform.position;
             flag    = true;
         }
     }
 }
Exemple #4
0
 public override void Act(GameObject player, AIAdvanced aicompnet)
 {
     if (ActO != null)
     {
         ActO();
     }
     if (flag)
     {
         float e = UnityEngine.Random.Range(0, 2 * Mathf.PI);
         float x = 1.5f * PatrlR * Mathf.Cos(e);
         float z = 1.5f * PatrlR * Mathf.Sin(e);
         float y = Terrain.activeTerrain.SampleHeight(new Vector3(PatrlPointer.x + x, PatrlPointer.y, PatrlPointer.z + z));
         try
         {
             if (nma.isOnNavMesh)
             {
                 nma.destination = new Vector3(PatrlPointer.x + x, y, PatrlPointer.z + z);
             }
             else
             {
                 GameObject.Find("Hero").transform.FindChild("Player").GetComponent <UnitSyncCmd>().CmdDes(Npc);
             }
             flag = false;
         }
         catch { flag = true; }
     }
     if (Vector3.Distance(PatrlPointer, Npc.transform.position) > PatrlR || Npc.transform.position.x < 110 || Npc.transform.position.x > 420 || Npc.transform.position.z < 70 || Npc.transform.position.z > 420)
     {
         nma.destination = PatrlPointer;
         //Npc.transform.Rotate(Npc.transform.up * (90 + UnityEngine.Random.Range(0, 180)));
     }
     if (nma.hasPath == false)
     {
         flag = true;
     }
 }
Exemple #5
0
 public abstract void Reason(GameObject player, AIAdvanced aicompnet);