Example #1
0
    public void SeesEnemy(HumanoidModel enemy, Vector3 location)
    {
        /*
         * first remove the nearest enemy marker that is in range
         * if seeing enemy for the first time
         */
        EnemyTarget target = null;

        viewableEnemies.TryGetValue(enemy, out target);
        if (target == null)
        {
            foreach (CommunicatableEnemyMarker marker in hiddenEnemies)
            {
                if (Vector3.Distance(location, marker.GetEnemyMarker().GetLocation()) < hiddenEnemyRadius)
                {
                    marker.Invalidate();
                    HumanoidTargeterCommunication.Communicate(
                        new CommunicationPackage(
                            GetDeepCopyOfHiddenEnemies(),
                            this
                            )
                        );
                    RemoveHiddenEnemy(marker);
                    break;
                }
            }
        }

        // next add viewable enemy
        viewableEnemies[enemy] = new EnemyTarget(enemy, location);
    }
Example #2
0
    public void DoesNotSeeEnemy(HumanoidModel enemy)
    {
        EnemyTarget enemyTarget;

        viewableEnemies.TryGetValue(enemy, out enemyTarget);
        if (enemyTarget != null)
        {
            viewableEnemies.Remove(enemy);
            EnemyMarker newMarker = new EnemyMarker(enemyTarget, this);
            CommunicatableEnemyMarker newCMarker = new CommunicatableEnemyMarker(
                newMarker,
                checkHiddenEnemyRadius
                );
            // avoid clustering enemy markers in one spot
            if (NoMarkerTooCloseTo(newCMarker))
            {
                AddHiddenEnemy(newCMarker);
                HumanoidTargeterCommunication.Communicate(
                    new CommunicationPackage(
                        GetDeepCopyOfHiddenEnemies(),
                        this
                        )
                    );
            }
        }
    }
Example #3
0
 /*
  * Communicator must be in hiddenEnemies
  */
 public void InvalidateMarker(CommunicatableEnemyMarker communicator)
 {
     communicator.Invalidate();
     HumanoidTargeterCommunication.Communicate(
         new CommunicationPackage(
             GetDeepCopyOfHiddenEnemies(),
             this
             )
         );
     RemoveHiddenEnemy(communicator);
 }
Example #4
0
    public void RecieveCommunication(CommunicationPackage package)
    {
        //Debug.Log("Sent by: " + package.GetIssuer().gameObject.name + " to " + this.gameObject.name + " for package " + package.id);
        HashSet <CommunicatableEnemyMarker> markerPayload = package.GetPayload();

        foreach (CommunicatableEnemyMarker marker in markerPayload)
        {
            if (marker.IsValid())
            {
                if (NoMarkerTooCloseTo(marker))
                {
                    AddHiddenEnemy(marker.GetNewMarker());
                }
            }
            else
            {
                RemoveHiddenEnemy(marker);
            }
        }

        HumanoidTargeterCommunication.Communicate(package.RecievedBy(this));
    }
Example #5
0
 // Use this for initialization
 void Start()
 {
     HumanoidTargeterCommunication.AddBlackBoardSubscriber(this);
 }
Example #6
0
 public void InterruptCommunication()
 {
     HumanoidTargeterCommunication.InterruptUpdate(this);
 }
Example #7
0
 // Use this for initialization
 private void Awake()
 {
     targeters     = new HashSet <HumanoidTargeter>();
     communicators = new List <Communicator>();
     instance      = this;
 }