Пример #1
0
        /// <summary>
        /// Calculates all possibilities to move next to the Entity provided by <paramref name="p_moveToEntityNode"/>.
        /// </summary>
        private static IEnumerable <ADecisionNode> createMoveToNavigationNodesLink(DecisionTree p_aiDecisionTree, MoveToEntityNode p_moveToEntityNode)
        {
            var l_reachableNavigationNodes =
                NavigationGraphAlgorithm.getReachableNeighborNavigationNodes(
                    NavigationGraphContainer.UniqueNavigationGraph,
                    p_moveToEntityNode.TargetEntity.CurrentNavigationNode,
                    NavigationGraphFlag.CURRENT).GetEnumerator();

            while (l_reachableNavigationNodes.MoveNext())
            {
                MoveToNavigationNodeNode l_moveToNavigationNodeNode = MoveToNavigationNodeNode.alloc(p_moveToEntityNode.SourceEntity.CurrentNavigationNode, l_reachableNavigationNodes.Current);
                DecisionTree.linkDecisionNodes(p_aiDecisionTree, p_moveToEntityNode, l_moveToNavigationNodeNode);
                yield return(l_moveToNavigationNodeNode);
            }


            /* If the source entity is already a neighbor of the target entity, we still create a node to move to same position to simulate the fact of staying at the same position. */
            if (NavigationGraphAlgorithm.areNavigationNodesNeighbors(
                    NavigationGraphContainer.UniqueNavigationGraph,
                    p_moveToEntityNode.SourceEntity.CurrentNavigationNode,
                    p_moveToEntityNode.TargetEntity.CurrentNavigationNode,
                    NavigationGraphFlag.SNAPSHOT))
            {
                MoveToNavigationNodeNode l_moveToNavigationNodeNode = MoveToNavigationNodeNode.alloc(p_moveToEntityNode.SourceEntity.CurrentNavigationNode, p_moveToEntityNode.SourceEntity.CurrentNavigationNode);
                DecisionTree.linkDecisionNodes(p_aiDecisionTree, p_moveToEntityNode, l_moveToNavigationNodeNode);
                yield return(l_moveToNavigationNodeNode);
            }
        }
Пример #2
0
        public static void buildMoveToHealthTrigger(DecisionTree p_decisionTree, Entity p_sourceEntity)
        {
            if (EntityComponentContainer.Components.ContainsKey(typeof(HealthRecoveryTrigger)))
            {
                var l_healthRecoveryTriggers = EntityComponentContainer.Components[typeof(HealthRecoveryTrigger)];
                for (int i = 0; i < l_healthRecoveryTriggers.Count; i++)
                {
                    HealthRecoveryTrigger    l_healthRecoveryTrigger    = l_healthRecoveryTriggers[i] as HealthRecoveryTrigger;
                    MoveToNavigationNodeNode l_moveToNavigationNodeNode = MoveToNavigationNodeNode.alloc(p_sourceEntity.CurrentNavigationNode,
                                                                                                         l_healthRecoveryTrigger.AssociatedEntity.CurrentNavigationNode);
                    DecisionTree.linkDecisionNodes(p_decisionTree, p_decisionTree.RootNode, l_moveToNavigationNodeNode);

                    HealNode l_healNode = HealNode.alloc(p_sourceEntity, l_healthRecoveryTrigger);
                    DecisionTree.linkDecisionNodes(p_decisionTree, l_moveToNavigationNodeNode, l_healNode);
                }
            }
        }