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);
            }
        }