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; }
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) ) ); }
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; }
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; }
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"); } }
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; }
public void Move(Tile origin, Tile destination, bool areAdjacent) { if (CanMove(origin, destination, areAdjacent)) { MovementPoints -= GetMovementCost(origin, destination); } }
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; }
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; }
public TileContext(Point coordinates, Tile tile) { this.tile = tile; Coordinates = coordinates; }