Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        public Tetro GetTetro(TetroType type)
        {
            Tetro tetro = pool.Where(t => t.GetTetroType() == type)
                          .FirstOrDefault();

            tetro.transform.parent = null;
            tetro.gameObject.SetActive(true);
            return(tetro);
        }
Exemplo n.º 3
0
 public void SetUp(TetroData data)
 {
     this.data = data;
     name      = $"Tetro ({data.Type})";
     tetroType = data.Type;
     SetTilePositions(data.DefaultTilePositions);
     ApplyColor();
     ApplyTexture();
     Active = false;
 }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public ActiveCell(TetroType tetroType)
 {
     Type = tetroType;
 }
Exemplo n.º 7
0
 public CoinCell(TetroType tetroType) : base(tetroType)
 {
 }
Exemplo n.º 8
0
 public Tetromino(TetroType type)
 {
     _type = type;
     MoveDelay = MoveDelayPeriod;
     Moving = false;
 }
Exemplo n.º 9
0
 // 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;
 }