/// <summary> /// Change TerrainType of this tile. /// </summary> /// <param name="type">Enum of the terrain type.</param> public void ChangeTerrainType(Globals.TerrainTypes type) { if (this.type.GetEnum() != type) { this.type = new TerrainType(type); } }
/// <summary> /// Creates a TerrainType of the type specified in t. /// </summary> /// <param name="t">A type of Globals.TerrainTypes.</param> public TerrainType(Globals.TerrainTypes t) { this.type = t; switch (t) { case (Globals.TerrainTypes.Membrane): { this.dmgMod = 0; this.spdMod = 10; this.rscMod = 0; break; } case (Globals.TerrainTypes.Mucus): { this.dmgMod = 0; this.spdMod = 8; this.rscMod = 4; break; } case (Globals.TerrainTypes.Slow): { this.dmgMod = 0; this.spdMod = 5; this.rscMod = 0; break; } case (Globals.TerrainTypes.Infected): { this.dmgMod = 5; this.spdMod = 10; this.rscMod = 0; break; } } }
/// <summary> /// Creates a Tile of the type 'type'. /// </summary> /// <param name="type">Enum of the terrain type.</param> /// <param name="x">Tile x-coordinate.</param> /// <param name="y">Tile y-coordinate.</param> public Tile(int x, int y, Globals.TerrainTypes type) : base(new Vector2(x, y), null) { this.type = new TerrainType(type); this.visibleTo = new HashSet <Player>(); this.units = new Dictionary <Player, HashSet <Unit> >(); this.allUnits = new List <Unit>(); this.position = new Vector2(x, y); this.building = null; this.lineDrawPoints = new List <Vector2>(); }
/// <summary> /// This is a recurisve method that each call creates a new tile for the /// specific terrain type to spread. It will call itself until the number of /// tiles to spread is zero or less. The spread works by randomly choose /// a direction as seen futher down. /// </summary> /// <param name="tileMatrix"></param> /// <param name="xCoord"></param> /// <param name="yCoord"></param> /// <param name="numberOfTiles"></param> /// <param name="type"></param> /// <param name="randomer"></param> private static void SpreadTiles(Tile[,] tileMatrix, int xCoord, int yCoord, int numberOfTiles, Globals.TerrainTypes type, Random randomer) { tileMatrix[xCoord, yCoord] = new Tile(xCoord, yCoord, type); //X represents the adjecent tiles, O is the current tile // X = 1 //2 = X O X = 3 // 4 = X // if (numberOfTiles <= 0 || !(xCoord > 1 && xCoord < tileMatrix.GetLength(0) - 1 && yCoord > 1 && yCoord < tileMatrix.GetLength(1) - 1)) { return; } switch (randomer.Next(4)) { case 0: SpreadTiles(tileMatrix, xCoord, yCoord - 1, numberOfTiles - 1, type, randomer); break; case 1: SpreadTiles(tileMatrix, xCoord - 1, yCoord, numberOfTiles - 1, type, randomer); break; case 2: SpreadTiles(tileMatrix, xCoord + 1, yCoord, numberOfTiles - 1, type, randomer); break; case 3: SpreadTiles(tileMatrix, xCoord, yCoord + 1, numberOfTiles - 1, type, randomer); break; } }
/// <summary> /// Change the type of this TerrainType. /// </summary> /// <param name="newType">Enum of the new type of type.</param> public void setType(Globals.TerrainTypes newType) { this.type = newType; }