Update() public method

public Update ( ) : void
return void
コード例 #1
0
        public void UpdateWithTopWithActiveAsFalseTest()
        {
            var lab = new Mock <ILabyrinthPlayField>();

            lab.Setup(l => l.CurrentCell.Row).Returns(2);
            lab.Setup(l => l.CurrentCell.Col).Returns(2);
            lab.Setup(l => l.LabyrinthSize).Returns(5);
            lab.Setup(l => l.Deactivate()).Verifiable();

            var gameConsole = new Mock <IGameConsole>();

            var resultTable = new Mock <IResultsTable>();

            resultTable.Setup(r => r.Table.IsTopResult(It.IsAny <int>())).Returns(false);
            resultTable.Setup(r => r.Active).Returns(false);
            resultTable.Setup(r => r.Activate()).Verifiable();

            var input = new Mock <IUserInput>();

            input.Setup(i => i.GetInput()).Returns(Command.Top);

            var       factory   = new Mock <IResultFactory>();
            GameLogic gameLogic = new GameLogic(lab.Object, gameConsole.Object, resultTable.Object, input.Object, factory.Object);

            gameLogic.Update();

            resultTable.Verify(r => r.Activate());
            lab.Verify(l => l.Deactivate());
        }
コード例 #2
0
        private static void MainThread()
        {
            Console.WriteLine($"Main thread started. Running at {Constants.TICKS_PER_SEC} ticks per second.");
            DateTime _nextLoop = DateTime.Now;

            while (isRunning)
            {
                while (_nextLoop < DateTime.Now)
                {
                    // If the time for the next loop is in the past,
                    // aka it's time to execute another tick
                    GameLogic.Update(); // Execute game logic
                    // Calculate at what point in time the next tick should be executed
                    _nextLoop = _nextLoop.AddMilliseconds(Constants.MS_PER_TICK);

                    if (_nextLoop > DateTime.Now)
                    {
                        // If the execution time for the next tick is in the future,
                        // aka the server is NOT running behind
                        // Let the thread sleep until it's needed again.
                        Thread.Sleep(_nextLoop - DateTime.Now);
                    }
                }
            }
        }
コード例 #3
0
ファイル: GameSceneController.cs プロジェクト: vcow/td
 private void Update()
 {
     if (_gameLogic != null && !_isPaused)
     {
         _gameLogic.Update(Time.deltaTime);
     }
 }
コード例 #4
0
    void Update()
    {
        if (gameLogic == null)
        {
            return;
        }

        // start the game for multiplayer game
        if (singlePlayer == false && playerNumber == 1 && DidOpponentConnect())
        {
            SendGameStartMessage();
            startMessageSent = true;
        }

        // updates the opponent
        if (singlePlayer)
        {
            UpdateAI();
        }
        else
        {
            UpdateServer();
        }

        if (gameLogic.hasStarted && !gameLogic.gameOver)
        {
            // update game if it has started
            gameLogic.Update();
        }
    }
コード例 #5
0
        public void Update(TgcD3dInput Input)
        {
            zombieRey.Update(Input);
            logica.Update(Input);

            if ((GameLogic.cantidadZombiesMuertos > 25) && (!GameModel.modoGod))
            {
                victoria();
            }
        }
コード例 #6
0
 public HttpResponseMessage UpdateGame([FromBody] GameDTO game)
 {
     if (logic.Update(game))
     {
         return(new HttpResponseMessage(HttpStatusCode.OK));
     }
     else
     {
         return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
     }
 }
コード例 #7
0
        public override void ProcessLogic(IGameModuleContext context)
        {
            if (gameLogic.GameOverJustification.IsGameOver)
            {
                var info = new GameOverInfo(playerName, gameLogic.ScoreStatus.Value, gameLogic.GameOverJustification.Reason);

                context.Exit(info);

                return;
            }

            gameLogic.Update();
            scoreTransitionUI.Update();
        }
コード例 #8
0
        public void Update(TgcD3dInput Input)
        {
            if (tiempo < 65.5f)
            {
                tiempo         = GameModel.time * 60;
                barra2.Scaling = new TGCVector2(tiempo, 1);
            }
            else
            {
                cambiarEstado(Input);
            }

            logica.Update(Input);
        }
コード例 #9
0
ファイル: Application.cs プロジェクト: rgracari/helio
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }


            // Before updating the game we are gonna do this
            // IEventManager::Get()->VTick(20);

            _gameLogic.Update(gameTime);

            base.Update(gameTime);
        }
コード例 #10
0
        private static void MainThread()
        {
            Console.WriteLine($"Main thread started. Running at {Constants.TICKS_PER_SEC} ticks per second");
            DateTime _nextLoop = DateTime.Now;

            while (isRunning)
            {
                while (_nextLoop < DateTime.Now)
                {
                    GameLogic.Update();
                    _nextLoop = _nextLoop.AddMilliseconds(Constants.MS_PER_TICK);

                    if (_nextLoop > DateTime.Now)
                    {
                        Thread.Sleep(_nextLoop - DateTime.Now);
                    }
                }
            }
        }
コード例 #11
0
ファイル: Game1.cs プロジェクト: erhowell/gamedevfinal
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            KeyboardState state           = Keyboard.GetState();
            GameMode      updatedGameMode = gameMode;

            if (updatedGameMode == GameMode.Menu)
            {
                updatedGameMode = gameMenu.Update();
            }
            if (updatedGameMode == GameMode.HighScores)
            {
                updatedGameMode = highscores.Update();
            }
            if (updatedGameMode == GameMode.CustomizeControls)
            {
                updatedGameMode = userControls.Update();
                //gameLogic.UpdateGameControls(userControls.getUserControls());
            }
            if (updatedGameMode == GameMode.Game)
            {
                if (gameMode != updatedGameMode)
                {
                    gameLogic.startNewGame();
                }
                gameLogic.Update(gameTime);
            }

            gameMode      = updatedGameMode;
            previousState = state;

            base.Update(gameTime);
        }
コード例 #12
0
    /// <summary>
    /// Synchronizes the game state with the server state (reconciliation).
    ///
    /// 1. Stores the current state
    /// 2. Goes back to the state returned to by the server
    /// 3. Fast forwards from the server state the current state applying the inputs
    /// 4. Replaces the current state with the now "up to date" server state
    ///
    /// </summary>
    /// <param name="serverState">Server state.</param>
    private void ProcessGetGameState(GameLogic serverState)
    {
        Debug.Log("Sync with the server.");

        GameLogic currentState = gameLogic;

        currentState.player1Connected = serverState.player1Connected;
        currentState.player2Connected = serverState.player2Connected;

        // fast forwarding by executing the inputs
        for (long tick = serverState.currentTick; tick <= currentState.currentTick; tick++)
        {
            List <PaddleMovementRequest> inputsPerTick = myPaddle.GetInputsForTick(tick);
            if (inputsPerTick != null)
            {
                foreach (PaddleMovementRequest input in inputsPerTick)
                {
                    if (input.playerNumber == 1)
                    {
                        serverState.paddle1 = input.paddle;
                    }
                    else
                    {
                        serverState.paddle2 = input.paddle;
                    }
                }
            }
            serverState.Update();
        }

        // updating the entities according to the server's update
        currentState.Copy(serverState);
        // updating paddles
        //myPaddle.UpdatePaddleModel (currentState);
        opponentPaddle.UpdatePaddleModel(currentState);
    }
コード例 #13
0
 public ActionResult PutGame([FromBody] GamePoco[] pocos)
 {
     _logic.Update(pocos);
     return(Ok());
 }
コード例 #14
0
 public override void Update()
 {
     logic.Update();
 }
コード例 #15
0
 private void onTickTimer(object _)
 {
     GameLogic.Update();
 }