Exemplo n.º 1
0
    protected override void UpdateAllyPositions()
    {
        // keep an update on who we can see
        foreach (UnitMover unit in FindUnits(DesiredTeam))
        {
            Vector3 targetPoint = unit.GetComponent <Collider>().bounds.center;
            if (HasLineOfSight(targetPoint))
            {
                LastSeenAlly seenEvent = new LastSeenAlly()
                {
                    Position = unit.transform.position,
                    Velocity = unit.MoveVector,
                    TimeSeen = Time.timeSinceLevelLoad,
                    IsPlayer = unit.gameObject.tag.Equals("Player")
                };

                allyPositions[unit.gameObject.GetInstanceID()] = seenEvent;
            }
        }

        foreach (LastSeenAlly lastSeen in allyPositions.Values)
        {
            DrawCross(lastSeen.Position, lastSeen.TimeSeen);
        }
    }
Exemplo n.º 2
0
 // do we have a place to move to
 public override bool ShouldProcessUpdate()
 {
     if (allyPositions != null && allyPositions.Count > 0)
     {
         float minDist = float.MaxValue;
         foreach (LastSeenAlly lastSeen in allyPositions.Values)
         {
             float testDist = Vector3.Distance(lastSeen.Position, this.transform.position);
             if (testDist < minDist)
             {
                 minDist       = testDist;
                 beelineTarget = lastSeen;
                 if (minDist < DesiredRadiusToTarget)
                 {
                     // already close enough
                     return(false);
                 }
             }
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
    // should rename to something other than Ally?
    protected override void UpdateAllyPositions()
    {
        IEnumerable <UnitMover> targetObjs = TargetDetection.DetectedObjects.Where(go => go != null && DesiredTags.Contains(go.tag)).Select(go => go.GetComponent <UnitMover>());

        if (targetObjs != null)
        {
            foreach (UnitMover targetObj in targetObjs)
            {
                Vector3 targetPoint = targetObj.GetComponent <Collider>().bounds.center;
                if (HasLineOfSight(targetPoint))
                {
                    LastSeenAlly seenEvent = new LastSeenAlly()
                    {
                        Position = targetObj.transform.position,
                        Velocity = targetObj.MoveVector,
                        TimeSeen = Time.timeSinceLevelLoad,
                        IsPlayer = targetObj.tag.Equals("Player")
                    };

                    allyPositions[targetObj.gameObject.GetInstanceID()] = seenEvent;
                }
            }
        }
    }