Ejemplo n.º 1
0
 public NPC_Alert(NPC_BehaviorAI npcStatePattern)
 {
     npc      = npcStatePattern;
     npcSight = npc.npcSight;
     npcMove  = npc.npcMove;
     npcStats = npc.npcStats;
 }
Ejemplo n.º 2
0
 void Start()
 {
     if (npc == null)
     {
         npc = GetComponent <NPC_BehaviorAI>();
     }
     offset = npc.head.position.y;
 }
Ejemplo n.º 3
0
    //  Calculates if npc can see target.
    public bool CanSeeTarget(NPC_BehaviorAI npc, Transform target)
    {
        VisibilityCalculations(target);

        if (Vector3.Distance(headPosition, targetPosition) < npc.sightRange &&
            angleBetweenNpcAndPlayer < npc.viewAngle / 2f &&
            Physics.Linecast(npc.transform.position, target.position, npc.myObstacleLayer) == false)
        {
            npc.hasTargetInSight = true;
            return(true);
        }
        npc.hasTargetInSight = false;
        return(false);
    }
Ejemplo n.º 4
0
    void InformNearbyAllies()
    {
        // string alliesInformed = "";
        if (Time.time > nextInform)
        {
            nextInform = Time.time + informRate;

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

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

            foreach (Collider ally in friendlyColliders)
            {
                if (ally.transform.root.GetComponent <NPC_BehaviorAI>() != null)
                {
                    NPC_BehaviorAI allyPattern = ally.transform.root.GetComponent <NPC_BehaviorAI>();

                    if (allyPattern.currentState == allyPattern.patrolState)
                    {
                        allyPattern.pursueTarget          = npc.pursueTarget;
                        allyPattern.hasLocationOfInterest = true;
                        allyPattern.locationOfInterest    = npc.pursueTarget.position;
                        allyPattern.currentState          = allyPattern.alertState;
                        // allyPattern.npcMaster.CallEventNpcWalkAnim();

                        // alliesInformed += ally.gameObject.name + "\n";
                        Debug.Log(npc.gameObject.name + " is informing " + ally.gameObject.name);
                    }
                }
            }
        }

        // Debug.Log(alliesInformed);
    }
Ejemplo n.º 5
0
    float minRange = 5;                //  The range for when the npc should move to target location.  If target is within range, npc will not move.


    public NPC_Movement(NPC_BehaviorAI _npc)
    {
        npc      = _npc;
        npcStats = npc.npcStats;
        npcSight = npc.npcSight;
    }
Ejemplo n.º 6
0
 public NPC_Sight(NPC_BehaviorAI _npc)
 {
     npc      = _npc;
     npcStats = npc.npcStats;
 }
Ejemplo n.º 7
0
 void Awake()
 {
     npc = GetComponent <NPC_BehaviorAI>();
 }