예제 #1
0
파일: Game.cs 프로젝트: RuMichael/Tetris
    public void UpdateGrid(TetroMino tetroMino)         //запись в Grid новых Tetromino
    {
        for (int y = 0; y < GridHeight; y++)
        {
            for (int x = 0; x < GridWeight; x++)
            {
                if (grid[x, y] != null)
                {
                    if (grid[x, y].parent == tetroMino.transform)
                    {
                        grid[x, y] = null;
                    }
                }
            }
        }

        foreach (Transform mino in tetroMino.transform)
        {
            Vector2 pos = Round(mino.position);
            if (pos.y < GridHeight)
            {
                grid[(int)pos.x, (int)pos.y] = mino;
            }
        }
    }
예제 #2
0
 /// <summary>
 /// Проверка на превышение верхней границы грид
 /// </summary>
 /// <param name="tetromino"></param>
 /// <returns></returns>
 public bool CheckIsAboveGrid(TetroMino tetromino)
 {
     foreach (Transform mino in tetromino.transform)
     {
         Point pos = ReverseVector(TetroMino.positionDeterminationMino(mino));
         if (pos.j > GridHeight - 1)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
파일: Game.cs 프로젝트: RuMichael/Tetris
    public bool CheckIsAboveGrid(TetroMino tetromino)
    {
        foreach (Transform mino in tetromino.transform)
        {
            Vector2 pos = Round(mino.position);
            if (pos.y > GridHeight - 1)
            {
                return(true);
            }
        }


        return(false);
    }
예제 #4
0
 public void GoStart(Player player)
 {
     for (int y = 0; y < GridHeight; y++)
     {
         for (int x = 0; x < GridWeight; x++)
         {
             grid[x, y] = null;
         }
     }
     this.player      = player;
     previewTetromino = null;
     hub_Name.text    = player.GetName;
     timer            = Time.time;
     SpawnNextTetromino();
 }
예제 #5
0
    /// <summary>
    /// запись в Grid новых Tetromino
    /// </summary>
    /// <param name="tetroMino"></param>
    public void UpdateGrid(TetroMino tetroMino)
    {
        for (int y = 0; y < GridHeight; y++)
        {
            for (int x = 0; x < GridWeight; x++)
            {
                if (grid[x, y] != null && grid[x, y].parent == tetroMino.transform)
                {
                    grid[x, y] = null;
                }
            }
        }

        foreach (Transform mino in tetroMino.transform)
        {
            Point pos = ReverseVector(TetroMino.positionDeterminationMino(mino));
            if (pos.j < GridHeight)
            {
                grid[(int)pos.i, (int)pos.j] = mino;
            }
        }
    }
예제 #6
0
    public void SpawnNextTetromino()
    {
        if (previewTetromino == null)
        {
            GameObject next = (GameObject)Instantiate(GetRandomTetromino(), transform);
            changeGridPosition = new Vector3(4, 20, 0);
            nextTetromino      = next.GetComponent <TetroMino>();
        }
        else
        {
            nextTetromino                         = previewTetromino;
            nextTetromino.enabled                 = true;
            nextTetromino.transform.parent        = transform;
            nextTetromino.transform.localPosition = Vector3.zero;
        }
        nextTetromino.SetGame = this;

        GameObject preview = (GameObject)Instantiate(GetRandomTetromino(), previewTetrominoTransform);

        previewTetromino         = preview.GetComponent <TetroMino>();
        previewTetromino.enabled = false;
    }