示例#1
0
 public NPC_Alert(NPC_BehaviorAI npcStatePattern)
 {
     npc      = npcStatePattern;
     npcSight = npc.npcSight;
     npcMove  = npc.npcMove;
     npcStats = npc.npcStats;
 }
示例#2
0
 void Start()
 {
     if (npc == null)
     {
         npc = GetComponent <NPC_BehaviorAI>();
     }
     offset = npc.head.position.y;
 }
示例#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);
    }
示例#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);
    }
示例#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;
    }
示例#6
0
 public NPC_Sight(NPC_BehaviorAI _npc)
 {
     npc      = _npc;
     npcStats = npc.npcStats;
 }
示例#7
0
 void Awake()
 {
     npc = GetComponent <NPC_BehaviorAI>();
 }