Exemplo n.º 1
0
        /// <summary>
        /// 現在操作中のブロックを1つしたへ落とします。
        /// </summary>
        public bool DownCurrentBlock()
        {
            this.DeleteBlock(this.CurrentBlobkStatus);
            BlockStatus s = this.CurrentBlobkStatus.Clone();

            s.Y++;

            if (this.PutBlock(s))
            {
                this.CurrentBlobkStatus = s;
            }
            else
            {
                this.PutBlock(this.CurrentBlobkStatus);

                this.DeleteLine();

                BlockStatus new_block = this.CreateNewBlock();
                new_block = this.CreateNewBlock();
                //BlockStatus new_block = this.CreateNewBlock();
                if (this.PutBlock(new_block))
                {
                    this.CurrentBlobkStatus = new_block;
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// ブロックを消去します。
 /// </summary>
 public bool DeleteBlock(BlockStatus s)
 {
     this.bord[s.X, s.Y] = BlockColors.None;
     for (int i = 0; i < 3; i++)
     {
         int dx = BlockDefine.Block[s.Type].Position[i].X;
         int dy = BlockDefine.Block[s.Type].Position[i].Y;
         int r  = s.Rotate % BlockDefine.Block[s.Type].Rotate;
         for (int j = 0; j < r; j++)
         {
             int nx = dx, ny = dy;
             dx = ny;
             dy = -nx;
         }
         this.bord[s.X + dx, s.Y + dy] = BlockColors.None;
     }
     return(true);
 }
Exemplo n.º 3
0
        //
        // ---- Private Methods ----
        //

        /// <summary>
        /// キーボードが押された時の処理
        /// </summary>
        private void continuousKeyboardEvents(Key key)
        {
            BlockStatus s = this.bord.CurrentBlobkStatus.Clone();

            switch (key)
            {
            case Key.Left:
                s.X--;
                break;

            case Key.Right:
                s.X++;
                break;

            case Key.Up:
                s.Rotate++;
                break;

            case Key.Down:
                s.Y++;
                break;

            default:
                break;
            }

            if (s.X != this.bord.CurrentBlobkStatus.X ||
                s.Y != this.bord.CurrentBlobkStatus.Y ||
                s.Rotate != this.bord.CurrentBlobkStatus.Rotate)
            {
                this.bord.DeleteBlock(this.bord.CurrentBlobkStatus);
                if (this.bord.PutBlock(s))
                {
                    this.bord.CurrentBlobkStatus = s;
                }
                else
                {
                    this.bord.PutBlock(this.bord.CurrentBlobkStatus);
                    this.keySignal.Stop();
                    this.keySignalUp.Stop();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// ブロックを1つ置きます
        /// </summary>
        public bool PutBlock(BlockStatus s, bool action = false)
        {
            if (this.bord[s.X, s.Y] != 0)
            {
                return(false);
            }

            if (action)
            {
                bord[s.X, s.Y] = (BlockColors)s.Type;
            }

            for (int i = 0; i < 3; i++)
            {
                int dx = BlockDefine.Block[s.Type].Position[i].X;
                int dy = BlockDefine.Block[s.Type].Position[i].Y;
                int r  = s.Rotate % BlockDefine.Block[s.Type].Rotate;
                for (int j = 0; j < r; j++)
                {
                    int nx = dx, ny = dy;
                    dx = ny;
                    dy = -nx;
                }
                if (this.bord[s.X + dx, s.Y + dy] != 0)
                {
                    return(false);
                }
                if (action)
                {
                    this.bord[s.X + dx, s.Y + dy] = (BlockColors)s.Type;
                }
            }

            if (!action)
            {
                this.PutBlock(s, true);
            }
            return(true);
        }