Esempio n. 1
0
        /// <summary>
        /// 指定ブロック配置
        /// </summary>
        /// <param name="_attemptPut"></param>
        /// <returns></returns>
        public bool PutBlock(BlockStatus attemptPut)
        {
            if (!IsBlockPuttable(attemptPut))
            {   // 更新可能かチェック事前チェック
                return(false);
            }

            int   statIdx = calcIdx(attemptPut.Pos);
            short setType = attemptPut.Type;

            // (0,0)座標のブロック更新
            board[statIdx] = setType;

            // 相対座標分のブロック更新
            for (int i = 0; i < SharedConstant.RELATIVE_BLOCK_NUM; i++)
            {
                BlockSettingData settingData = SharedConstant.BLOCK_DATA[attemptPut.SettingDataIdx];
                GridPos          diffPos     = CalcRelativeRotatePos(settingData.RelativePos[i], settingData.RotatableNum, attemptPut.RotateNum);

                int expectedIdx = calcIdx(attemptPut.Pos.x + diffPos.x, attemptPut.Pos.y + diffPos.y);
                board[expectedIdx] = setType;
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 指定ブロック削除
        /// </summary>
        /// <param name="_stat"></param>
        public void DeleteBlock(BlockStatus stat)
        {
            int statIdx = calcIdx(stat.Pos);

            // (0,0)座標のブロック更新
            board[statIdx] = SharedConstant.BLOCK_TYPE_NULL;

            // 相対座標分のブロック更新
            for (int i = 0; i < SharedConstant.RELATIVE_BLOCK_NUM; i++)
            {
                BlockSettingData settingData = SharedConstant.BLOCK_DATA[stat.SettingDataIdx];
                GridPos          diffPos     = CalcRelativeRotatePos(settingData.RelativePos[i], settingData.RotatableNum, stat.RotateNum);

                int expectedIdx = calcIdx(stat.Pos.x + diffPos.x, stat.Pos.y + diffPos.y);
                board[expectedIdx] = SharedConstant.BLOCK_TYPE_NULL;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 指定ブロックが配置可能か
        /// </summary>
        /// <param name="_stat"></param>
        /// <returns></returns>
        public bool IsBlockPuttable(BlockStatus stat)
        {
            if (HasBlock(stat.Pos, board))
            {   // 何かしらブロック配置済み
                return(false);
            }

            for (int i = 0; i < SharedConstant.RELATIVE_BLOCK_NUM; i++)
            {
                BlockSettingData blockData = SharedConstant.BLOCK_DATA[stat.SettingDataIdx];
                GridPos          diffPos   = CalcRelativeRotatePos(blockData.RelativePos[i], blockData.RotatableNum, stat.RotateNum);

                // 回転後の座標に空き領域がなければそこにはブロックは置けない
                if (HasBlock(stat.Pos.x + diffPos.x, stat.Pos.y + diffPos.y, board))
                {
                    return(false);
                }
            }

            // 更新可能
            return(true);
        }