Start() public method

public Start ( ) : void
return void
コード例 #1
0
 public void TestMoveLeft()
 {
     StartCell = new Cell(0, 0);
     _engine.Start();
     _engine.MoveLeft();
     Assert.AreEqual("A1", _engine.CurrentPosition);
     Assert.AreEqual(1, _called);
 }
コード例 #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)
        }
コード例 #3
0
        public void RunEngineShouldInitializeTheMap()
        {
            GameEngine engine = new GameEngine(Options);

            engine.Start();
            Assert.IsTrue(engine.IsRunning);
        }
コード例 #4
0
        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);
            });
        }
コード例 #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);
            });
        }
コード例 #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);
            });
        }
コード例 #7
0
        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);
            });
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: MaximBudnik/BoulderDashGame
        private void InitEngine()
        {
            _gameEngine = new GameEngine(ReDraw, ShowAlert);
            var engineStart = new Task(() => { _gameEngine.Start(); });

            engineStart.Start();
        }
コード例 #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();
        }
コード例 #10
0
        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);
            });
        }
コード例 #11
0
ファイル: MasterViewModel.cs プロジェクト: Snoopyslr/EasyFarm
 private void StartEngine()
 {
     Logger.Write.BotStart("Bot now running");
     EventPublisher.InformUser("Program running.");
     StartPauseHeader = "P_ause";
     GameEngine.Start();
 }
コード例 #12
0
        static void Main(string[] args)
        {
            var map    = Map.ReadFromFile("map.txt");
            var engine = new GameEngine(map);

            engine.Start();
        }
コード例 #13
0
ファイル: MasterViewModel.cs プロジェクト: mbout4it/EasyFarm
 private void StartEngine()
 {
     Log.Write("Bot now running");
     AppServices.InformUser("Program running.");
     StartPauseHeader = "P_ause";
     GameEngine.Start();
 }
コード例 #14
0
 public void Start()
 {
     _game.Start();
     BalanceBots();
     _game.NewRound();
     _botController.Start();
     _worldBroadcastThread.Start();
     _broadcastCounterThread.Start();
 }
コード例 #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());
        }
コード例 #16
0
        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);
        }
コード例 #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);
     }
 }
コード例 #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();
    }
コード例 #19
0
ファイル: GameTests.cs プロジェクト: viorel8/BoardGame
        public void GameEngine_initialise()
        {
            //Arrange
            var engine = new GameEngine(gameLogic);

            //Act
            engine.Start();

            //Assert
            Assert.IsInstanceOfType(engine, typeof(IGameEngine));
        }
コード例 #20
0
ファイル: MasterViewModel.cs プロジェクト: sruon/EasyFarm
        private void StartEngine()
        {
            LogViewModel.Write("Bot now running");
            AppServices.InformUser("Program running.");
            var isStarted = GameEngine.Start();

            if (!isStarted)
            {
                return;
            }
            StartPauseHeader = "P_ause";
        }
コード例 #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);
        }
コード例 #22
0
ファイル: Test.cs プロジェクト: ppanchal97/Design-Patterns
        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);
        }
コード例 #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();
        }
コード例 #24
0
        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();
        }
コード例 #25
0
        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();
        }
コード例 #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);
        }
コード例 #27
0
ファイル: Program.cs プロジェクト: FrederikNygart/LiarsDice
        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);
        }
コード例 #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));
            }
        }
コード例 #29
0
        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);
            });
        }
コード例 #30
0
ファイル: Form1.cs プロジェクト: danmalear/Legendary
        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();
        }
コード例 #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;
            }
        }
コード例 #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;
     }
 }
コード例 #33
0
ファイル: ConsoleApp.cs プロジェクト: tockata/GuessTheWeight
 public static void Main()
 {
     GameEngine gameEngine = new GameEngine();
     gameEngine.Start();
 }