Example #1
0
    // Percepts
    private void Spotting()
    {
        foreach (Agent a in LevelManager.Instance.Agents)
        {
            OtherAgent oa = new OtherAgent(a.name, a.Team, a.transform.position, a.visionDirection, a.direction);
            if (InFieldOfVision(a.name))
            {
                // Update position & looking direction
                if (seenOtherAgents.ContainsKey(oa.Name))
                {
                    seenOtherAgents[oa.Name].Position        = oa.Position;
                    seenOtherAgents[oa.Name].VisionDirection = oa.VisionDirection;
                }
                else
                {
                    seenOtherAgents.Add(oa.Name, oa);
                    AgentGroup.SeenAgent(oa);
                }

                if (TargetAgent != null && TargetAgent.Enemy.Equals(oa))
                {
                    TargetAgent.Enemy.Position = oa.Position;
                }
            }
            else
            {
                AgentGroup.UnseenAgent(oa);

                // Remove unseen agents
                seenOtherAgents.Remove(oa.Name);
            }
        }
    }
Example #2
0
 // Placeholder for dying
 private void Die()
 {
     foreach (OtherAgent oa in seenOtherAgents.Values)
     {
         AgentGroup.UnseenAgent(oa);
     }
     AgentGroup.DeleteMember(this);
     LevelManager.Instance.DeleteAgent(this);
 }