コード例 #1
0
        public override float GetMVCost(UnitMapComponent MapComponent, UnitStats UnitStat, MovementAlgorithmTile CurrentNode, MovementAlgorithmTile TerrainToGo)
        {
            float MovementCostToNeighbor = 0;

            if (MapComponent.CurrentMovement == UnitStats.TerrainAir)
            {
                if (Map.GetTerrainLetterAttribute(UnitStat, UnitStats.TerrainAir) == 'C' ||
                    Map.GetTerrainLetterAttribute(UnitStat, UnitStats.TerrainAir) == 'D' ||
                    Map.GetTerrainLetterAttribute(UnitStat, UnitStats.TerrainAir) == '-')
                {
                    MovementCostToNeighbor += 0.5f;
                }
                else
                {
                    MovementCostToNeighbor += 1;
                }
            }
            else
            {
                string TerrainType = Map.GetTerrainType(TerrainToGo);

                if (!UnitStat.ListTerrainChoices.Contains(TerrainType))
                {
                    return(-1);
                }

                char TerrainCharacter = Map.GetTerrainLetterAttribute(UnitStat, TerrainType);

                if ((TerrainCharacter == 'C' || TerrainCharacter == 'D' || TerrainCharacter == '-') && TerrainType != UnitStats.TerrainLand)
                {
                    MovementCostToNeighbor += TerrainToGo.MVMoveCost + 0.5f;
                }
                else if (TerrainCharacter == 'S' && TerrainToGo.MVMoveCost > 1)
                {
                    MovementCostToNeighbor += TerrainToGo.MVMoveCost / 2;
                }
                else
                {
                    MovementCostToNeighbor += TerrainToGo.MVMoveCost;
                }

                if (TerrainToGo.TerrainTypeIndex != GetTile(CurrentNode.Position.X, CurrentNode.Position.Y, (int)MapComponent.Z).TerrainTypeIndex)
                {
                    MovementCostToNeighbor += TerrainToGo.MVEnterCost;
                }
            }

            return(MovementCostToNeighbor);
        }
コード例 #2
0
        public override float GetMVCost(UnitMapComponent MapComponent, UnitStats UnitStat, MovementAlgorithmTile CurrentNode, MovementAlgorithmTile TerrainToGo)
        {
            float MovementCostToNeighbor = 0;

            if (MapComponent.CurrentMovement == "Air")
            {
                if (Map.GetTerrainLetterAttribute(UnitStat, "Air") == 'C' || Map.GetTerrainLetterAttribute(UnitStat, "Air") == 'D' || Map.GetTerrainLetterAttribute(UnitStat, "Air") == '-')
                {
                    MovementCostToNeighbor += 0.5f;
                }
                else
                {
                    MovementCostToNeighbor += 1;
                }
            }
            else
            {
                char TerrainCharacter = Map.GetTerrainLetterAttribute(UnitStat, Map.GetTerrainType(TerrainToGo));

                if ((TerrainCharacter == 'C' || TerrainCharacter == 'D' || TerrainCharacter == '-') && Map.GetTerrainType(TerrainToGo) != "Land")
                {
                    MovementCostToNeighbor += TerrainToGo.MVMoveCost + 0.5f;
                }
                else if (TerrainCharacter == 'S' && TerrainToGo.MVMoveCost > 1)
                {
                    MovementCostToNeighbor += TerrainToGo.MVMoveCost / 2;
                }
                else
                {
                    MovementCostToNeighbor += TerrainToGo.MVMoveCost;
                }

                if (TerrainToGo.TerrainTypeIndex != GetTile(CurrentNode.Position.X, CurrentNode.Position.Y, MapComponent.LayerIndex).TerrainTypeIndex)
                {
                    MovementCostToNeighbor += TerrainToGo.MVEnterCost;
                }
            }

            return(MovementCostToNeighbor);
        }