Start() public method

public Start ( ) : void
return void
Esempio n. 1
0
 public void TestMoveLeft()
 {
     StartCell = new Cell(0, 0);
     _engine.Start();
     _engine.MoveLeft();
     Assert.AreEqual("A1", _engine.CurrentPosition);
     Assert.AreEqual(1, _called);
 }
Esempio n. 2
0
        public void Start()
        {
            // first setup game engine parameters needed before warming up ,,,

            engine.SetContentRoot("Content");

            // ... then push starting state like engine/game splash ...

            TestState testState = new TestState("TestState");

            GameStateManager.PushGameState(testState);

            // ... warm up the engine ...

            engine.WarmUp();

            // ... then setup game engine parameters that are needed after warm up
            // but before complete start and also game parameters e.g when you need
            // GraphicsDevice for setting resolution but which is null in Core
            // constructor but only set on intialization by MonoGame ...

            engine.SetResolution(1366, 768, false);
            //engine.SetResolution(1920, 1080, true);

            // ... then start engine

            engine.Start();

            // nothing after this can be called because it's in a loop unless it exits (handed
            // off to states from here on out)
        }
Esempio n. 3
0
        public void RunEngineShouldInitializeTheMap()
        {
            GameEngine engine = new GameEngine(Options);

            engine.Start();
            Assert.IsTrue(engine.IsRunning);
        }
        public void WhenPlayerRolls4_ThenTokenShouldMove4Spaces(GameEngine gameEngine, Player player,
                                                                IDice dice, int diceRollResult, int positionBeforeMove)
        {
            "Given the player rolls a 4"
            .x(() =>
            {
                dice = A.Fake <IDice>();
                A.CallTo(() => dice.Roll()).Returns(4);
                player           = new Player(1, "Player 1", dice);
                int totalSquares = 100;
                gameEngine       = new GameEngine(totalSquares);
                gameEngine.AddPlayer(player);
                gameEngine.Start();
            });

            "When they move their token"
            .x(() =>
            {
                positionBeforeMove = gameEngine.CurrentSquareForPlayer(player);
                gameEngine.MovePlayer(player, player.RollDice());
            });
            "Then the token should move 4 space"
            .x(() =>
            {
                int positionAfterMove = gameEngine.CurrentSquareForPlayer(player);
                int result            = positionAfterMove - positionBeforeMove;
                result.Should().Be(4);
            });
        }
Esempio n. 5
0
        public void WhenTokenMovesToSquare100_ThenPlayerWinsGame(GameEngine gameEngine, Player player,
                                                                 IDice dice, int diceRollResult, int positionBeforeMove)
        {
            "Given the token is on square 97"
            .x(() =>
            {
                player           = new Player(1, "Player 1", dice);
                int totalSquares = 100;
                gameEngine       = new GameEngine(totalSquares);
                gameEngine.AddPlayer(player);
                gameEngine.Start();
                gameEngine.MovePlayer(player, 96);
            });

            "When the token is moved 3 spaces"
            .x(() =>
            {
                gameEngine.MovePlayer(player, 3);
            });

            "Then the token is on square 100"
            .x(() =>
            {
                gameEngine.CurrentSquareForPlayer(player).Should().Be(100);
            });

            "And the player has won the game"
            .x(() =>
            {
                gameEngine.Winner.Should().Be(player);
            });
        }
Esempio n. 6
0
        public void WhenTokenMoves4StepsFrom97_ThenTokenIsOn97(GameEngine gameEngine, Player player,
                                                               IDice dice, int diceRollResult, int positionBeforeMove)
        {
            "Given the token is on square 97"
            .x(() =>
            {
                player           = new Player(1, "Player 1", dice);
                int totalSquares = 100;
                gameEngine       = new GameEngine(totalSquares);
                gameEngine.AddPlayer(player);
                gameEngine.Start();
                gameEngine.MovePlayer(player, 96);
            });

            "When the token is moved 4 spaces"
            .x(() =>
            {
                gameEngine.MovePlayer(player, 4);
            });

            "Then the token is on square 97"
            .x(() =>
            {
                gameEngine.CurrentSquareForPlayer(player).Should().Be(97);
            });

            "And the player has not won the game"
            .x(() =>
            {
                gameEngine.Winner.Should().Be(null);
            });
        }
        public void AfterGameStart_WhenTokenMoves3And4Spaces_ThenTokenShouldBeOnSquare8(GameEngine gameEngine, Player player, IDice dice)
        {
            "Given the token is on square 1"
            .x(() =>
            {
                player           = new Player(1, "Player 1", dice);
                int totalSquares = 100;
                gameEngine       = new GameEngine(totalSquares);
                gameEngine.AddPlayer(player);
                gameEngine.Start();
            });

            "When the token is moved 3 spaces"
            .x(() =>
            {
                int spaces = 3;
                gameEngine.MovePlayer(player, spaces);
            });

            "And then it is moved 4 spaces"
            .x(() =>
            {
                int spaces = 4;
                gameEngine.MovePlayer(player, spaces);
            });

            "Then the token is on square 8"
            .x(() =>
            {
                gameEngine.CurrentSquareForPlayer(player).Should().Be(8);
            });
        }
Esempio n. 8
0
        private void InitEngine()
        {
            _gameEngine = new GameEngine(ReDraw, ShowAlert);
            var engineStart = new Task(() => { _gameEngine.Start(); });

            engineStart.Start();
        }
Esempio n. 9
0
        public static void Main(string[] args)
        {
            GameEngine gameEngine = new GameEngine();

            Face playerOne = GetFace("ertugrulungor");
            Face playerTwo = GetFace("onuar");

            var firstPlayer = gameEngine.Start(playerOne, playerTwo);

            Card pickedCard;

            if (playerOne.PlayerType == firstPlayer)
            {
                pickedCard = gameEngine.PickCard(playerOne);
            }
            else
            {
                pickedCard = gameEngine.PickCard(playerTwo);
            }
            var selectedPlayer = playerOne.PlayerType == firstPlayer ? playerOne : playerTwo;

            var mana = gameEngine.PlayToBattleGround(selectedPlayer, pickedCard);

            gameEngine.NextTurn();
        }
        public void PlayerRollsDie_ShouldBeInRangeOf1And6(GameEngine gameEngine, Player player, IDice dice, int diceRollResult)
        {
            "Given the game is started"
            .x(() =>
            {
                dice             = new Dice();
                player           = new Player(1, "Player 1", dice);
                int totalSquares = 100;
                gameEngine       = new GameEngine(totalSquares);
                gameEngine.AddPlayer(player);
                gameEngine.Start();
            });

            "When the player rolls a die"
            .x(() =>
            {
                diceRollResult = player.RollDice();
            });

            "Then the result should be between 1-6 inclusive"
            .x(() =>
            {
                diceRollResult.Should().BeInRange(1, 6);
            });
        }
Esempio n. 11
0
 private void StartEngine()
 {
     Logger.Write.BotStart("Bot now running");
     EventPublisher.InformUser("Program running.");
     StartPauseHeader = "P_ause";
     GameEngine.Start();
 }
Esempio n. 12
0
        static void Main(string[] args)
        {
            var map    = Map.ReadFromFile("map.txt");
            var engine = new GameEngine(map);

            engine.Start();
        }
Esempio n. 13
0
 private void StartEngine()
 {
     Log.Write("Bot now running");
     AppServices.InformUser("Program running.");
     StartPauseHeader = "P_ause";
     GameEngine.Start();
 }
Esempio n. 14
0
 public void Start()
 {
     _game.Start();
     BalanceBots();
     _game.NewRound();
     _botController.Start();
     _worldBroadcastThread.Start();
     _broadcastCounterThread.Start();
 }
Esempio n. 15
0
        public void CreateEngineWork()
        {
            var    engine   = new GameEngine(6);
            string expected = "1 16 17 18 19 20 \r\n15 2 27 28 29 21 \r\n14 31 3 26 30 22 \r\n13 36 32 4 25 23 \r\n12 35 34 33 5 24 \r\n11 10 9 8 7 6 \r\n";

            engine.Start();

            Assert.AreEqual(expected, engine.BoardToString());
        }
        public void Should_be_able_to_start_a_game()
        {
            IRandomGenerator generator  = new RandomGenerator();
            IGameEngine      gameEngine = new GameEngine(generator);

            Assert.True(gameEngine.Start());

            Assert.True(gameEngine.Started);
        }
Esempio n. 17
0
 /// <summary>
 /// If the console is enabled, we load that aswell when the form is loaded
 /// </summary>
 private void TransportMayhemForm_Load(object sender, EventArgs e)
 {
     game.Start();
     InputHandler.Start(canvas);
     if (GlobalVars.CONSOLE)
     {
         TMConsole.Start(game);
     }
 }
Esempio n. 18
0
    static void Main()
    {
        FleckLog.Level = LogLevel.Error;

        var renderers = new ConcurrentDictionary<IWebSocketConnection, IRenderer>();

        var proxyRenderer = new ProxyRenderer();
            proxyRenderer.AddRenderer( new ConsoleRenderer());
        var allSockets = new List<IWebSocketConnection>();
        var server = new WebSocketServer("ws://localhost:8080/websession");
        server.Start(socket =>
        {
            socket.OnOpen = () =>
            {
                allSockets.Add(socket);
                renderers[socket] = new WebRenderer(socket);
                proxyRenderer.AddRenderer(renderers[socket]);

                if (allSockets.Count == 1)
                {
                    var size = new Size(10, 15);
                    var dto = new InitMessageDto(new SizeDto(size));
                    socket.Send(dto.ToJson());

                    var engine = new GameEngine(size, new ConsoleInputListener(), proxyRenderer);
                    engine.Start();
                }
                else
                {
                    var size = new Size(10, 15);
                    var dto = new InitMessageDto(new SizeDto(size));
                    socket.Send(dto.ToJson());
                }
            };
            socket.OnClose = () =>
            {
                allSockets.Remove(socket);
                proxyRenderer.RemoveRenderer(renderers[socket]);

                IRenderer toRemove;
                renderers.TryRemove(socket, out toRemove);
            };
            socket.OnMessage = message =>
            {
                //Console.WriteLine(message);
                //allSockets.ToList().ForEach(s => s.Send("Echo: " + message));
            };
        });

        while (true)
        {
            Thread.Sleep(1000);
        }

           // Console.ReadLine();
    }
Esempio n. 19
0
        public void GameEngine_initialise()
        {
            //Arrange
            var engine = new GameEngine(gameLogic);

            //Act
            engine.Start();

            //Assert
            Assert.IsInstanceOfType(engine, typeof(IGameEngine));
        }
Esempio n. 20
0
        private void StartEngine()
        {
            LogViewModel.Write("Bot now running");
            AppServices.InformUser("Program running.");
            var isStarted = GameEngine.Start();

            if (!isStarted)
            {
                return;
            }
            StartPauseHeader = "P_ause";
        }
Esempio n. 21
0
        public void ElapsedGameTimeShouldProgressAfterTick()
        {
            _gameEngine.GameTime.Elapsed.Should().Be(default(TimeSpan));
            _gameEngine.Start();

            _gameEngine.Tick();
            var afterOneTick = _gameEngine.GameTime.Elapsed;

            afterOneTick.Should().BeGreaterThan(TimeSpan.FromTicks(0));

            _gameEngine.Tick();
            _gameEngine.GameTime.Elapsed.Should().BeGreaterThan(afterOneTick);
        }
Esempio n. 22
0
        public static void Run()
        {
            var        ordinaryGame = new OrdinaryMazeGame();
            GameEngine engine       = new GameEngine(ordinaryGame);

            Console.WriteLine("Game's on");

            engine.Start();
            var magicMazeGame = new MagicMazeGame();

            Console.WriteLine("SWITCHING TO MAGIC MODE");
            engine.Switch(magicMazeGame);
        }
Esempio n. 23
0
        public void Form1_Load(object sender, EventArgs args)
        {
            i = 0;

            engine = new GameEngine(this);
            player = new SuperPlayer();
            engine.SetPlayer(player);

            engine.AddTickMethod(SpawnerTick, TickSchedule.BEFORE_LOGIC);
            engine.AddTickMethod(EngineEnder, TickSchedule.AFTER_RENDER);

            engine.Start();
        }
        public static void Main()
        {
            IGameDatabase gameDatabase = new GameDatabase();
            IInputReader reader = new ConsoleReader();
            IOutputWriter writer = new ConsoleWriter();

            var engine = new GameEngine(
                gameDatabase,
                reader,
                writer);

            engine.Start();
        }
        public static void Main()
        {
            IGameDatabase gameDatabase = new GameDatabase();
            IInputReader  reader       = new ConsoleReader();
            IOutputWriter writer       = new ConsoleWriter();

            var engine = new GameEngine(
                gameDatabase,
                reader,
                writer);

            engine.Start();
        }
Esempio n. 26
0
        public void EnsureEngineIsNotStartetTwice()
        {
            int called = 0;

            RandomMock.Setup(_ => _.CalculateStart(Options.MapX, Options.MapY))
            .Returns(() => {
                called++;
                return(StartCell);
            });
            GameEngine engine = new GameEngine(Options);

            engine.Start().Start();
            Assert.AreEqual(1, called);
        }
Esempio n. 27
0
        private static void TestStartGame()
        {
            var users = new List <ObjectId> {
                ObjectId.GenerateNewId(),
                ObjectId.GenerateNewId(),
                ObjectId.GenerateNewId()
            };

            var gameOptions = new GameOptions();

            gameOptions.AmountOfDice  = 4;
            gameOptions.AmountOfLives = 3;
            gameOptions.Stair         = true;

            game.Start(users);
        }
Esempio n. 28
0
        public IHttpActionResult Start([FromBody] GameDto g)
        {
            try
            {
                var userIds = g.Players.Select(userId => ObjectId.Parse(userId));

                if (userIds.Count() < 1)
                {
                    return(BadRequest());
                }

                return(Ok(game.Start(userIds, g.GameOptions)));
            }
            catch (NullReferenceException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public void TokenShouldBeOnSquare1(GameEngine gameEngine, Player player, IDice dice)
        {
            "Given the game is started"
            .x(() =>
            {
                player           = new Player(1, "Player 1", dice);
                int totalSquares = 100;
                gameEngine       = new GameEngine(totalSquares);
                gameEngine.AddPlayer(player);
                gameEngine.Start();
            });

            "When the token is placed on the board"
            .x(() => { });

            "Then the token is on square 1"
            .x(() =>
            {
                gameEngine.CurrentSquareForPlayer(player).Should().Be(1);
            });
        }
Esempio n. 30
0
        private void SetUpGame()
        {
            List <Module> modules = new List <Module>();

            if (checkBoxHeroes.Checked)
            {
                modules.Add(HeroesExports.Module);
            }

            if (checkBoxVillains.Checked)
            {
                modules.Add(VillainsExports.Module);
            }

            if (checkBoxTestExpansion.Checked)
            {
                modules.Add(TestExports.Module);
            }

            Game = new GameEngine(int.Parse(comboBoxPlayers.SelectedItem.ToString()), modules, this);
            Game.Start();
        }
Esempio n. 31
0
        private static void DisplayConsoleMenu()
        {
            Menu menu = new Menu(new IMenuInterface());

            menu.ShowMenu();
            switch (menu.Choosen)
            {
            case 0:
                Init(engine);
                engine.Start();
                break;

            case 1:
                DisplayHighscores();
                break;

            case 2: Console.SetCursorPosition(0, 32); Environment.Exit(0); break;

            default:
                break;
            }
        }
Esempio n. 32
0
 // Update is called once per frame
 void Update()
 {
     if (PlayerPrefs.GetInt("SaveFile") == 1)
     {
         texture.enabled = true;
         if (Input.GetMouseButtonDown(0) && texture.HitTest(Input.mousePosition))
         {
             Destroy(camera2);
             camera.SetActive(true);
             player.SetActive(true);
             game.Start();
             p.Start();
             game.loadGame();
             Application.LoadLevel("Village");
             //GameEngine.ge.loadGame();
         }
     }
     else
     {
         texture.enabled = false;
     }
 }
Esempio n. 33
0
 public static void Main()
 {
     GameEngine gameEngine = new GameEngine();
     gameEngine.Start();
 }