public void インスタンス生成時にパラメータが適切にセットされるかのテスト()
        {
            var controlBlocks = new ControlBlocks(5, 10, IBlocks);

            Assert.AreEqual(5, controlBlocks.X);
            Assert.AreEqual(10, controlBlocks.Y);
        }
        public void 左移動テスト()
        {
            var controlBlocks = new ControlBlocks(20, 14, IBlocks);

            controlBlocks.MoveLeft();
            Assert.AreEqual(19, controlBlocks.X);
        }
        public void  移動テスト()
        {
            var controlBlocks = new ControlBlocks(4, 14, IBlocks);

            controlBlocks.MoveDown();
            Assert.AreEqual(13, controlBlocks.Y);
        }
    private ControlBlocks AdjustBlocksForSpinLoop(ControlBlocks controlBlocks)
    {
        for (var i = 0; i <= controlBlocks.Blocks.BlockList.Count; i++)
        {
            if (CollisionDetection.IsCollisionControlBlocksLeftSide(controlBlocks))
            {
                controlBlocks.MoveRight();
                continue;
            }

            if (CollisionDetection.IsCollisionControlBlocksRightSide(controlBlocks))
            {
                controlBlocks.MoveLeft();
                continue;
            }

            if (CollisionDetection.IsCollisionControlBlocksLower(controlBlocks))
            {
                controlBlocks.MoveUp();
                continue;
            }

            break;
        }

        return(controlBlocks);
    }
        public void 右移動テスト()
        {
            var controlBlocks = new ControlBlocks(4, 14, IBlocks);

            controlBlocks.MoveRight();
            Assert.AreEqual(5, controlBlocks.X);
        }
Beispiel #6
0
 private void ExecuteMoveService(IMoveControlBlocksService moveService)
 {
     if (ControlBlocks is null)
     {
         return;
     }
     ControlBlocks = BlockControllUseCase.Execute(moveService, PlayerId, ControlBlocks);
 }
        public void 右移動で壁に衝突するテスト()
        {
            var controlBlocks = new ControlBlocks(9, 10, IBlocks);

            controlBlocks = MoveRightService.Execute(controlBlocks);
            Assert.AreEqual(9, controlBlocks.X);
            Assert.AreEqual(10, controlBlocks.Y);
        }
    public ControlBlocks Execute(ControlBlocks controlBlocks)
    {
        var newControlBlocks = controlBlocks.Clone();

        newControlBlocks.LeftSpin();

        return(Adjuster.AdjustBlocksForSpin(controlBlocks, newControlBlocks));
    }
        public void 左移動で壁に衝突するテスト()
        {
            var controlBlocks = new ControlBlocks(0, 10, IBlocks);

            controlBlocks = MoveLeftService.Execute(controlBlocks);
            Assert.AreEqual(0, controlBlocks.X);
            Assert.AreEqual(10, controlBlocks.Y);
        }
        public void 右回転で設置ブロックに衝突するテスト()
        {
            var controlBlocks = new ControlBlocks(6, 0, IBlocks);

            controlBlocks = SpinRightService.Execute(controlBlocks);
            Assert.AreEqual(4, controlBlocks.X);
            Assert.AreEqual(0, controlBlocks.Y);
        }
        public void 左壁への衝突判定テスト()
        {
            var controlBlocks = new ControlBlocks(-2, 19, LBlocks);

            Assert.IsTrue(CollisionDetection.IsCollision(controlBlocks));

            controlBlocks = new ControlBlocks(0, 19, LBlocks);
            Assert.IsFalse(CollisionDetection.IsCollision(controlBlocks));
        }
        public void 回転時に両方向に衝突する際のテスト()
        {
            // 回転後の移動調整をしても衝突する場合、回転前のブロックが返る
            var controlBlocks = new ControlBlocks(8, 0, IBlocks);

            controlBlocks = SpinRightService.Execute(controlBlocks);
            Assert.AreEqual(8, controlBlocks.X);
            Assert.AreEqual(0, controlBlocks.Y);
        }
        public void 右回転でボードの一番下に衝突するテスト()
        {
            var controlBlocks = new ControlBlocks(5, 0, IBlocks);

            controlBlocks.RightSpin();
            controlBlocks = SpinRightService.Execute(controlBlocks);
            Assert.AreEqual(5, controlBlocks.X);
            Assert.AreEqual(2, controlBlocks.Y);
        }
        public void 左移動でブロックに衝突するテスト()
        {
            var controlBlocks = new ControlBlocks(1, 1, IBlocks);

            // ボードの0, 0座標にはブロックが存在するため、衝突判定が発生
            controlBlocks = MoveLeftService.Execute(controlBlocks);
            Assert.AreEqual(1, controlBlocks.X);
            Assert.AreEqual(1, controlBlocks.Y);
        }
Beispiel #15
0
    public void Initialize(int playerId)
    {
        PlayerId = playerId;
        InitializeUiUseCase.Execute(PlayerId);

        InitializeBlocksQueueService.Execute(QueueSize);
        ControlBlocks      = GetNextControlBlocksService.Execute(PlayerId);
        InputEventProvider = GetInputEventProvider();
    }
        public void 設置してあるブロックへの衝突判定テスト()
        {
            var controlBlocks = new ControlBlocks(7, 1, LBlocks);

            Assert.IsTrue(CollisionDetection.IsCollision(controlBlocks));

            controlBlocks = new ControlBlocks(2, 1, LBlocks);
            Assert.IsTrue(CollisionDetection.IsCollision(controlBlocks));

            controlBlocks = new ControlBlocks(1, 1, LBlocks);
            Assert.IsTrue(CollisionDetection.IsCollision(controlBlocks));
        }
        public void ボードの一番下への衝突判定テスト()
        {
            var controlBlocks = new ControlBlocks(4, -2, IBlocks);

            Assert.IsTrue(CollisionDetection.IsCollision(controlBlocks));

            controlBlocks = new ControlBlocks(4, 0, IBlocks);
            Assert.IsTrue(CollisionDetection.IsCollision(controlBlocks));

            controlBlocks = new ControlBlocks(4, 1, IBlocks);
            Assert.IsFalse(CollisionDetection.IsCollision(controlBlocks));
        }
    public bool Execute(ControlBlocks controlBlocks)
    {
        if (CollisionDetection.IsCollisionPutPosition(controlBlocks))
        {
            var adjustedControlBlocks = Adjuster.AdjustBlocksByPutBlocks(controlBlocks);
            var addBlocks             = Board.PutBlocks(adjustedControlBlocks);
            BoardPresenter.AddBlocks(addBlocks);
            return(true);
        }

        return(false);
    }
    public ControlBlocks Execute(ControlBlocks controlBlocks)
    {
        var newControlBlocks = controlBlocks.Clone();

        newControlBlocks.MoveRight();

        if (CollisionDetection.IsCollision(newControlBlocks))
        {
            ControlBlocksPresenter.PlayCollisionSound();
            return(controlBlocks);
        }
        return(newControlBlocks);
    }
        public void 右回転で壁に衝突するテスト()
        {
            var controlBlocks = new ControlBlocks(9, 10, IBlocks);

            controlBlocks = SpinRightService.Execute(controlBlocks);
            Assert.AreEqual(7, controlBlocks.X);
            Assert.AreEqual(10, controlBlocks.Y);

            var controlBlocks2 = new ControlBlocks(8, 10, IBlocks);

            controlBlocks2 = SpinRightService.Execute(controlBlocks2);
            Assert.AreEqual(7, controlBlocks2.X);
            Assert.AreEqual(10, controlBlocks2.Y);
        }
        public void 左回転で壁に衝突するテスト()
        {
            var controlBlocks = new ControlBlocks(0, 10, IBlocks);

            controlBlocks = SpinLeftService.Execute(controlBlocks);
            Assert.AreEqual(2, controlBlocks.X);
            Assert.AreEqual(10, controlBlocks.Y);

            var controlBlocks2 = new ControlBlocks(1, 10, IBlocks);

            controlBlocks2 = SpinLeftService.Execute(controlBlocks2);
            Assert.AreEqual(2, controlBlocks2.X);
            Assert.AreEqual(10, controlBlocks2.Y);
        }
    public ControlBlocks AdjustBlocksByPutBlocks(ControlBlocks controlBlocks)
    {
        for (var i = 0; i <= controlBlocks.Blocks.BlockList.Count; i++)
        {
            if (CollisionDetection.IsCollisionPutPosition(controlBlocks))
            {
                controlBlocks.MoveUp();
                continue;
            }

            break;
        }
        return(controlBlocks);
    }
Beispiel #23
0
        public void ControlBlocksの座標と保持しているブロックの座標からボードでの座標を持つブロックリストを生成するテスト()
        {
            var controlBlocks          = new ControlBlocks(5, 1, IBlocks);
            var boardPositionBlockList = controlBlocks.GetBoardPositionBlockList();

            Assert.AreEqual(5, boardPositionBlockList[0].X);
            Assert.AreEqual(3, boardPositionBlockList[0].Y);
            Assert.AreEqual(5, boardPositionBlockList[1].X);
            Assert.AreEqual(2, boardPositionBlockList[1].Y);
            Assert.AreEqual(5, boardPositionBlockList[2].X);
            Assert.AreEqual(1, boardPositionBlockList[2].Y);
            Assert.AreEqual(5, boardPositionBlockList[3].X);
            Assert.AreEqual(0, boardPositionBlockList[3].Y);
        }
Beispiel #24
0
        public void 左回転テストt()
        {
            var controlBlocks   = new ControlBlocks(5, 15, IBlocks);
            var IBlocksLeftSpin = IBlocks.LeftSpin();

            controlBlocks.LeftSpin();
            Assert.AreEqual(IBlocksLeftSpin, controlBlocks.Blocks);

            var controlBlocks2   = new ControlBlocks(5, 15, IBlocks);
            var IBlocksRightSpin = IBlocks.RightSpin();

            controlBlocks2.RightSpin();
            Assert.AreEqual(IBlocksRightSpin, controlBlocks2.Blocks);
        }
    public ControlBlocks AdjustBlocksForSpin(ControlBlocks currentControlBlocks, ControlBlocks newControlBlocks)
    {
        if ((CollisionDetection.IsCollisionControlBlocksLower(newControlBlocks) &&
             CollisionDetection.IsCollisionControlBlocksUpper(newControlBlocks)) ||
            (CollisionDetection.IsCollisionControlBlocksLeftSide(newControlBlocks) &&
             CollisionDetection.IsCollisionControlBlocksRightSide(newControlBlocks)))
        {
            ControlBlocksPresenter.PlayCollisionSound();
            return(currentControlBlocks);
        }

        ControlBlocksPresenter.PlaySpinSound();
        return(AdjustBlocksForSpinLoop(newControlBlocks));
    }
    public ControlBlocks Execute(int playerId)
    {
        var controlBlocks = new ControlBlocks(
            Board.GetInsertPositionX(playerId),
            Board.GetInsertPositionY(),
            BlocksQueue.Dequeue()
            );

        ControlBlocksPresenter.DrawControlBlocks(controlBlocks);

        BlocksQueuePresenter.DrawQueueBlocksDequeue(BlocksQueue.LastBlock);

        return(controlBlocks);
    }
Beispiel #27
0
    public List <BoardPutBlock> PutBlocks(ControlBlocks controlBlocks)
    {
        var addPutBlocks = new List <BoardPutBlock>();

        foreach (var block in controlBlocks.GetBoardPositionBlockList())
        {
            var newBoardPutBlock = new BoardPutBlock(NextBlockId, block);
            NextBlockId++;

            addPutBlocks.Add(newBoardPutBlock);
        }
        BoardPutBlocks.AddBoardPutBlocks(addPutBlocks);

        return(addPutBlocks);
    }
Beispiel #28
0
        public void ボードの高さを超えた位置にブロックが設置されたらゲームオーバー判定()
        {
            var board         = new Board(10, 10);
            var controlBlocks = new ControlBlocks(4, 1, IBlocks);

            board.PutBlocks(controlBlocks);
            Assert.IsFalse(board.IsGameOver());

            controlBlocks = new ControlBlocks(4, 5, IBlocks);
            board.PutBlocks(controlBlocks);
            Assert.IsFalse(board.IsGameOver());

            controlBlocks = new ControlBlocks(4, 9, IBlocks);
            board.PutBlocks(controlBlocks);
            Assert.IsTrue(board.IsGameOver());
        }
Beispiel #29
0
        public void クローンオブジェクト生成メソッドのテスト()
        {
            var controlBlocks  = new ControlBlocks(5, 10, IBlocks);
            var controlBlocks2 = controlBlocks.Clone();

            controlBlocks2.MoveDown();
            var controlBlocks3 = controlBlocks.Clone();

            controlBlocks3.MoveRight();

            Assert.AreEqual(5, controlBlocks.X);
            Assert.AreEqual(10, controlBlocks.Y);
            Assert.AreEqual(5, controlBlocks2.X);
            Assert.AreEqual(9, controlBlocks2.Y);
            Assert.AreEqual(6, controlBlocks3.X);
            Assert.AreEqual(10, controlBlocks3.Y);
        }
Beispiel #30
0
        public void ブロックをボードに設置するテスト()
        {
            var controlBlocks = new ControlBlocks(0, 1, LBlocks);


            var putBlocks = Board.PutBlocks(controlBlocks);


            Assert.AreEqual(1, putBlocks[0].Id);
            Assert.AreEqual(0, putBlocks[0].GetX());
            Assert.AreEqual(2, putBlocks[0].GetY());

            Assert.AreEqual(2, putBlocks[1].Id);
            Assert.AreEqual(0, putBlocks[1].GetX());
            Assert.AreEqual(1, putBlocks[1].GetY());

            Assert.AreEqual(3, putBlocks[2].Id);
            Assert.AreEqual(0, putBlocks[2].GetX());
            Assert.AreEqual(0, putBlocks[2].GetY());

            Assert.AreEqual(4, putBlocks[3].Id);
            Assert.AreEqual(1, putBlocks[3].GetX());
            Assert.AreEqual(0, putBlocks[3].GetY());
        }