コード例 #1
0
        public void Contains_SameType_True()
        {
            Motility motility  = Motility.Fly;
            Motility motility2 = Motility.Fly;

            Assert.IsTrue(motility.Contains(motility2));
        }
コード例 #2
0
        /// <summary>
        /// Checks if a given edge is traversable given the motility flags passed in. Will check both movement
        /// motility as well as filter out edges based on the most permissive n-WayNeighbor's flag set. If no
        /// neighbor flag is set, it defaults to Motility.AllNeighbors.
        /// </summary>
        /// <param name="edge">The edge attempting traversal.</param>
        /// <param name="agentMotility">The agent's ability to traverse edges.</param>
        public static bool IsTraversable(GridNode edge, Motility agentMotility)
        {
            // Identify the graph structure for this agent and reject extraneous neighbors.
            if (agentMotility.Contains(Motility.AllNeighbors))
            {
                // Most permissive option is true, so continue to next step, skipping the other checks.
            }
            else if (agentMotility.Contains(Motility.EightWayNeighbors))
            {
                // Reject only special nodes (such as portals)
                //if (!Direction.Clockwise.Contains(edge.Direction))
                {
                    return(false);
                }
            }
            else if (agentMotility.Contains(Motility.FourWayNeighbors))
            {
                // Reject the intercardinal directions (diagonals) as well as any special nodes (such as portals)
                //if (!Direction.CardinalDirections.Contains(edge.Direction))
                {
                    return(false);
                }
            }
            else
            {
                // This is an implicit "has no neighbors flag" flag, which is just a lack of any neighbor flag at all.
                // In this case we default to Motility.AllNeighbors and continue.
            }

            // If the agent has Motility.Unconstrained, then we return, no need to compare to edge Motility.
            if (agentMotility.Contains(Motility.Unconstrained))
            {
                return(true);
            }

            // Check the agent's movement Motility compared to the edge Motility
            throw new NotImplementedException();
            //return edge.IsTraversable(agentMotility);
        }
コード例 #3
0
        public void Contains_SameReference_True()
        {
            Motility motility = Motility.Fly;

            Assert.IsTrue(motility.Contains(motility));
        }