/// <summary>
 /// Construtor para criar uma casa com cor.
 /// </summary>
 /// <param name="tileColor"> Cor da casa. </param>
 /// <param name="tileType"> Tipo da casa. </param>
 public Tile(EnumColor tileColor, EnumTileType tileType)
 {
     TileColor   = tileColor;
     TileType    = tileType;
     ghostOnTile = null;
     pos         = new Position();
 }
示例#2
0
        /// <summary>
        /// Create a Tile with a random type (not Unknown) at a specified position
        /// </summary>
        /// <param name="position">The position of the Tile</param>
        /// <returns>The newly created Tile</returns>
        public static Tile CreateTileAt(Position position, EnumTileType tileType = EnumTileType.Unkown)
        {
            if (tileType == EnumTileType.Unkown)
            {
                EnumTileType[] tileTypes = ((EnumTileType[])Enum.GetValues(typeof(EnumTileType))).Where(t => (EnumTileType)t != EnumTileType.Unkown).ToArray();
                Random         random    = new Random();
                tileType = (EnumTileType)tileTypes.GetValue(random.Next(tileTypes.Length));
            }

            return(tileType.CreateNewTileFromType(position));
        }
示例#3
0
 /// <summary>
 /// Instantiate a Tile of a specific type
 /// </summary>
 /// <param name="type">The type of the new Tile to create</param>
 /// <param name="position">The position of the Tile</param>
 /// <returns>The newly create Tile</returns>
 public static Tile CreateNewTileFromType(this EnumTileType type, Position position)
 {
     if (type == EnumTileType.Rock)
     {
         return(new TileRock(position));
     }
     else if (type == EnumTileType.Ice)
     {
         return(new TileIce(position));
     }
     else if (type == EnumTileType.Lava)
     {
         return(new TileLava(position));
     }
     else if (type == EnumTileType.Wall)
     {
         return(new TileWall(position));
     }
     throw new InvalidOperationException($"Unable to create a Tile of type [{type.ToString()}].");
 }
 /// <summary>
 /// Construtor para criar o tipo de casa ( Mirror, Portal ou Tile ).
 /// </summary>
 /// <param name="tileType"> Tipo de casa. </param>
 public Tile(EnumTileType tileType)
 {
     TileType    = tileType;
     ghostOnTile = null;
     pos         = new Position();
 }