Пример #1
0
        public override double GetMovementCost(Tile origin, Tile destination)
        {
            double baseCost = base.GetMovementCost(origin, destination);

            // The movement cost for orcs on Plain tile is divided by 2
            if (destination.GetType() == typeof(PlainTile))
            {
                return baseCost / 2;
            }

            return baseCost;
        }
Пример #2
0
 public override bool CanMove(Tile origin, Tile destination, bool areAdjacent)
 {
     // A Dwarf can move like any other Unit,
     // But can also moves (teleports) if the origin and destination Tile are MoutainTile
     return (
         base.CanMove(origin, destination, areAdjacent)
         ||
         (
             MovementPoints >= GetMovementCost(origin, destination)
             &&
             origin.GetType() == typeof(MountainTile)
             &&
             destination.GetType() == typeof(MountainTile)
         )
     );
 }
Пример #3
0
        public override double GetMovementCost(Tile origin, Tile destination)
        {
            double baseCost = base.GetMovementCost(origin, destination);

            // The movement cost for elfs on Forest tile is divided by 2
            if (destination.GetType() == typeof(ForestTile))
            {
                return baseCost / 2;
            }
            // The movement cost for elfs on Desert tile is multiplied by 2
            else if (destination.GetType() == typeof(DesertTile))
            {
                return baseCost * 2;
            }

            return baseCost;
        }
Пример #4
0
        public override double GetMovementCost(Tile origin, Tile destination)
        {
            double baseCost = base.GetMovementCost(origin, destination);

            // The movement cost for knights on Plain tile is divided by 2
            if (destination.GetType() == typeof(PlainTile))
            {
                return baseCost / 2;
            }
            // The movement cost for knights on Swamp tile is multiplied by 2
            else if (destination.GetType() == typeof(SwampTile))
            {
                return baseCost * 2;
            }

            return baseCost;
        }
Пример #5
0
 public static TileType GetType(Tile tile)
 {
     var type = tile.GetType().Name;
     switch (type)
     {
         case "DesertTile":
             return TileType.Desert;
         case "ForestTile":
             return TileType.Forest;
         case "MoutainTile":
             return TileType.Mountain;
         case "PlainTile":
             return TileType.Plain;
         case "SeaTile":
             return TileType.Sea;
         case "SwampTile":
             return TileType.Swamp;
         default:
             throw new ArgumentException("Impossible to retrieve type of Tile \"" + type + "\"", "tile");
     }
 }
Пример #6
0
        public override double GetMovementCost(Tile origin, Tile destination)
        {
            double baseCost = base.GetMovementCost(origin, destination);

            // The movement cost for slimes on Swamp tile is divided by 4
            if (destination.GetType() == typeof(SwampTile))
            {
                return baseCost / 4;
            }
            // The movement cost for slimes on Desert tile is multiplied by 2
            else if (destination.GetType() == typeof(DesertTile))
            {
                return baseCost * 2;
            }
            // The movement cost for slimes on Moutain tile is multiplied by 2
            else if (destination.GetType() == typeof(MountainTile))
            {
                return baseCost * 2;
            }

            return baseCost;
        }
Пример #7
0
 public void Move(Tile origin, Tile destination, bool areAdjacent)
 {
     if (CanMove(origin, destination, areAdjacent))
     {
         MovementPoints -= GetMovementCost(origin, destination);
     }
 }
Пример #8
0
 public virtual double GetMovementCost(Tile origin, Tile destination)
 {
     // By default the movement cost is one (but some units may redefine this, e.g: the orc unit)
     return DefaultMovementCost;
 }
Пример #9
0
 public virtual bool CanMove(Tile origin, Tile destination, bool areAdjacent)
 {
     // By default the movement is valide,
     // If the unit has anought movement points to move to the destination and if the tiles are adjacent
     // (but some units may redefine this, e.g: the orc unit)
     return MovementPoints >= GetMovementCost(origin, destination) && areAdjacent;
 }
Пример #10
0
 public TileContext(Point coordinates, Tile tile)
 {
     this.tile = tile;
     Coordinates = coordinates;
 }