Ejemplo n.º 1
0
        protected override List <MovementAlgorithmTile> AddSuccessor(MovementAlgorithmTile ActiveNode, float OffsetX, float OffsetY, int LayerIndex)
        {
            List <MovementAlgorithmTile> ListTerrainSuccessor = new List <MovementAlgorithmTile>();
            List <int> ListLayerPossibility;
            int        NextRegularMovementLayerIndex = Map.GetNextLayerIndex(new Vector3(ActiveNode.Position.X, ActiveNode.Position.Y, LayerIndex), (int)(ActiveNode.Position.X + OffsetX), (int)(ActiveNode.Position.Y + OffsetY), 1f, 15, out ListLayerPossibility);

            foreach (int ActiveLayerIndex in ListLayerPossibility)
            {
                if (Map.CheckForObstacleAtPosition(new Vector3(ActiveNode.Position.X + OffsetX, ActiveNode.Position.Y + OffsetY, ActiveLayerIndex), Vector3.Zero))
                {
                    continue;
                }

                MovementAlgorithmTile ActiveTile = GetTile(ActiveNode.Position.X + OffsetX, ActiveNode.Position.Y + OffsetY, ActiveLayerIndex);
                //Wall
                if (ActiveTile == null || ActiveTile.MVEnterCost == -1 || ActiveTile.MovementCost == -1 ||
                    ActiveTile.TerrainTypeIndex == UnitStats.TerrainWallIndex || ActiveTile.TerrainTypeIndex == UnitStats.TerrainVoidIndex)
                {
                    continue;
                }

                if (!AllowGoThroughGround && ActiveLayerIndex < NextRegularMovementLayerIndex && ActiveLayerIndex != NextRegularMovementLayerIndex && ListLayerPossibility.Contains(LayerIndex))
                {
                    continue;
                }
                //If the NewNode is the parent, skip it.
                //Used for an undefined map or if you don't need to calculate the whole map.
                //ListSuccessors.Add(new AStarNode(ActiveNode, AX, AY));
                ActiveTile.LayerIndex = ActiveLayerIndex;
                ListTerrainSuccessor.Add(ActiveTile);
            }

            return(ListTerrainSuccessor);
        }