public Color GetColorBasedOnType(TetroType type) { switch (type) { case TetroType.I: return(I); case TetroType.O: return(O); case TetroType.T: return(T); case TetroType.J: return(J); case TetroType.L: return(L); case TetroType.S: return(S); case TetroType.Z: return(Z); default: return(O); } }
public Tetro GetTetro(TetroType type) { Tetro tetro = pool.Where(t => t.GetTetroType() == type) .FirstOrDefault(); tetro.transform.parent = null; tetro.gameObject.SetActive(true); return(tetro); }
public void SetUp(TetroData data) { this.data = data; name = $"Tetro ({data.Type})"; tetroType = data.Type; SetTilePositions(data.DefaultTilePositions); ApplyColor(); ApplyTexture(); Active = false; }
public Tetro(sbyte[,] gameField, TetroType type) { this.Type = type; this.gameField = gameField; setTetroField(); y = 0; x = gameField.GetUpperBound(1) / 2 - tetroField.GetUpperBound(1) / 2; Fill(); }
public Tetro SpawnRandomTetro() { int length = System.Enum.GetNames(typeof(TetroType)).Length; int i = Random.Range(1, length); TetroType type = (TetroType)i; Tetro tetro = tetroPool.GetTetro(type); tetro.transform.position = spawnPos.position; tetro.gameObject.SetActive(true); tetro.StartFalling(fallSpeed); return(tetro); }
public ActiveCell(TetroType tetroType) { Type = tetroType; }
public CoinCell(TetroType tetroType) : base(tetroType) { }
public Tetromino(TetroType type) { _type = type; MoveDelay = MoveDelayPeriod; Moving = false; }
// Spawns a new tetromino just for holding. Stored in _holdingTetro public void SpawnNewHoldingTetro(TetroType type) { Color color = new Color(1, 1, 1, 1); _holdingTetro = new Tetromino(type); string blockType = ""; switch (_holdingTetro.Type) { case TetroType.LongBlock: { /* * * * * * * * * **/ color.Red = 1.0f; color.Green = 0.2f; color.Blue = 0.0f; blockType = "breadBot_block"; SpawnNewBlock(blockType, "holding"); _holdingTetro.Blocks.Add(_currentBlock); blockType = "breadMid_block"; SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(-_previewLeftBound - ((_blockWidth * 5) / 2), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(-_previewLeftBound - ((_blockWidth * 5) / 2), _currentBlock.GetPosition().Y + (2 * _currentBlock.GetHeight())); _holdingTetro.Blocks.Add(_currentBlock); blockType = "breadTop_block"; SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(-_previewLeftBound - ((_blockWidth * 5) / 2), _currentBlock.GetPosition().Y + (3 * _currentBlock.GetHeight())); _holdingTetro.Blocks.Add(_currentBlock); break; } case TetroType.Square: { /* * ** * ** **/ color.Red = 1.0f; color.Green = 0.0f; color.Blue = 0.0f; blockType = "pickle_block"; SpawnNewBlock(blockType, "holding"); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(-_previewLeftBound - ((_blockWidth * 5) / 2), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X - _currentBlock.GetWidth(), _currentBlock.GetPosition().Y); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X - _currentBlock.GetWidth(), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); break; } case TetroType.LeftHook: { /* * ** * * * * **/ color.Red = 0.0f; color.Green = 1.0f; color.Blue = 0.0f; blockType = "cucumber_block"; SpawnNewBlock(blockType, "holding"); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(-_previewLeftBound - ((_blockWidth * 5) / 2), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(-_previewLeftBound - ((_blockWidth * 5) / 2), _currentBlock.GetPosition().Y + (2 * _currentBlock.GetHeight())); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X - _currentBlock.GetWidth(), _currentBlock.GetPosition().Y + (2 * _currentBlock.GetHeight())); _holdingTetro.Blocks.Add(_currentBlock); break; } case TetroType.RightHook: { /* * ** * * * * **/ color.Red = 0.0f; color.Green = 0.0f; color.Blue = 1.0f; blockType = "tomato_block"; SpawnNewBlock(blockType, "holding"); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(-_previewLeftBound - ((_blockWidth * 5) / 2), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(-_previewLeftBound - ((_blockWidth * 5) / 2), _currentBlock.GetPosition().Y + (2 * _currentBlock.GetHeight())); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X + _currentBlock.GetWidth(), _currentBlock.GetPosition().Y + (2 * _currentBlock.GetHeight())); _holdingTetro.Blocks.Add(_currentBlock); break; } case TetroType.RightZ: { /* * ** * ** **/ color.Red = 0.5f; color.Green = 0.0f; color.Blue = 0.5f; blockType = "olive_block"; SpawnNewBlock(blockType, "holding"); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X + _currentBlock.GetWidth(), _currentBlock.GetPosition().Y); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X + _currentBlock.GetWidth(), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X + (2 * _currentBlock.GetWidth()), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); break; } case TetroType.LeftZ: { /* * ** * ** **/ color.Red = 1.0f; color.Green = 1.0f; color.Blue = 0f; blockType = "lettuce_block"; SpawnNewBlock(blockType, "holding"); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X - _currentBlock.GetWidth(), _currentBlock.GetPosition().Y); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X - _currentBlock.GetWidth(), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X - (2 * _currentBlock.GetWidth()), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); break; } case TetroType.TBlock: { /* * *** * * **/ color.Red = 0.5f; color.Green = 0.5f; color.Blue = 0.5f; blockType = "pepper_block"; SpawnNewBlock(blockType, "holding"); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X, _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X - _currentBlock.GetWidth(), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); SpawnNewBlock(blockType, "holding"); _currentBlock.SetPosition(_currentBlock.GetPosition().X + _currentBlock.GetWidth(), _currentBlock.GetPosition().Y + _currentBlock.GetHeight()); _holdingTetro.Blocks.Add(_currentBlock); break; } default: { break; } } _holdingTetro.Moving = false; }