示例#1
0
        private void Update()
        {
            menu.Update();

            if (state == ApplicationState.Opening)
            {
                opening.Update();
            }
            else if (state == ApplicationState.Game)
            {
                UserInput.BuildTicCmd(cmds[0]);
                //demo.ReadCmd(cmds);
                game.Update(cmds);
            }

            renderer.Render(this);
        }
示例#2
0
        private UpdateResult Update()
        {
            if (!wiping)
            {
                menu.Update();

                if (nextState != currentState)
                {
                    if (nextState != ApplicationState.Opening)
                    {
                        opening.Reset();
                    }

                    if (nextState != ApplicationState.DemoPlayback)
                    {
                        demoPlayback = null;
                    }

                    currentState = nextState;
                }

                if (quit)
                {
                    return(UpdateResult.Completed);
                }

                if (needWipe)
                {
                    needWipe = false;
                    StartWipe();
                }
            }

            if (!wiping)
            {
                switch (currentState)
                {
                case ApplicationState.Opening:
                    if (opening.Update() == UpdateResult.NeedWipe)
                    {
                        StartWipe();
                    }
                    break;

                case ApplicationState.DemoPlayback:
                    var result = demoPlayback.Update();
                    if (result == UpdateResult.NeedWipe)
                    {
                        StartWipe();
                    }
                    else if (result == UpdateResult.Completed)
                    {
                        Quit("FPS: " + demoPlayback.Fps.ToString("0.0"));
                    }
                    break;

                case ApplicationState.Game:
                    userInput.BuildTicCmd(cmds[options.ConsolePlayer]);
                    if (sendPause)
                    {
                        sendPause = false;
                        cmds[options.ConsolePlayer].Buttons |= (byte)(TicCmdButtons.Special | TicCmdButtons.Pause);
                    }
                    if (game.Update(cmds) == UpdateResult.NeedWipe)
                    {
                        StartWipe();
                    }
                    break;

                default:
                    throw new Exception("Invalid application state!");
                }
            }

            if (wiping)
            {
                var result = wipe.Update();
                renderer.RenderWipe(this, wipe);
                if (result == UpdateResult.Completed)
                {
                    wiping = false;
                }
            }
            else
            {
                renderer.Render(this);
            }

            options.Sound.Update();

            CheckMouseState();

            return(UpdateResult.None);
        }