/*getTileWithSpecifications(max_height, max_slope) * int max tries * Vector3 pos = 000. * //loop through * //check conditions * //set position * //set occupied * //return position * */ public Vector3 getTileOfType(TILE_TYPES type) { Vector3 pos = new Vector3(); List <Tile> availableTiles = new List <Tile>(); for (int i = 0; i < tiles.GetLength(0); i++) { for (int j = 0; j < tiles.GetLength(1); j++) { if (tiles [i, j].type == type && !tiles[i, j].occupied) { availableTiles.Add(tiles [i, j]); } } } if (availableTiles.Count > 0) { Tile selected = availableTiles [Random.Range(0, availableTiles.Count)]; pos = new Vector3(selected.x, selected.y, selected.z); } return(pos); }
public Tile(MainGame game, TILE_TYPES type, Vector2 mapPosition) { //Salvando os valores: mDrawDepth = 0; mHeight = 0; mMapPosition = mapPosition; mType = type; _state = TILE_STATE.NORMAL; _fallTimer = TimeSpan.Zero; _isAlmostFalling = false; //Carregando o sprite: _sprite = new Sprite(game.Content.Load<Texture2D>("Images/Tileset"), Vector2.Zero); _sprite.Color = Color.White; _sprite.Scale = 1f; //Calculando o RECT da imagem a ser desenhado: switch (type) { case TILE_TYPES.NORMAL: _sprite.SpriteRect = new Rectangle(0, 0, (int)TILE_SIZE.X, (int)TILE_SIZE.Y + 6); break; case TILE_TYPES.HEIGHT_ONE: mHeight = 1; _sprite.SpriteRect = new Rectangle((int)TILE_SIZE.X, 0, (int)TILE_SIZE.X, (int)TILE_SIZE.Y * 2); break; case TILE_TYPES.HOLE: _sprite.SpriteRect = new Rectangle(0, 0, (int)TILE_SIZE.X, (int)TILE_SIZE.Y + 6); _sprite.Color = Color.Transparent; break; case TILE_TYPES.SPAWN: _sprite.SpriteRect = new Rectangle(0, 0, (int)TILE_SIZE.X, (int)TILE_SIZE.Y + 6); _sprite.Color = Color.LightGreen; break; case TILE_TYPES.EXIT: _sprite.SpriteRect = new Rectangle(0, 0, (int)TILE_SIZE.X, (int)TILE_SIZE.Y + 6); _sprite.Color = Color.Blue; break; default: mHeight = 0; break; } }
public void Fall() { //Criando o Random: Random rand = new Random(); //Setando a velocidade: _state = TILE_STATE.FALLING; _speed = new Vector2(0,rand.Next(2, 6)); //Definindo o tile como caível: mType = TILE_TYPES.HOLE; }