Example #1
0
        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);
                }

                if (ok)
                {
                    switch (Level)
                    {
                        case Level.Main:
                            switch (_option[SelItem])
                            {
                                case Option.NewGame:
                                    Transition(Level.NewGame, true);
                                    break;
                                case Option.ResumeGame:
                                    Transition(Level.ResumeGame, true);
                                    break;
                                case Option.EndGame:
                                    Transition(Level.EndGame, true);
                                    break;
                                case Option.Continue:
                                    break;
                                case Option.Options:
                                    Transition(Level.Options);
                                    break;
                                case Option.Quit:
                                    Transition(Level.Quit, true);
                                    break;
                            }
                            break;

                        case Level.Dead:
                            switch (_option[SelItem])
                            {
                                case Option.EndGame:
                                    Transition(Level.EndGame, true);
                                    break;
                                case Option.Quit:
                                    Transition(Level.Quit, true);
                                    break;
                            }
                            break;

                        case Level.Options:
                            switch (_option[SelItem])
                            {
                                case Option.Back:
                                    Transition(Level.Main);
                                    break;
                            }
                            break;
                    }
                }
            }
        }
Example #2
0
        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;
                    }
                }

                if (option[0] == Option.AwaitingConnection)
                    selItem = 1;

                bool ok = false;
                if (transFrame > 1.9f)
                {
                    if (gs.Buttons.A == ButtonState.Pressed &&
                        oldState[i].Buttons.A == ButtonState.Released)
                        ok = true;
                    if (gs.Buttons.Start == ButtonState.Pressed &&
                        oldState[i].Buttons.Start == ButtonState.Released)
                    {
                        if (menuMode == MenuMode.Main ||
                            menuMode == MenuMode.Dead)
                            ok = true;
                        else
                        {
                            Transition(Level.ResumeGame, true);
                        }
                    }

                    if (ok)
                    {
                        switch (level)
                        {
                            case Level.Main:
                                switch (option[selItem])
                                {
                                    case Option.NewGame:
                                        Transition(Level.NewGame, true);
                                        break;
                                    case Option.ResumeGame:
                                        Transition(Level.ResumeGame, true);
                                        break;
                                    case Option.EndGame:
                                        Transition(Level.EndGame, true);
                                        break;
                                    case Option.Continue:

                                        break;
                                    case Option.Multiplayer:
                                        Transition(Level.Multiplayer);
                                        break;
                                    case Option.Options:
                                        Transition(Level.Options);
                                        break;
                                    case Option.Quit:
                                        Transition(Level.Quit, true);
                                        break;
                                }
                                break;
                            case Level.Dead:
                                switch (option[selItem])
                                {
                                    case Option.EndGame:
                                        Transition(Level.EndGame, true);
                                        break;
                                    case Option.Quit:
                                        Transition(Level.Quit, true);
                                        break;
                                }
                                break;
                            case Level.Options:
                                switch (option[selItem])
                                {
                                    case Option.Back:
                                        Transition(Level.Main);
                                        Game1.store.Write(Store.STORE_SETTINGS);
                                        break;
                                    case Option.RumbleOn:
                                        Game1.settings.Rumble = false;
                                        break;
                                    case Option.RumbleOff:
                                        Game1.settings.Rumble = true;
                                        break;
                                }
                                break;
                            case Level.Multiplayer:
                                switch (option[selItem])
                                {
                                    case Option.Back:
                                        Transition(Level.Main);
                                        break;
                                    case Option.HostGame:
                                        Transition(Level.HostGame);
                                        break;
                                    case Option.JoinGame:
                                        Transition(Level.JoinGame);
                                        break;
                                }
                                break;
                            case Level.HostGame:
                                switch (option[selItem])
                                {
                                    case Option.Cancel:
                                        Transition(Level.Main);
                                        Game1.NetPlay.NetConnect.Disconnect();
                                        break;
                                }
                                break;
                            case Level.JoinGame:
                                switch (option[selItem])
                                {
                                    case Option.Cancel:
                                        Transition(Level.Main);
                                        Game1.NetPlay.NetConnect.Disconnect();
                                        break;
                                }
                                break;
                        }
                    }
                    else
                    {
                        switch (level)
                        {
                            case Level.JoinGame:
                                if (Game1.NetPlay.Joined)
                                    Transition(Level.NewArena);
                                break;
                            case Level.HostGame:
                                if (Game1.NetPlay.NetSession != null)
                                {
                                    if (Game1.NetPlay.NetSession.AllGamers.Count == 2)
                                        Transition(Level.NewArena);
                                }
                                break;
                        }
                    }
                }
                oldState[i] = gs;
            }
        }