Exemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            float seconds = Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds);

            if (isClosing)
            {
                menuTypeElapsed -= seconds;
                if (menuTypeElapsed <= 0)
                {
                    menuTypeElapsed = 0f;
                    MenuType        = MenuType.None;
                    isClosing       = false;
                }
            }
            else
            {
                menuTypeElapsed += seconds;
            }

            btPre.Visible = btNext.Visible = false;

            btPre1.Visible = btNext1.Visible = false;

            if (MenuType == MenuType.None)
            {
                textGameElapsed += seconds;

                if (textGameElapsed > 20f)
                {
                    textGameElapsed = 0f;
                }

                textLevel = Convert.ToInt32(textGameElapsed / 2f);

                btList.ForEach(bt => bt.Update());
            }
            else if (MenuType == MenuType.New)
            {
                btScenarioList.ForEach(bt => bt.Update());

                btPre.Position  = new Vector2(40, 340);
                btNext.Position = new Vector2(40 + 125, 340);
                btPre.Visible   = btNext.Visible = true;

                btPre1.Position  = new Vector2(740, 340 + 208);
                btNext1.Position = new Vector2(740 + 125, 340 + 208);
                btPre1.Visible   = btNext1.Visible = true;

                btScenarioSelectListPaged = GenericTools.GetPageList <ButtonTexture>(btScenarioSelectList, pageIndex.ToString(), 5, ref pageCount, ref page);

                for (int i = 0; i < btScenarioSelectListPaged.Count; i++)
                {
                    var btOne = btScenarioSelectListPaged[i];
                    btOne.Position = new Vector2(40, 80 + 55 * i);
                    btOne.Update();
                }

                btScenarioPlayersListPaged = GenericTools.GetPageList <ButtonTexture>(btScenarioPlayersList, pageIndex1.ToString(), 8, ref pageCount1, ref page1);

                for (int i = 0; i < btScenarioPlayersListPaged.Count; i++)
                {
                    var btOne = btScenarioPlayersListPaged[i];
                    btOne.Position = new Vector2(740, 80 + 55 * i);
                    btOne.Update();
                }

                if (CurrentScenario != null)
                {
                    CurrentScenario.Players = String.Join(",", btScenarioPlayersList.Where(bt => bt.Selected).Select(bt => bt.ID));
                }
            }
            else if (MenuType == MenuType.Save)
            {
                btSaveList.ForEach(bt => bt.Update());

                btPre.Position  = new Vector2(530, 355 + 268);
                btNext.Position = new Vector2(530 + 125, 355 + 268);
                btPre.Visible   = btNext.Visible = true;

                btScenarioSelectListPaged = GenericTools.GetPageList <ButtonTexture>(btScenarioSelectList, pageIndex.ToString(), 10, ref pageCount, ref page);

                for (int i = 0; i < btScenarioSelectListPaged.Count; i++)
                {
                    var btOne = btScenarioSelectListPaged[i];
                    btOne.Position = new Vector2(40, 45 + 53 * i);
                    btOne.Update();
                }
            }
            else if (MenuType == MenuType.Setting)
            {
                btSettingList.ForEach(bt =>
                {
                    if (!String.IsNullOrEmpty(bt.ID))
                    {
                        bt.Visible = false;
                    }
                });

                string[] buttons = null;

                if (CurrentSetting == "基本")
                {
                    buttons = new string[] { "简体中文", "传统中文" };

                    //cbAIHardList.ForEach(cb => cb.Update());

                    //tbBattleSpeed.Update(seconds);
                    //tbBattleSpeed.HandleInput(seconds);

                    tbGamerName.Update(seconds);
                    tbGamerName.HandleInput(seconds);

                    //Setting.Current.BattleSpeed = tbBattleSpeed.Text.NullToStringTrim();
                    Setting.Current.GamerName = tbGamerName.Text.NullToStringTrim();
                }
                else if (CurrentSetting == "环境")
                {
                    buttons = new string[] { "窗口模式", "全屏模式" };  //, "925*520", "1120*630", "1024*768" };

                    int musicVolume = 0;
                    int soundVolume = 0;
                    nstMusic.Update(Vector2.Zero, ref musicVolume);
                    nstSound.Update(Vector2.Zero, ref soundVolume);

                    if (nstMusic.NowNumber <= nstMusic.MinNumber)
                    {
                        nstMusic.leftTexture.Enable = false;
                    }
                    else
                    {
                        nstMusic.leftTexture.Enable = true;
                    }
                    if (nstMusic.NowNumber >= nstMusic.MaxNumber)
                    {
                        nstMusic.rightTexture.Enable = false;
                    }
                    else
                    {
                        nstMusic.rightTexture.Enable = true;
                    }

                    if (nstSound.NowNumber <= nstSound.MinNumber)
                    {
                        nstSound.leftTexture.Enable = false;
                    }
                    else
                    {
                        nstSound.leftTexture.Enable = true;
                    }
                    if (nstSound.NowNumber >= nstSound.MaxNumber)
                    {
                        nstSound.rightTexture.Enable = false;
                    }
                    else
                    {
                        nstSound.rightTexture.Enable = true;
                    }

                    if (Setting.Current.MusicVolume != (int)nstMusic.NowNumber)
                    {
                        Setting.Current.MusicVolume = (int)nstMusic.NowNumber;
                        Platform.Current.SetMusicVolume((int)Setting.Current.MusicVolume);
                    }
                    if (Setting.Current.SoundVolume != (int)nstSound.NowNumber)
                    {
                        Setting.Current.SoundVolume = (int)nstSound.NowNumber;
                        Platform.Current.PlayEffect(@"Content\Sound\Move");
                    }
                }
                else if (CurrentSetting == "人物")
                {
                    buttons = new string[] { };
                }
                else if (CurrentSetting == "参数")
                {
                    buttons = new string[] { };
                }
                else if (CurrentSetting == "电脑")
                {
                    buttons = new string[] { };
                }

                btSettingList.Where(bt => buttons.Contains(bt.ID)).NullToEmptyList().ForEach(bt =>
                {
                    bt.Visible = true;
                });

                btSettingList.ForEach(bt =>
                {
                    bt.Update();
                });

                lbSettingList.ForEach(lb =>
                {
                    lb.Update(null, true);
                    if (lb.MouseOver || lb.Text == CurrentSetting)
                    {
                        lb.Color = PlatformColor.DarkRed;
                    }
                    else
                    {
                        lb.Color = Color.Blue;
                    }
                });
            }
            else if (MenuType == MenuType.About)
            {
                btAboutList.ForEach(bt => bt.Update());
            }

            btPre.Enable  = pageIndex > 1;
            btNext.Enable = pageIndex < pageCount;
            btPre.Update();
            btNext.Update();

            btPre1.Enable  = pageIndex1 > 1;
            btNext1.Enable = pageIndex1 < pageCount1;
            btPre1.Update();
            btNext1.Update();
        }