Exemplo n.º 1
0
 public ThreeDots(TetrisGrid parent) : base(parent)
 {
     color           = Color.DimGray;
     BlockGrid[0, 0] = true;
     BlockGrid[2, 0] = true;
     BlockGrid[1, 2] = true;
 }
Exemplo n.º 2
0
 public GameWorld(TetrisGame game)
 {
     this.game               = game;
     random                  = new Random();
     gameState               = GameState.Init;
     font                    = TetrisGame.ContentManager.Load <SpriteFont>("SpelFont");
     menuFont                = TetrisGame.ContentManager.Load <SpriteFont>("MenuFont");
     background              = TetrisGame.ContentManager.Load <Texture2D>("TETRIS");
     controls                = TetrisGame.ContentManager.Load <Texture2D>("Controls");
     endScreen               = TetrisGame.ContentManager.Load <Texture2D>("Gameover");
     emptyCell               = TetrisGame.ContentManager.Load <Texture2D>("block");
     normalTheme             = TetrisGame.ContentManager.Load <Song>("Normaltheme");
     hardTheme               = TetrisGame.ContentManager.Load <Song>("Hardtheme");
     nock                    = TetrisGame.ContentManager.Load <SoundEffect>("nock");
     rowDel                  = TetrisGame.ContentManager.Load <SoundEffect>("rowDel");
     lvlUp                   = TetrisGame.ContentManager.Load <SoundEffect>("lvlUp");
     gameOver                = TetrisGame.ContentManager.Load <SoundEffect>("youLose");
     MediaPlayer.IsRepeating = true;
     grid                    = new TetrisGrid();
     nrBlocks                = 7;
     nextBlock               = Random.Next(nrBlocks);
     ResetBlock();
     dropSpeed    = 1000;
     previousTime = 0;
     timePressed  = 0;
 }
Exemplo n.º 3
0
 public SubBlock(int X, int Y, Color C, TetrisGrid Grid)
 {
     x     = X;
     y     = Y;
     color = C;
     grid  = Grid;
 }
	void Start()
	{
		if ( Grid == null )
		{
			Grid = FindObjectOfType<TetrisGrid>();
		}
	}
Exemplo n.º 5
0
    //모든 블록들의 상태을 바꾸는 함수
    public void BoardUpdate(TetrisGrid mainGrid, TetrisGrid playerGrid )
    {
        if( playerGrid == null )
        {
            for (int y = 0; y < gameScirpt.gridHeight; y++)
            {
                for (int x = 0; x < gameScirpt.gridLength; x++)
                {
                    int val = mainGrid.grid[y, x];

                    if (_boardGrid[y, x] != val)
                    {
                        _boardGrid[y, x] = val;
                        BlockUpdate(x, y, val);
                    }
                }
            }
            return;
        }

        //_boardGrid와 비교하여 변경사항 있으면 적용
        for (int y = 0; y < gameScirpt.gridHeight; y++)
        {
            for (int x = 0; x < gameScirpt.gridLength; x++)
            {
                int temp = mainGrid.grid[y, x] + playerGrid.grid[y, x];

                if (_boardGrid[y, x] != temp)
                {
                    _boardGrid[y, x] = temp;
                    BlockUpdate(x, y, temp);
                }
            }
        }
    }
Exemplo n.º 6
0
 void Start()
 {
     if (Grid == null)
     {
         Grid = FindObjectOfType <TetrisGrid>();
     }
 }
Exemplo n.º 7
0
    public bool CanMoveRelativeTo(int xChange, int yChange)
    {
        foreach (SubBlock subBlock in subBlockArray)
        {
            int newX = subBlock.x + xChange;
            int newY = subBlock.y + yChange;

            if (TetrisGrid.IsInBounds(newX, newY, grid))
            {
                Debug.WriteLine("x: " + newX + " y: " + newY + "test1");
                if (grid.gridArr[newX, newY] != null)
                {
                    Debug.WriteLine("af1");
                    //Debug.WriteLine("x-as width: " + grid.gridArr.GetLength(0) + " y-as height: " + grid.gridArr.GetLength(1));
                    return(false);
                }
            }
            else
            {
                Debug.WriteLine("af2");
                return(false);
            }
        }
        return(true);
    }
Exemplo n.º 8
0
    public GameWorld(int width, int height, ContentManager Content)
    {
        screenWidth = width;
        screenHeight = height;
        random = new Random();
        gameState = GameState.Menu;
        inputHelper = new InputHelper();
        block = Content.Load<Texture2D>("block");
        reset = Content.Load<Texture2D>("reset");
        font = Content.Load<SpriteFont>("SpelFont");
        font2 = Content.Load<SpriteFont>("SpriteFont1");
        font3 = Content.Load<SpriteFont>("SpriteFont2");
        playButton = Content.Load<Texture2D>("Play");
        optionsButton = Content.Load<Texture2D>("Options");
        backButton = Content.Load<Texture2D>("Back");
        polytris = Content.Load<Texture2D>("Polytris");
        grid = new TetrisGrid(block);
        level = 1;
        levelspeed = 1;
        score = 0;
        i = (int)random.Next(7) + 1;
        i2 = (int)random.Next(7) + 1;
        blockcounter = 1;

        blocks = new BlockList(block, Content);          //Voegen de verschillende blockobjecten toe aan de lijst
        block1 = new Block1(block, Content);
        blocks.Add(block1, 1);
        block2 = new Block2(block, Content);
        blocks.Add(block2, 2);
        block3 = new Block3(block, Content);
        blocks.Add(block3, 3);
        block4 = new Block4(block, Content);
        blocks.Add(block4, 4);
        block5 = new Block5(block, Content);
        blocks.Add(block5, 5);
        block6 = new Block6(block, Content);
        blocks.Add(block6, 6);
        block7 = new Block7(block, Content);
        blocks.Add(block7, 7);

        //Voegen de verschillende blockobjecten toe aan een tweede lijst voor het tekenen van het volgende blokje
        block1res = new Block1(block, Content);
        blocks.AddToReserve(block1res, 1);
        block2res = new Block2(block, Content);
        blocks.AddToReserve(block2res, 2);
        block3res = new Block3(block, Content);
        blocks.AddToReserve(block3res, 3);
        block4res = new Block4(block, Content);
        blocks.AddToReserve(block4res, 4);
        block5res = new Block5(block, Content);
        blocks.AddToReserve(block5res, 5);
        block6res = new Block6(block, Content);
        blocks.AddToReserve(block6res, 6);
        block7res = new Block7(block, Content);
        blocks.AddToReserve(block7res, 7);

        options = new Options(block, reset, backButton, width, height, font, blocks);
        menu = new Menu(playButton, optionsButton, polytris, width, height);
        gameOver = new GameOver(backButton, width, height);
    }
Exemplo n.º 9
0
    public GameWorld()
    {
        random    = new Random();
        gameState = GameState.GameOverScreen;

        // Load in the Fonts
        font    = TetrisGame.ContentManager.Load <SpriteFont>("Fonts/8-BitFontSmall");
        fontBig = TetrisGame.ContentManager.Load <SpriteFont>("fonts/8-BitFontBig");

        // Load in the Sounds
        selectSound   = TetrisGame.ContentManager.Load <SoundEffect>("Sounds/Select");
        gameOverSound = TetrisGame.ContentManager.Load <SoundEffect>("Sounds/GameOver");

        nextBlock = new NextBlock();
        grid      = new TetrisGrid();
        block     = new Block();
        score     = new Score();
        hold      = new Hold();

        //States
        title = new TitleScreenState();
        over  = new GameOverState();
        help  = new HelpState();

        over.grid     = grid;
        over.score    = score;
        block.Grid    = grid;
        grid.Gblock   = block;
        score.grid    = grid;
        score.font    = font;
        hold.font     = font;
        title.fontBig = fontBig;
        over.fontBig  = fontBig;
        help.fontBig  = fontBig;
    }
Exemplo n.º 10
0
    /// <summary>
    /// Check lines from bottom to top. If the line is full, then clear the line.
    /// </summary>
    public void CheckLines()
    {
        // Index list of the lines that need to be cleared.
        List <int> linesToClear = new List <int>();

        // Counts how many lines next to each other will be cleared.
        int lineClearNum = 0;
        int lineScoreNum = 0;

        for (int y = 0; y < gridHeight; y++)
        {
            bool lineClear = true;
            for (int x = 0; x < gridWidth; x++)
            {
                if (!_grid[x, y].isOccupied)
                {
                    lineClear    = false;
                    lineClearNum = 0;
                }
            }
            if (lineClear)
            {
                linesToClear.Add(y);
                ClearLine(y);
                isLineCleared = true;

                // Play particle effect after clear line
                ClearLineVFX(lineClearNum, y);
                lineClearNum++;
            }

            // Get the maximum line clear number for score update
            lineScoreNum = lineScoreNum > lineClearNum ? lineScoreNum : lineClearNum;
        }

        // Update Score for line clears
        GameSystem.gsInstance.UpdateScore(lineScoreNum, false);



        // When the lines have been cleared, the lines above those will drop to fill in the empty space
        if (linesToClear.Count > 0)
        {
            for (int i = 0; i < linesToClear.Count; i++)
            {
                for (int lineToDrop = linesToClear[i] + 1 - i; lineToDrop < gridHeight; lineToDrop++)
                {
                    for (int x = 0; x < gridWidth; x++)
                    {
                        TetrisGrid curGrid = _grid[x, lineToDrop];
                        if (curGrid.isOccupied)
                        {
                            MoveBlockDown(curGrid);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 11
0
 public Tpiece(TetrisGrid parent) : base(parent)
 {
     color           = Color.Purple;
     BlockGrid[0, 0] = true;
     BlockGrid[1, 0] = true;
     BlockGrid[2, 0] = true;
     BlockGrid[1, 1] = true;
 }
Exemplo n.º 12
0
 public Jpiece(TetrisGrid parent) : base(parent)
 {
     color           = Color.Orange;
     BlockGrid[1, 0] = true;
     BlockGrid[1, 1] = true;
     BlockGrid[1, 2] = true;
     BlockGrid[0, 2] = true;
 }
Exemplo n.º 13
0
 public Lpiece(TetrisGrid parent) : base(parent)
 {
     color           = Color.Blue;
     BlockGrid[1, 0] = true;
     BlockGrid[1, 1] = true;
     BlockGrid[1, 2] = true;
     BlockGrid[2, 2] = true;
 }
Exemplo n.º 14
0
 public Zpiece(TetrisGrid parent) : base(parent)
 {
     color           = Color.Red;
     BlockGrid[0, 0] = true;
     BlockGrid[1, 1] = true;
     BlockGrid[1, 0] = true;
     BlockGrid[2, 1] = true;
 }
Exemplo n.º 15
0
 public Spiece(TetrisGrid parent) : base(parent)
 {
     color           = Color.LightGreen;
     BlockGrid[0, 1] = true;
     BlockGrid[1, 1] = true;
     BlockGrid[1, 0] = true;
     BlockGrid[2, 0] = true;
 }
Exemplo n.º 16
0
 public static bool IsInBounds(int x, int y, TetrisGrid grid)
 {
     if (x < 0 || x >= grid.width || y < 0 || y >= grid.height)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 17
0
    public bool SetGrid(TetrisGrid grid, Spawner spawner, bool player)
    {
        this.grid    = grid;
        this.spawner = spawner;
        this.player  = player;

        return(IsValidGridPos() == false);
    }
Exemplo n.º 18
0
    public GameWorld()
    {
        random = new Random();
        gameState = GameState.Title;

        font = TetrisGame.ContentManager.Load<SpriteFont>("SpelFont");
        grid = new TetrisGrid();
    }
Exemplo n.º 19
0
    private void Start()
    {
        tetrisGrid = GetComponent <TetrisGrid>();
        tetrisGrid.SetupGrid(width, height);

        tetrisGrid.InitGrid();

        tetrisGrid.CreateTetramino(tetraminoToMove);
    }
Exemplo n.º 20
0
 public GhostBlock(TetrisGrid parent) : base(parent)
 {
     color           = Color.Gray;
     BlockGrid       = new bool[4, 4];
     BlockGrid[1, 0] = true;
     BlockGrid[1, 1] = true;
     BlockGrid[1, 2] = true;
     BlockGrid[1, 3] = true;
 }
Exemplo n.º 21
0
 void setGridInvalid()
 {
     foreach (Transform child in transform)
     {
         Vector2 v = TetrisGrid.roundVec2(child.position);
         TetrisGrid.grid[((int)v.x), (int)v.y] = child;
         //TetrisGrid.setGridInvalid(v);
     }
 }
Exemplo n.º 22
0
 public Ipiece(TetrisGrid parent) : base(parent)
 {
     color           = Color.CornflowerBlue;
     BlockGrid       = new bool[4, 4];
     BlockGrid[1, 0] = true;
     BlockGrid[1, 1] = true;
     BlockGrid[1, 2] = true;
     BlockGrid[1, 3] = true;
 }
Exemplo n.º 23
0
 public OPiece(TetrisGrid parentGrid) : base(parentGrid)
 {
     color = 1;
     shape = new[, ]
     {
         { true, true },
         { true, true }
     };
 }
Exemplo n.º 24
0
 public InvisableTpiece(TetrisGrid parent) : base(parent)
 {
     color           = new Color(254, 254, 254);
     BlockGrid[0, 0] = true;
     BlockGrid[1, 0] = true;
     BlockGrid[2, 0] = true;
     BlockGrid[1, 1] = true;
     BlockGrid[1, 2] = true;
 }
Exemplo n.º 25
0
 public Ldiagonal(TetrisGrid parent) : base(parent)
 {
     color           = Color.DimGray;
     BlockGrid       = new bool[4, 4];
     BlockGrid[0, 0] = true;
     BlockGrid[1, 1] = true;
     BlockGrid[2, 2] = true;
     BlockGrid[3, 3] = true;
 }
Exemplo n.º 26
0
 public Tetris()
 {
     grid     = new TetrisGrid(12, 21, 32, 32);
     graphics = new GraphicsDeviceManager(this)
     {
         PreferredBackBufferWidth  = 12 * grid.cell.Width,
         PreferredBackBufferHeight = 25 * grid.cell.Height
     };
     Content.RootDirectory = "Content";
 }
Exemplo n.º 27
0
 public void AddToSubBlocks()
 {
     foreach (SubBlock subBlock in subBlockArray)
     {
         if (TetrisGrid.IsInBounds(subBlock.x, subBlock.y, grid))
         {
             grid.gridArr[subBlock.x, subBlock.y] = subBlock;
         }
     }
 }
Exemplo n.º 28
0
 public VSSideBar(GameWorld parent, TetrisGrid MyGrid, TetrisGrid EnemyGrid) : base(parent, MyGrid)
 {
     this.EnemyGrid                = EnemyGrid;
     DotExample                    = new Dot(MyGrid);
     DotExample.BlockPosition      = new Vector2(14, 15);
     BadBlockExample               = new FullOpiece(MyGrid);
     BadBlockExample.BlockPosition = new Vector2(13, 9);
     BombExample                   = new Bomb(MyGrid);
     BombExample.BlockPosition     = new Vector2(14, 19);
 }
Exemplo n.º 29
0
 public ZPiece(TetrisGrid parentGrid) : base(parentGrid)
 {
     color = 4;
     shape = new[, ]
     {
         { true, false, false },
         { true, true, false },
         { false, true, false }
     };
 }
Exemplo n.º 30
0
 public GameWorld()
 {
     random             = new Random();
     gameState          = GameState.Start;
     grid               = new TetrisGrid();
     font               = TetrisGame.ContentManager.Load <SpriteFont>("SpelFont");
     gameOver           = TetrisGame.ContentManager.Load <SoundEffect>("GameOver");
     grid               = new TetrisGrid();
     MediaPlayer.Volume = 0.1f;
 }
Exemplo n.º 31
0
 public Opiece(TetrisGrid parent) : base(parent)
 {
     color           = Color.Yellow;
     BlockPosition   = new Vector2(12, 0);
     BlockGrid       = new bool[4, 4];
     BlockGrid[1, 1] = true;
     BlockGrid[1, 2] = true;
     BlockGrid[2, 1] = true;
     BlockGrid[2, 2] = true;
 }
Exemplo n.º 32
0
        public IEnumerator Init()
        {
            TetrisGrid grid = new TetrisGrid(WIDTH, HEIGHT);

            m_GridView.SetSize(grid);

            mTetrisGrid = grid;

            yield return(null);
        }
Exemplo n.º 33
0
 public TwoLines(TetrisGrid parent) : base(parent)
 {
     color           = Color.DimGray;
     BlockGrid[0, 0] = true;
     BlockGrid[1, 0] = true;
     BlockGrid[2, 0] = true;
     BlockGrid[0, 2] = true;
     BlockGrid[1, 2] = true;
     BlockGrid[2, 2] = true;
 }
Exemplo n.º 34
0
    public GameWorld(int width, int height, ContentManager Content)
    {
        screenWidth = width;
        screenHeight = height;
        random = new Random();
        gameState = GameState.Playing;

        block = Content.Load<Texture2D>("block");
        font = Content.Load<SpriteFont>("SpelFont");
        grid = new TetrisGrid(block);
    }
Exemplo n.º 35
0
 ////복사생성자
 public TetrisGrid(TetrisGrid T)
 {
     this.gridHeight = T.gridHeight;
     this.gridLength = T.gridLength;
     //배열 복사할때는 Clone() 사용
     this.grid = (int[,])T.grid.Clone();
     this._blockType = T._blockType;
     this._pivotX = T._pivotX;
     this._pivotY = T._pivotY;
     this._blockTurnState = T._blockTurnState;
     this._color = T._color;
     this._validCheck = T._validCheck;
 }
	public void Init( TetrisBlockCreator c, TetrisGrid g, int set_w )
	{
		Grid = g;
		creator = c;
		X = g.GetStartX();
		Y = g.GetStartY();
		W = set_w;

		if ( g.countX < X + W )
		{
			X -= W;
		}

		Update();
	}
Exemplo n.º 37
0
    void Start()
    {
        // Initialize UI
        textUI.text = "Score : 0";

        // Initialize Parameters
        _validCheck = true;
        _isPhaseStart = false;
        _isPhaseEnd = false;
        _isGameEnd = false;

        //[임시]levelGrid 아직 미구현
        levelGrid = new TetrisGrid(gridHeight, gridLength, blockType.Main, 0, 0, 0);
            levelGrid.grid = new int[20, 10] {
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};

        //levelGrid에서 받은 정보 적용, gridHeight 와 gridLength 설정
        mainGrid = levelGrid;
        this.gridHeight = mainGrid.gridHeight;
        this.gridLength = mainGrid.gridLength;

        playerGrid = TetrisGrid.GenerateBlock(this.gridHeight, this.gridLength);

        //보드 초기화
        boardScript.BoardSetup();
    }
Exemplo n.º 38
0
    public GameWorld(int width, int height, ContentManager Content)
    {
        screenWidth = width;
        screenHeight = height;
        random = new Random();
        gameState = GameState.Playing;

        gridTexture = Content.Load<Texture2D>("gridBlock2");
        blockTexture = Content.Load<Texture2D>("block");
        blockEdgeTexture = Content.Load<Texture2D>("blockBackground");
        gridBorder = Content.Load<Texture2D>("Border");

        bufferBorder = Content.Load<Texture2D>("BufferBorder");
        background = Content.Load<Texture2D>("background");
        segoeui = Content.Load<SpriteFont>("segoeui");
        segoeuiLarge = Content.Load<SpriteFont>("segoeuiLarge");
        theme = Content.Load<Song>("themeSong");

        MediaPlayer.IsRepeating = true;
        MediaPlayer.Volume = 0.07f;
        MediaPlayer.Play(theme);
        blockPlaced = Content.Load<SoundEffect>("blockPlaced");
        blockPlaced2 = Content.Load<SoundEffect>("blockPlaceSound2");
        blockPlaced3 = Content.Load<SoundEffect>("blockPlaceSound3");
        blockPlaced4 = Content.Load<SoundEffect>("blockPlaceSound4");

        rowCleared = Content.Load<SoundEffect>("rowCleared");

        grid = new TetrisGrid(gridTexture, blockTexture, blockEdgeTexture, segoeui);

        //Timer for moving the blocks down one unit a second
        Timer aTimer = new System.Timers.Timer(500);
        aTimer.Elapsed += OnTimedEvent;
        aTimer.AutoReset = true;
        aTimer.Enabled = true;
    }
Exemplo n.º 39
0
    ////회전
    public void Turn(TetrisGrid mainGrid)
    {
        _validCheck = true;
        TetrisGrid temp = new TetrisGrid(this);

        //I 타입
        if (this._blockType == blockType.I)
        {

            //TurnState == 0
            if (this._blockTurnState == 0)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == 0 || mainGrid.grid[_pivotY, _pivotX - 1] != 0)
                {
                    MoveRight(null, out _validCheck);
                }
                else if (this._pivotX == (this.gridLength - 1) || mainGrid.grid[_pivotY, _pivotX + 1] != 0)
                {
                    MoveLeft(null, out _validCheck);
                    MoveLeft(null, out _validCheck);
                }
                else if (this._pivotX == (this.gridLength - 2) || mainGrid.grid[_pivotY, _pivotX + 2] != 0)
                {
                    MoveLeft(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 2, _pivotY);
                MoveBlock(_pivotX, _pivotY, _pivotX + 1, _pivotY);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX, _pivotY);
                MoveBlock(_pivotX, _pivotY + 2, _pivotX - 1, _pivotY);

                //정보 갱신
                this._pivotX += 1;
                this._blockTurnState = 1;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 1
            if (this._blockTurnState == 1)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == 0 || mainGrid.grid[_pivotY - 1, _pivotX] != 0)
                {
                    MoveDown(null, out _validCheck);
                }
                else if (this._pivotY == (this.gridHeight - 1) || mainGrid.grid[_pivotY + 1, _pivotX] != 0)
                {
                    MoveUp(null, out _validCheck);
                    MoveUp(null, out _validCheck);
                }
                else if (this._pivotY == (this.gridHeight - 2) || mainGrid.grid[_pivotY + 2, _pivotX] != 0)
                {
                    MoveUp(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX - 2, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX, _pivotY, _pivotX, _pivotY + 1);
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 2);

                //정보 갱신
                this._pivotY += 1;
                this._blockTurnState = 2;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 2
            if (this._blockTurnState == 2)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == (this.gridLength - 1) || mainGrid.grid[_pivotY, _pivotX + 1] != 0)
                {
                    MoveLeft(null, out _validCheck);
                }
                else if (this._pivotX == 0 || mainGrid.grid[_pivotY, _pivotX - 1] != 0)
                {
                    MoveRight(null, out _validCheck);
                    MoveRight(null, out _validCheck);
                }
                else if (this._pivotX == 1 || mainGrid.grid[_pivotY, _pivotX - 2] != 0)
                {
                    MoveRight(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX, _pivotY, _pivotX - 1, _pivotY);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 2, _pivotY);
                MoveBlock(_pivotX, _pivotY - 1, _pivotX, _pivotY);
                MoveBlock(_pivotX, _pivotY - 2, _pivotX + 1, _pivotY);

                //정보 갱신
                this._pivotX -= 1;
                this._blockTurnState = 3;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 3
            if (this._blockTurnState == 3)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == 0 || mainGrid.grid[_pivotY - 1, _pivotX] != 0)
                {
                    MoveDown(null, out _validCheck);
                    MoveDown(null, out _validCheck);
                }
                else if (this._pivotY == 1 || mainGrid.grid[_pivotY - 2, _pivotX] != 0)
                {
                    MoveDown(null, out _validCheck);
                }
                else if (this._pivotY == (this.gridHeight - 1) || mainGrid.grid[_pivotY + 1, _pivotX] != 0)
                {
                    MoveUp(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 2);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY);
                MoveBlock(_pivotX + 2, _pivotY, _pivotX, _pivotY + 1);

                //정보 갱신
                this._pivotY -= 1;
                this._blockTurnState = 0;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
        }
        //J 타입
        else if (this._blockType == blockType.J)
        {

            //TurnState == 0
            if (this._blockTurnState == 0)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == (mainGrid.gridLength - 1) || mainGrid.grid[_pivotY, _pivotX + 1] != 0)
                {
                    MoveLeft(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);
                MoveBlock(_pivotX - 1, _pivotY + 1, _pivotX - 1, _pivotY - 1);

                //정보 갱신
                this._blockTurnState = 1;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 1
            if (this._blockTurnState == 1)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == (mainGrid.gridHeight - 1) || mainGrid.grid[_pivotY + 1, _pivotX] != 0)
                {
                    MoveUp(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX - 1, _pivotY - 1, _pivotX + 1, _pivotY - 1);
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);

                //정보 갱신
                this._blockTurnState = 2;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 2
            if (this._blockTurnState == 2)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == 0 || mainGrid.grid[_pivotY, _pivotX - 1] != 0)
                {
                    MoveRight(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX + 1, _pivotY - 1, _pivotX + 1, _pivotY + 1);
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);

                //정보 갱신
                this._blockTurnState = 3;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 3
            if (this._blockTurnState == 3)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == 0 || mainGrid.grid[_pivotY - 1, _pivotX] != 0)
                {
                    MoveDown(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);
                MoveBlock(_pivotX + 1, _pivotY + 1, _pivotX - 1, _pivotY + 1);

                //정보 갱신
                this._blockTurnState = 0;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
        }
        //L 타입
        else if (this._blockType == blockType.L)
        {

            //TurnState == 0
            if (this._blockTurnState == 0)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == 0 || mainGrid.grid[_pivotY, _pivotX - 1] != 0 || mainGrid.grid[_pivotY + 1, _pivotX - 1] != 0)
                {
                    MoveRight(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);
                MoveBlock(_pivotX + 1, _pivotY + 1, _pivotX - 1, _pivotY + 1);

                //정보 갱신
                this._blockTurnState = 1;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 1
            if (this._blockTurnState == 1)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == 0 || mainGrid.grid[_pivotY - 1, _pivotX] != 0 || mainGrid.grid[_pivotY - 1, _pivotX - 1] != 0)
                {
                    MoveDown(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX - 1, _pivotY + 1, _pivotX - 1, _pivotY - 1);
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);

                //정보 갱신
                this._blockTurnState = 2;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 2
            if (this._blockTurnState == 2)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == (mainGrid.gridLength - 1) || mainGrid.grid[_pivotY, _pivotX + 1] != 0 || mainGrid.grid[_pivotY - 1, _pivotX + 1] != 0)
                {
                    MoveLeft(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);
                MoveBlock(_pivotX - 1, _pivotY - 1, _pivotX + 1, _pivotY - 1);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);

                //정보 갱신
                this._blockTurnState = 3;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 3
            if (this._blockTurnState == 3)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == (gridHeight - 1) || mainGrid.grid[_pivotY + 1, _pivotX] != 0 || mainGrid.grid[_pivotY + 1, _pivotX + 1] != 0)
                {
                    MoveUp(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);
                MoveBlock(_pivotX + 1, _pivotY - 1, _pivotX + 1, _pivotY + 1);

                //정보 갱신
                this._blockTurnState = 0;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
        }
        //S 타입
        else if (this._blockType == blockType.S)
        {

            //TurnState == 0
            if (this._blockTurnState == 0)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == 0 || mainGrid.grid[_pivotY - 1, _pivotX - 1] != 0)
                {
                    MoveDown(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;
                if (mainGrid.grid[_pivotY - 1, _pivotX - 1] != 0 || mainGrid.grid[_pivotY, _pivotX - 1] != 0)
                {
                    MoveRight(null, out _validCheck);
                }
                if (_validCheck == false)
                {
                    MoveUp(null, out _validCheck);
                    return;
                }

                //임시 회전
                MoveBlock(_pivotX - 1, _pivotY + 1, _pivotX - 1, _pivotY - 1);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);

                //정보 갱신
                this._blockTurnState = 1;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 1
            if (this._blockTurnState == 1)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == (mainGrid.gridLength - 1) || mainGrid.grid[_pivotY - 1, _pivotX] != 0)
                {
                    MoveLeft(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;
                if (mainGrid.grid[_pivotY - 1, _pivotX + 1] != 0)
                {
                    MoveLeft(null, out _validCheck);
                }
                if (_validCheck == false)
                {
                    MoveRight(null, out _validCheck);
                    return;
                }

                //임시 회전
                MoveBlock(_pivotX - 1, _pivotY - 1, _pivotX + 1, _pivotY - 1);
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);

                //정보 갱신
                this._blockTurnState = 2;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 2
            if (this._blockTurnState == 2)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == (mainGrid.gridHeight - 1) || mainGrid.grid[_pivotY + 1, _pivotX + 1] != 0)
                {
                    MoveUp(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;
                if (this.grid[_pivotY, _pivotX + 1] != 0 || this.grid[_pivotY + 1, _pivotX + 1] != 0)
                {
                    MoveLeft(null, out _validCheck);
                }
                if (_validCheck == false)
                {
                    MoveDown(null, out _validCheck);
                    return;
                }

                //임시 회전
                MoveBlock(_pivotX + 1, _pivotY - 1, _pivotX + 1, _pivotY + 1);
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);

                //정보 갱신
                this._blockTurnState = 3;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 3
            if (this._blockTurnState == 3)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == 0 || mainGrid.grid[_pivotY + 1, _pivotX - 1] != 0)
                {
                    MoveRight(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;
                if (this.grid[_pivotY + 1, _pivotX - 1] != 0)
                {
                    MoveRight(null, out _validCheck);
                }
                if (_validCheck == false)
                {
                    MoveLeft(null, out _validCheck);
                    return;
                }

                //임시 회전
                MoveBlock(_pivotX + 1, _pivotY + 1, _pivotX - 1, _pivotY + 1);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);

                //정보 갱신
                this._blockTurnState = 0;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
        }
        //Z 타입
        else if (this._blockType == blockType.Z)
        {

            //TurnState == 0
            if (this._blockTurnState == 0)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == 0 || mainGrid.grid[_pivotY - 1, _pivotX] != 0)
                {
                    MoveDown(null, out _validCheck);
                }
                else if (mainGrid.grid[_pivotY + 1, _pivotX - 1] != 0)
                {
                    MoveRight(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);
                MoveBlock(_pivotX + 1, _pivotY + 1, _pivotX - 1, _pivotY + 1);

                //정보 갱신
                this._blockTurnState = 1;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 1
            if (this._blockTurnState == 1)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == (mainGrid.gridLength - 1) || mainGrid.grid[_pivotY, _pivotX + 1] != 0)
                {
                    MoveLeft(null, out _validCheck);
                }
                else if (mainGrid.grid[_pivotY - 1, _pivotX - 1] != 0)
                {
                    MoveDown(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX - 1, _pivotY + 1, _pivotX - 1, _pivotY - 1);

                //정보 갱신
                this._blockTurnState = 2;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 2
            if (this._blockTurnState == 2)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == (mainGrid.gridHeight - 1) || mainGrid.grid[_pivotY + 1, _pivotX] != 0)
                {
                    MoveUp(null, out _validCheck);
                }
                else if (this.grid[_pivotY - 1, _pivotX + 1] != 0)
                {
                    MoveLeft(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);
                MoveBlock(_pivotX - 1, _pivotY - 1, _pivotX + 1, _pivotY - 1);

                //정보 갱신
                this._blockTurnState = 3;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 3
            if (this._blockTurnState == 3)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == 0 || mainGrid.grid[_pivotY, _pivotX - 1] != 0)
                {
                    MoveRight(null, out _validCheck);
                }
                else if (this.grid[_pivotY + 1, _pivotX + 1] != 0)
                {
                    MoveUp(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);
                MoveBlock(_pivotX + 1, _pivotY - 1, _pivotX + 1, _pivotY + 1);

                //정보 갱신
                this._blockTurnState = 0;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
        }
        //T 타입
        else if (this._blockType == blockType.T)
        {

            //TurnState == 0
            if (this._blockTurnState == 0)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == (mainGrid.gridHeight - 1) || mainGrid.grid[_pivotY + 1, _pivotX] != 0)
                {
                    MoveUp(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);

                //정보 갱신
                this._blockTurnState = 1;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 1
            if (this._blockTurnState == 1)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == 0 || mainGrid.grid[_pivotY, _pivotX - 1] != 0)
                {
                    MoveRight(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);

                //정보 갱신
                this._blockTurnState = 2;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 2
            if (this._blockTurnState == 2)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotY == 0 || mainGrid.grid[_pivotY - 1, _pivotX] != 0)
                {
                    MoveDown(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);
                MoveBlock(_pivotX + 1, _pivotY, _pivotX, _pivotY + 1);

                //정보 갱신
                this._blockTurnState = 3;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
            //TurnState == 3
            if (this._blockTurnState == 3)
            {
                //배열 크기 확인, 공간 부족할시 임시 이동
                if (this._pivotX == (mainGrid.gridLength - 1) || mainGrid.grid[_pivotY, _pivotX + 1] != 0)
                {
                    MoveLeft(null, out _validCheck);
                }
                if (_validCheck == false)
                    return;

                //임시 회전
                MoveBlock(_pivotX, _pivotY - 1, _pivotX + 1, _pivotY);
                MoveBlock(_pivotX - 1, _pivotY, _pivotX, _pivotY - 1);
                MoveBlock(_pivotX, _pivotY + 1, _pivotX - 1, _pivotY);

                //정보 갱신
                this._blockTurnState = 0;

                //유효성 체크
                if (ValidCheck(mainGrid) == false)
                {
                    //[임시] false시 위로 한칸 올린다.
                    //MoveUp(mainGrid, out _validCheck);
                    //그래도 겹치면 원위치
                    //if (_validCheck == false)
                    //{
                    this._pivotX = temp._pivotX;
                    this._pivotY = temp._pivotY;
                    this.grid = temp.grid;
                    this._blockTurnState = temp._blockTurnState;
                    //}
                }
                return;
            }
        }
    }
Exemplo n.º 40
0
    ////유효성검사
    public bool ValidCheck(TetrisGrid mainGrid)
    {
        //행렬 사이즈가 다른 경우 FALSE 반환
        if (mainGrid.gridHeight != this.gridHeight || mainGrid.gridLength != this.gridLength)
        {
            Debug.Log("The grid size doesn't match");
            return false;
        }

        for (int y = 0; y < gridHeight; y++)
        {
            for (int x = 0; x < gridLength; x++)
            {
                //행렬에서 블록이 겹치는 경우(곱할경우 0이 아님)
                if (mainGrid.grid[y, x] * this.grid[y, x] != 0)
                {
                    return false;
                }
            }
        }

        //겹치는 블록이 없다면 TRUE 반환
        return true;
    }
Exemplo n.º 41
0
 ////합치기(적용)
 public void MergeGrid(TetrisGrid playerGrid)
 {
     //행렬 더하기
     for (int y = 0; y < gridHeight; y++)
     {
         for (int x = 0; x < gridLength; x++)
         {
             this.grid[y, x] += playerGrid.grid[y, x];
         }
     }
 }
Exemplo n.º 42
0
    ////바닥이동
    public void MoveButtom(TetrisGrid mainGrid)
    {
        bool valid = this.ValidCheck(mainGrid);

        while (valid == true)
        {
            this.MoveDown(mainGrid, out valid);
        }
    }
Exemplo n.º 43
0
    ////왼쪽이동
    public void MoveLeft(TetrisGrid mainGrid, out bool valid)
    {
        valid = true;

        //왼쪽 가장자리에 블록이 있다면 변화 없음
        for (int y = 0; y < gridHeight; y++)
        {
            if (this.grid[y, 0] != 0)
            {
                valid = false;
                return;
            }
        }

        //grid 임시 저장
        TetrisGrid temp = new TetrisGrid(this);

        //왼쪽 이동
        this._pivotX -= 1;

        for (int y = 0; y < gridHeight; y++)
        {
            for (int x = 0; x < (gridLength - 1); x++)
            {
                this.grid[y, x] = this.grid[y, x + 1];
            }
        }
        for (int y = 0; y < gridHeight; y++)
        {
            this.grid[y, gridLength - 1] = 0;
        }

        //mainGrid와 겹치면 복귀 또는 mainGrid가 비어있으면 그대로 반환
        if (mainGrid != null && ValidCheck(mainGrid) == false)
        {
            this.grid = temp.grid;
            this._pivotX = temp._pivotX;
            valid = false;
        }
    }
Exemplo n.º 44
0
    ////오른쪽이동
    public void MoveRight(TetrisGrid mainGrid, out bool valid)
    {
        valid = true;

        //오른쪽 가장자리에 블록이 있다면 변화 없음
        for (int y = 0; y < gridHeight; y++)
        {
            if (this.grid[y, gridLength - 1] != 0)
            {
                valid = false;
                return;
            }
        }

        //grid 임시 저장
        TetrisGrid temp = new TetrisGrid(this);

        //오른쪽 이동
        this._pivotX += 1;

        for (int y = 0; y < gridHeight; y++)
        {
            for (int x = (gridLength - 1); x > 0; x--)
            {
                this.grid[y, x] = this.grid[y, x - 1];
            }
        }
        for (int y = 0; y < gridHeight; y++)
        {
            this.grid[y, 0] = 0;
        }

        //mainGrid와 겹치면 복귀
        if (mainGrid != null && ValidCheck(mainGrid) == false)
        {
            this.grid = temp.grid;
            this._pivotX = temp._pivotX;
            valid = false;
        }
    }
Exemplo n.º 45
0
    // Update is called once per frame
    void Update()
    {
        // 게임 오버 처리
        if(_isGameEnd == true)
        {
            textUI.text = "GAME OVER";
            return;
        }

        // 페이즈 시작 처리
        if (_isPhaseStart == true)
        {
            playerGrid = TetrisGrid.GenerateBlock(this.gridHeight, this.gridLength);
            //게임오버 확인
            if (!playerGrid.ValidCheck(mainGrid))
            {
                _isGameEnd = true;
                return;
            }
            boardScript.BoardUpdate(mainGrid, playerGrid);
            _isPhaseStart = false;
            return;
        }

        // 페이즈 마무리 처리
        if (_isPhaseEnd == true)
        {
            _timeCounter = 0f;
            //합체
            mainGrid.MergeGrid(playerGrid);
            score += mainGrid.ShiftLine() * perLineScore;
            textUI.text = "Score : " + score.ToString();
            boardScript.BoardUpdate(mainGrid, null);
            _isPhaseEnd = false;
            _isPhaseStart = true;
            return;
        }

        //일정 시간 마다
        if (_timeCounter >= gameSpeed)
        {
            //카운터 초기화
            _timeCounter = 0f;

            //블록이 내려가고
            playerGrid.MoveDown(mainGrid, out _validCheck);

            //못 내려갈 경우
            if (_validCheck == false)
            {
                //다음 페이즈로 넘어간다.
                _isPhaseEnd = true;

                //다른 input무시
                return;
            }
        }
        //

        ////컨트롤 관련

        UpdateHoldingKey();

        if (Input.GetKey(KeyCode.DownArrow))
        {
            if (holdTime <= _DholdCounter)
            {
                playerGrid.MoveDown(mainGrid, out _validCheck);
                _DholdCounter = 0;
            }
            else
                _DholdCounter += Time.deltaTime;
            //내려갈시 카운터 초기화
            if (_validCheck == true)
                _timeCounter = 0f;
        }

        if (Input.GetKey(KeyCode.RightArrow) && (_isHolding == holdKey.Right))
        {
            if (holdTime <= _RLholdCounter)
            {
                playerGrid.MoveRight(mainGrid, out _validCheck);
                _RLholdCounter = 0f;
            }
            else
                _RLholdCounter += Time.deltaTime;
        }

        if (Input.GetKey(KeyCode.LeftArrow) && (_isHolding == holdKey.Left))
        {
            if (holdTime <= _RLholdCounter)
            {
                playerGrid.MoveLeft(mainGrid, out _validCheck);
                _RLholdCounter = 0f;
            }
            else
                _RLholdCounter += Time.deltaTime;
        }

        // 회전
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            playerGrid.Turn(mainGrid);
        }

        // 박기
        if (Input.GetKeyDown(KeyCode.Space))
        {
            playerGrid.MoveButtom(mainGrid);
            _isPhaseEnd = true;

            //다른 input무시
            return;
        }

        ////컨트롤 관련 End

        //변경사항 그래픽 적용
        boardScript.BoardUpdate(mainGrid, playerGrid);
        _timeCounter += Time.deltaTime;
    }
Exemplo n.º 46
0
    ////랜덤 블록 생성 ( 한계 : 사이즈가 W=10,T=20 로 제한 )
    public static TetrisGrid GenerateBlock(int gridHeight, int gridLength)
    {
        TetrisGrid T;

        UnityEngine.Random.seed = (int)System.Environment.TickCount;
        blockType randomBlockType = (blockType)UnityEngine.Random.Range((int)1, (int)blockType.NUM_TYPES);

        switch (randomBlockType)
        {
            // Need To Add Color Elements!
            case blockType.I:
                T = new TetrisGrid(gridHeight, gridLength, blockType.I, 4, 1, 0);
                T.grid = new int[20, 10] {
                    { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
                return T;
            case blockType.J:
                T = new TetrisGrid(gridHeight, gridLength, blockType.J, 4, 1, 0);
                T.grid = new int[20, 10] {
                    { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 2, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
                return T;
            case blockType.L:
                T = new TetrisGrid(gridHeight, gridLength, blockType.L, 4, 1, 0);
                T.grid = new int[20, 10] {
                    { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 2, 2, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
                return T;
            case blockType.S:
                T = new TetrisGrid(gridHeight, gridLength, blockType.S, 4, 0, 0);
                T.grid = new int[20, 10] {
                    { 0, 0, 0, 0, 2, 2, 0, 0, 0, 0 },
                    { 0, 0, 0, 2, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
                return T;
            case blockType.Z:
                T = new TetrisGrid(gridHeight, gridLength, blockType.Z, 4, 0, 0);
                T.grid = new int[20, 10] {
                    { 0, 0, 0, 2, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 2, 2, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
                return T;
            case blockType.T:
                T = new TetrisGrid(gridHeight, gridLength, blockType.T, 4, 1, 0);
                T.grid = new int[20, 10] {
                    { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 2, 2, 2, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
                return T;
            case blockType.O:
                T = new TetrisGrid(gridHeight, gridLength, blockType.O, 4, 0, 0);
                T.grid = new int[20, 10] {
                    { 0, 0, 0, 2, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 2, 2, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
                return T;
        }
        // Trash
        return null;
    }
Exemplo n.º 47
0
    ////위이동
    public void MoveUp(TetrisGrid mainGrid, out bool valid)
    {
        valid = true;

        //천장에 있는 경우 변경 없음 및 valid 거짓
        for (int x = 0; x < gridLength; x++)
        {
            if (this.grid[0, x] != 0)
            {
                valid = false;
                return;
            }
        }

        //grid 임시 저장
        TetrisGrid temp = new TetrisGrid(this);

        //위 이동 및 valid 참
        this._pivotY -= 1;

        for (int y = 1; y < gridHeight; y++)
        {
            for (int x = 0; x < gridLength; x++)
            {
                this.grid[y - 1, x] = this.grid[y, x];
            }
        }
        for (int x = 0; x < gridLength; x++)
        {
            this.grid[gridHeight - 1, x] = 0;
        }

        //mainGrid와 겹치면 복귀 및 valid 거짓
        if (mainGrid != null && ValidCheck(mainGrid) == false)
        {
            this.grid = temp.grid;
            this._pivotY = temp._pivotY;
            valid = false;
        }
    }