Exemple #1
0
        protected override void UpdateObjects()
        {
            // Update inputs and camera.
            UpdateInput(UTimeDelta);
            UpdateCamera();
            // Manage game state.
            LblTest.Text = $"X:{Mouse.X} Y:{Mouse.Y}";
            LblTest.SetTranslate(new Vector3(Mouse.X + 16, Height - Mouse.Y, 0.0f));
            LblTest.Update();
            #region Network updating
            UpdateGameFromNetwork();
            #endregion
            #region Update game states
            // If a player should move
            // Move until
            SetWindowTitle(IsServer ? "Server" : "Client", TxtNetName?.Text ?? "N/A", State.ToString(), Board.CurrentPlayerTurn.ToString());
            switch (State)
            {
            case GameState.Menu:
                break;

            case GameState.Lobby:
                break;

            case GameState.LobbyRoll:
                break;

            case GameState.PlayerOptions:
                break;

            case GameState.Moving:
                bool isDone = Board.UpdatePositions(Board.CurrentPlayerTurn, (float)(1d / UpdatePeriod));
                if (isDone && Board.CurrentPlayerTurn == Board.CurrentPlayerID)
                {
                    MnuPlayerOptions.ShowAll();
                    BtnRollDice.HideAll();
                    Network.SendAsync(PacketHandler.Create(PacketType.MoveState,
                                                           Protocol.Game.EncodeMoveDone(Board.CurrentPlayerTurn)));
                    State = GameState.PlayerOptions;
                }
                break;

            default:
                break;
            }
            #endregion
            #region Update Matrices.
            // Update view matrices.
            ViewMatrix       = Camera.GetViewMatrix();
            StaticViewMatrix = Camera.GetStaticViewMatrix();
            ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(ToRadians(Camera.Zoom),
                                                                    (float)Width / Height,
                                                                    0.1f, 1000f);
            UIProjectionMatrix = Matrix4.CreateOrthographicOffCenter(
                ClientRectangle.X, ClientRectangle.Width,
                ClientRectangle.Y, ClientRectangle.Height,
                -1.0f, 1.0f);
            // Update projection matrices.
            foreach (var control in Controls.Values)
            {
                control.ProjectionMatrix = UIProjectionMatrix;
                control.Update();
            }
            // Update matrices.
            Skybox.UpdateModelMatrix();
            foreach (var model in Models.Values)
            {
                model.UpdateModelMatrix();
            }
            DiceTwo.UpdateModelMatrix();
            foreach (var player in Board.GetPlayers())
            {
                player.UpdateModelMatrix();
            }
            #endregion
        }