Beispiel #1
0
        void informNearbyAllies()
        {
            if (Time.time > nextInform)
            {
                nextInform = Time.time + informRate;

                friendlyCollider = Physics.OverlapSphere(npc.transform.position, npc.sightRange, npc.myFriendlyLayers);

                if (friendlyCollider.Length == 0)
                {
                    return;
                }

                foreach (Collider ally in friendlyCollider)
                {
                    if (ally.transform.root.GetComponent <NPCManager_StatePattern>() != null)
                    {
                        NPCManager_StatePattern allyNPC = ally.transform.root.GetComponent <NPCManager_StatePattern>();

                        if (allyNPC.currentState == allyNPC.patrolState)
                        {
                            allyNPC.pursueTarget       = npc.pursueTarget;
                            allyNPC.locationOfInterest = npc.pursueTarget.position;
                            allyNPC.currentState       = allyNPC.alertState;
                            allyNPC.npcManagerMasterScript.callNPCWalkAnimEvent();
                        }
                    }
                }
            }
        }
Beispiel #2
0
        void alertNearbyAllies()
        {
            foreach (Collider ally in friendlyColliders)
            {
                if (ally.transform.root.GetComponent <NPCManager_StatePattern>() != null)
                {
                    NPCManager_StatePattern npcPattern = ally.transform.root.GetComponent <NPCManager_StatePattern>();

                    if (npcPattern.currentState == npcPattern.patrolState)
                    {
                        npcPattern.pursueTarget       = npc.myAttacker;
                        npcPattern.locationOfInterest = npc.myAttacker.position;
                        npcPattern.currentState       = npcPattern.investigateState;
                        npcPattern.npcManagerMasterScript.callNPCWalkAnimEvent();
                    }
                }
            }
        }
        void initiate()
        {
            npcManagerMasterScript = GetComponent <NPCManager_Master>();

            if (GetComponent <Animator>() != null)
            {
                myAnimator = GetComponent <Animator>();
            }

            if (GetComponent <NavMeshAgent>() != null)
            {
                myNavMeshAgent = GetComponent <NavMeshAgent>();
            }

            if (GetComponent <NPCManager_StatePattern>() != null)
            {
                myPattern = GetComponent <NPCManager_StatePattern>();
            }
        }
 public NPCManager_FleeState(NPCManager_StatePattern pattern)
 {
     npc = pattern;
 }
Beispiel #5
0
 public NPCManager_AlertState(NPCManager_StatePattern npcStatePattern)
 {
     npc = npcStatePattern;
 }
 public NPCManager_FollowState(NPCManager_StatePattern pattern)
 {
     npc = pattern;
 }
 public NPCManager_PatrolState(NPCManager_StatePattern npcStatePat)
 {
     npc = npcStatePat;
 }
Beispiel #8
0
 public NPCManager_RangeAttackState(NPCManager_StatePattern pattern)
 {
     npc = pattern;
 }
 public NPCManager_InvestigateState(NPCManager_StatePattern pattern)
 {
     npc = pattern;
 }
 void initiate()
 {
     npc        = GetComponent <NPCManager_StatePattern>();
     myAnimator = GetComponent <Animator>();
 }
Beispiel #11
0
 public NPCManager_StruckState(NPCManager_StatePattern pattern)
 {
     npc = pattern;
 }
 public NPCManager_PursueState(NPCManager_StatePattern pattern)
 {
     npc = pattern;
 }