コード例 #1
0
ファイル: Tetris.cs プロジェクト: AntonyF92/Tetris
    void RotateShape()
    {
        _currentShape.RotateRight();
        var checkPos = CheckPosForShift(_currentShape.transform);

        if (checkPos)
        {
            UpdateGameField(_currentShape.transform);
        }
        else
        {
            if (_deltaX != 0)
            {
                var oldPos = _currentShape.transform.position;
                if (TryShiftAfterRotate())
                {
                    UpdateGameField(_currentShape.transform);
                }
                else
                {
                    _currentShape.transform.position = oldPos;
                    _currentShape.RotateLeft();
                }
            }
            else
            {
                _currentShape.RotateLeft();
            }
        }
    }
コード例 #2
0
    void NextShape()
    {
        int next = 0;

        for (int i = 0; i < 4; i++)
        {
            next = Random.Range(0, 10000) % shapeList.Length;
            if (!_usedElements.Contains(next))
            {
                break;
            }
        }

        _spawnedObj = Instantiate(shapeList[next], nextShapePoint.transform);
        _spawnedSp  = _spawnedObj.GetComponent <ShapeProps>();

        for (int i = 0; i < (int)Random.Range(0, 4); i++)
        {
            _spawnedSp.RotateRight();
        }

        SaveToUsedElements(next);
    }