예제 #1
0
        /// <summary>
        /// Gets all occupying and obstructing agents ordered per status in a dictionary.
        /// </summary>
        /// <param name="inAgent">Agent to check obstruction for.</param>
        /// <returns>Dictionary containing all obstructing agents order per status.</returns>
        public Dictionary <NavTileAgent.EMovementStatus, List <NavTileAgent> > GetSortedOccupyingAgents(NavTileAgent inAgent)
        {
            Dictionary <NavTileAgent.EMovementStatus, List <NavTileAgent> > dic = new Dictionary <NavTileAgent.EMovementStatus, List <NavTileAgent> >();
            NavTileAgentManager manager = NavTileManager.Instance.AgentManager;

            foreach (NavTileAgent agent in OccupyingAgents)
            {
                if (manager.GetValue(inAgent.AgentType, agent.AgentType))
                {
                    List <NavTileAgent> agents;
                    if (dic.TryGetValue(agent.MovementStatus, out agents))
                    {
                        agents.Add(agent);
                    }
                    else
                    {
                        agents = new List <NavTileAgent>()
                        {
                            agent
                        };

                        dic.Add(agent.MovementStatus, agents);
                    }
                }
            }

            return(dic);
        }
예제 #2
0
        /// <summary>
        /// Checks if this tile contains an agent that obstructs the given agent.
        /// </summary>
        /// <param name="inAgent">Agent to check obstruction for.</param>
        /// <param name="outObstructingAgent">Found agent that is obstructing.</param>
        /// <returns>Whether or not an obstruction was found.</returns>
        public bool IsObstructed(NavTileAgent inAgent, out NavTileAgent outObstructingAgent)
        {
            NavTileAgentManager manager = NavTileManager.Instance.AgentManager;

            outObstructingAgent = null;

            foreach (NavTileAgent agent in OccupyingAgents)
            {
                if (manager.GetValue(inAgent.AgentType, agent.AgentType))
                {
                    outObstructingAgent = agent;
                    return(true);
                }
            }

            return(false);
        }