当前位置: 首页>>代码示例>>C#>>正文


C# Game1.Quit方法代码示例

本文整理汇总了C#中Game1.Quit方法的典型用法代码示例。如果您正苦于以下问题:C# Game1.Quit方法的具体用法?C# Game1.Quit怎么用?C# Game1.Quit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Game1的用法示例。


在下文中一共展示了Game1.Quit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

        public void Update(Game1 game)
        {
            _frame += Game1.FrameTime / 2f;
            if (_frame > 6.28f)
                _frame -= 6.28f;

            if (TransFrame < 2f)
            {
                var pFrame = TransFrame;
                TransFrame += Game1.FrameTime;

                if (TransType == Trans.Buttons)
                    TransFrame += Game1.FrameTime;

                if (pFrame < 1f && TransFrame >= 1f)
                {
                    _levelSel[(int)Level] = SelItem;
                    Level = TransGoal;
                    SelItem = _levelSel[(int)Level];

                    switch (Level)
                    {
                        case Level.NewGame:
                            game.NewGame();
                            break;
                        case Level.ResumeGame:
                            Game1.GameMode = GameModes.Playing;
                            break;
                        case Level.EndGame:
                            MenuMode = MenuMode.Main;
                            Level = Level.Main;
                            break;
                        case Level.Quit:
                            game.Quit();
                            break;
                    }
                }
            }

            for (var i = 0; i < _fog.Length; i++)
            {
                _fog[i].X -= Game1.FrameTime * (50f + (i % 20 + 2));
                _fog[i].Y += Game1.FrameTime * (i % 14 + 5);

                if (_fog[i].X < -150f)
                {
                    _fog[i].X = Game1.ScreenSize.X + Rand.GetRandomFloat(150f, 200f);
                    _fog[i].Y = Game1.ScreenSize.Y - Rand.GetRandomFloat(0f, 300f);
                }
            }

            for (var i = 0; i < _optionFrame.Length; i++)
            {
                if (SelItem == i)
                {
                    if (_optionFrame[i] < 1f)
                    {
                        _optionFrame[i] += Game1.FrameTime * 7f;
                        if (_optionFrame[i] > 1f)
                            _optionFrame[i] = 1f;
                    }
                }
                else
                {
                    if (_optionFrame[i] > 0f)
                    {
                        _optionFrame[i] -= Game1.FrameTime * 4f;
                        if (_optionFrame[i] < 0f)
                            _optionFrame[i] = 0f;
                    }
                }
            }

            PopulateOptions();

            if (_totalOptions > 0)
            {
                if (ControlInput.KeyUpPressed)
                {
                    SelItem = (SelItem + (_totalOptions - 1)) % _totalOptions;
                }
                else if (ControlInput.KeyDownPressed)
                {
                    SelItem = (SelItem + 1) % _totalOptions;
                }
            }

            var ok = false;
            if (TransFrame > 1.9f)
            {
                if (ControlInput.KeyAttackPressed)
                    ok = true;

                if (ControlInput.KeyStartPressed)
                {
                    if (MenuMode == MenuMode.Main || MenuMode == MenuMode.Dead)
                        ok = true;
                    else
                        Transition(Level.ResumeGame, true);
                }
//.........这里部分代码省略.........
开发者ID:PawelklosPL,项目名称:GameDevelopment,代码行数:101,代码来源:Menu.cs

示例2: Update

        public void Update(Game1 game)
        {
            frame += Game1.FrameTime / 2f;
            if (frame > 6.28f) frame -= 6.28f;

            if (transFrame < 2f)
            {
                float pFrame = transFrame;
                transFrame += Game1.FrameTime;
                if (transType == Trans.Buttons)
                    transFrame += Game1.FrameTime;
                if (pFrame < 1f && transFrame >= 1f)
                {
                    levelSel[(int)level] = selItem;
                    level = transGoal;
                    selItem = levelSel[(int)level];
                    switch (level)
                    {
                        case Level.NewGame:
                            game.NewGame();
                            break;
                        case Level.ResumeGame:
                            Game1.GameMode = Game1.GameModes.Playing;
                            break;
                        case Level.EndGame:
                            menuMode = MenuMode.Main;
                            level = Level.Main;
                            break;
                        case Level.Quit:
                            game.Quit();
                            break;
                        case Level.HostGame:
                            Game1.NetPlay.NetConnect.Host();
                            break;
                        case Level.JoinGame:
                            Game1.NetPlay.NetConnect.Find();
                            break;
                        case Level.NewArena:
                            game.NewGame(true);
                            Game1.NetPlay.NetConnect.NewGame();
                            break;
                    }
                }
            }

            for (int i = 0; i < fog.Length; i++)
            {
                fog[i].X -= Game1.FrameTime * (50f + (float)(i % 20 + 2));
                fog[i].Y += Game1.FrameTime * (float)(i % 14 + 5);
                if (fog[i].X < -150f)
                {
                    fog[i].X = Game1.ScreenSize.X +
                        Rand.GetRandomFloat(150f, 200f);
                    fog[i].Y = Game1.ScreenSize.Y -
                        Rand.GetRandomFloat(0f, 300f);
                }
            }

            for (int i = 0; i < optionFrame.Length; i++)
            {
                if (selItem == i)
                {
                    if (optionFrame[i] < 1f)
                    {
                        optionFrame[i] += Game1.FrameTime * 7f;
                        if (optionFrame[i] > 1f) optionFrame[i] = 1f;
                    }
                }
                else
                {
                    if (optionFrame[i] > 0f)
                    {
                        optionFrame[i] -= Game1.FrameTime * 4f;
                        if (optionFrame[i] < 0f) optionFrame[i] = 0f;
                    }
                }
            }

            PopulateOptions();

            for (int i = 0; i < 4; i++)
            {
                GamePadState gs = GamePad.GetState((PlayerIndex)i);

                if (totalOptions > 0)
                {
                    if ((gs.ThumbSticks.Left.Y > 0.3f &&
                        oldState[i].ThumbSticks.Left.Y <= 0.3f) ||
                        (gs.DPad.Up == ButtonState.Pressed &&
                        oldState[i].DPad.Up == ButtonState.Released))
                    {
                        selItem = (selItem + (totalOptions - 1)) % totalOptions;
                    }

                    if ((gs.ThumbSticks.Left.Y < -0.3f &&
                        oldState[i].ThumbSticks.Left.Y >= -0.3f) ||
                        (gs.DPad.Down == ButtonState.Pressed &&
                        oldState[i].DPad.Down == ButtonState.Released))
                    {
                        selItem = (selItem + 1) % totalOptions;
//.........这里部分代码省略.........
开发者ID:o3a,项目名称:ZombieSmashersXNA4,代码行数:101,代码来源:Menu.cs


注:本文中的Game1.Quit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。