Ejemplo n.º 1
0
        public void Should_HaveFlagInTheCenterOfGameField()
        {
            var testGame = new GameModel(300, 300, 0, 2);
            var testForm = new CaptureTheFlagMode(testGame);

            Assert.IsNotNull(testGame.Flag);
            Assert.AreEqual(testForm.ClientRectangle.Width / 2, testGame.Flag.X);
            Assert.AreEqual(testForm.ClientRectangle.Height / 2, testGame.Flag.Y);
        }
        private void StartCaptureTheFlagGame()
        {
            var captureTheFlagGame = new GameModel(selectedFormWidth, selectedFormHeight, ballsCount, playersCountSelection);

            captureTheFlagGame.SetGameTime(selectedGametime);
            var captureTheFlagModeForm = new CaptureTheFlagMode(captureTheFlagGame);

            captureTheFlagModeForm.ShowDialog();
        }
Ejemplo n.º 3
0
        public void Should_CreateFourDefaultPlayersWithCertainPosition()
        {
            var testGame = new GameModel(300, 300, 0, 4);
            var testForm = new CaptureTheFlagMode(testGame);

            Assert.AreEqual(4, testGame.Players.Count);

            CheckFourDefaultPlayersPositions(testGame, testForm);
        }
Ejemplo n.º 4
0
        public void Should_IncreasePlayerScoreIfFlagIsAtHomeZone()
        {
            var testGame = new GameModel(100, 100, 0, 2);
            var testForm = new CaptureTheFlagMode(testGame);
            var player   = testGame.Players.First();

            player.SetPosition(testGame.FieldWidth / 2, testGame.FieldHeight / 2);
            MovePlayerToHomeZone(player, testGame, testForm);

            Assert.AreNotEqual(0, player.Score);
        }
Ejemplo n.º 5
0
        public void Should_ChangePlayerSize()
        {
            var newSize  = new Random().Next(0, 100);
            var testGame = new GameModel(300, 300, 0, 2);
            var testForm = new CaptureTheFlagMode(testGame);
            var player   = testGame.Players.First();

            player.SetPlayerSize(newSize, newSize);

            Assert.AreEqual(newSize, player.Width);
            Assert.AreEqual(newSize, player.Height);
        }
Ejemplo n.º 6
0
        public void Should_ChangePlayerSpeedIfFlagIsCaptured()
        {
            var testGame   = new GameModel(300, 300, 0, 2);
            var testForm   = new CaptureTheFlagMode(testGame);
            var player     = testGame.Players.First();
            var startSpeed = player.Speed;

            player.SetPosition(testGame.Flag.X, testGame.Flag.Y);
            testGame.CheckFlagCapture();

            Assert.AreNotEqual(startSpeed, player.Speed);
        }
Ejemplo n.º 7
0
        public void Should_ChangePlayerSizeIfFlagIsCaptured()
        {
            var testGame = new GameModel(300, 300, 0, 2);
            var testForm = new CaptureTheFlagMode(testGame);
            var player   = testGame.Players.First();

            player.SetPosition(testGame.Flag.X, testGame.Flag.Y);
            testGame.CheckFlagCapture();

            Assert.AreNotEqual(player.Width, player.OriginalWidth);
            Assert.AreNotEqual(player.Height, player.OriginalHeight);
        }
Ejemplo n.º 8
0
        public void Should_CaptureTheFlag()
        {
            var testGame = new GameModel(300, 300, 0, 2);
            var testForm = new CaptureTheFlagMode(testGame);
            var player   = testGame.Players.First();

            player.SetPosition(testGame.Flag.X, testGame.Flag.Y);
            testGame.CheckFlagCapture();

            Assert.AreEqual(true, player.HasFlag);
            Assert.AreEqual(testGame.Flag.Owner, player);
        }
Ejemplo n.º 9
0
        public void Should_SetPlayerSpeedToNormalIfFlagIsAtHomeZone()
        {
            var testGame = new GameModel(100, 100, 0, 2);
            var testForm = new CaptureTheFlagMode(testGame);
            var player   = testGame.Players.First();

            player.SetPosition(testGame.FieldWidth / 2, testGame.FieldHeight / 2);
            testGame.CheckFlagCapture();
            var playerChangedSpeed = player.Speed;

            MovePlayerToHomeZone(player, testGame, testForm);

            Assert.AreNotEqual(player.Speed, playerChangedSpeed);
        }
Ejemplo n.º 10
0
        public void Should_SetOriginalPlayerSize()
        {
            var deltaInc = new Random().Next(0, 20);
            var deltaDec = new Random().Next(0, 20);
            var testGame = new GameModel(300, 300, 0, 2);
            var testForm = new CaptureTheFlagMode(testGame);
            var player   = testGame.Players.First();

            player.SetPlayerSize(deltaDec, deltaDec);
            player.SetPlayerSize(deltaInc, deltaInc);
            player.SetOriginalSize();

            Assert.AreEqual(player.OriginalWidth, player.Width);
            Assert.AreEqual(player.OriginalHeight, player.Height);
        }
Ejemplo n.º 11
0
        public void Should_PlayerGetBackToOriginalPositionIfHitByBallInMultiplayerGame()
        {
            var testGame = new GameModel(300, 300, 100, 2);
            var testForm = new CaptureTheFlagMode(testGame);
            var player   = testGame.Players.First();

            player.SetPosition(testGame.FieldWidth / 2, testGame.FieldHeight / 2);
            for (int i = 0; i < 1000; i++)
            {
                foreach (var ball in testGame.Balls)
                {
                    testGame.CaptureTheFlagModeBallsMoves(testForm);
                }
            }

            Assert.AreEqual(player.OriginalPosition.X, player.X);
            Assert.AreEqual(player.OriginalPosition.Y, player.Y);
        }