//UPDATE
        public void Update(GameTime gameTime, Vector2 screenScale, TouchCollection touchPanelState)
        {
            foreach (TouchLocation tl in touchPanelState)
            {
                //Restart
                if (m_restartButton.Collision((int)(tl.Position.X), (int)(tl.Position.Y), screenScale))
                {
                    if (tl.State == TouchLocationState.Pressed)
                    {
                        m_restartButton.Update(true);
                    }
                    else if (tl.State == TouchLocationState.Released)
                    {
                        Game1.MenuChanged = true;
                        Game1.MenuList    = menuList.InGameReset;
                        m_restartButton.Update(false);
                    }
                }

                //Exit
                if (m_exitButton.Collision((int)(tl.Position.X), (int)(tl.Position.Y), screenScale))
                {
                    if (tl.State == TouchLocationState.Pressed)
                    {
                        m_exitButton.Update(true);
                    }
                    else if (tl.State == TouchLocationState.Released)
                    {
                        Game1.MenuChanged = true;
                        Game1.MenuList    = menuList.MainMenu;
                        m_exitButton.Update(false);
                    }
                }
            }
        }
예제 #2
0
파일: BackTool.cs 프로젝트: zhaohuwei/ZHSan
        public void Update()
        {
            var architectureDetail = Session.MainGame.mainGameScreen.Plugins.ArchitectureDetailPlugin;
            var personDetail       = Session.MainGame.mainGameScreen.Plugins.PersonDetailPlugin;
            var treasureDetail     = Session.MainGame.mainGameScreen.Plugins.TreasureDetailPlugin;
            var factionTech        = Session.MainGame.mainGameScreen.Plugins.FactionTechniquesPlugin;
            var optionDialog       = Session.MainGame.mainGameScreen.Plugins.OptionDialogPlugin as OptionDialogPlugin.OptionDialogPlugin;
            var troopDetail        = Session.MainGame.mainGameScreen.Plugins.TroopDetailPlugin;
            var createTroop        = Session.MainGame.mainGameScreen.Plugins.CreateTroopPlugin as CreateTroopPlugin.CreateTroopPlugin;
            var transPort          = Session.MainGame.mainGameScreen.Plugins.TransportDialogPlugin as TransportDialogPlugin.TransportDialogPlugin;
            var frame         = Session.MainGame.mainGameScreen.Plugins.GameFramePlugin;
            var numberInputer = Session.MainGame.mainGameScreen.Plugins.NumberInputerPlugin;

            if (architectureDetail.IsShowing || personDetail.IsShowing || treasureDetail.IsShowing || troopDetail.IsShowing ||
                createTroop.IsShowing && createTroop.createTroop.IsDialog ||
                numberInputer.IsShowing ||
                transPort.transportDialog.IsShowing && !frame.IsShowing ||
                factionTech.IsShowing || optionDialog.OptionTitle != "系统选项" && optionDialog.IsShowing
                )
            {
                btBack.Visible = true;
            }
            else
            {
                btBack.Visible = false;
            }

            btBack.Update();
        }
예제 #3
0
        public override void Update()
        {
            if (!this.Updated)
            {
                //int num = this.DaysToGo % 10;
                //this.DaysToGoSecondDigitTextTexture = this.DaysToGoTextBuilder.CreateTextTexture(num.ToString());
                //this.DaysToGoFirstDigitTextTexture = this.DaysToGoTextBuilder.CreateTextTexture(((this.DaysToGo / 10) % 10).ToString());
                //this.DaysLeftTextTexture = this.DaysLeftTextBuilder.CreateTextTexture(this.DaysLeftString());
                this.Updated = true;
            }

            var pos = new Vector2(this.DaysToGoFirstDigitTextDisplayPosition.X - 5, this.DaysToGoFirstDigitTextDisplayPosition.Y - 15);

            btChangeDays.Position = pos;

            btChangeDays.Update();
        }
예제 #4
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();
        }
예제 #5
0
        public void Update(GameTime gameTime)
        {
            float seconds = Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds);

            elapsedTime += seconds;

            if (Mode == "Start")
            {
                if (pause)
                {
                    btPlay.Visible  = true;
                    btPause.Visible = false;
                }
                else
                {
                    btPlay.Visible  = false;
                    btPause.Visible = true;

                    if (page < maps.Length)
                    {
                        pageTime += seconds;

                        if (pageTime >= Session.globalVariablesBasic.ScenarioMapPerTime)
                        {
                            page++;
                            pageTime -= Session.globalVariablesBasic.ScenarioMapPerTime;
                        }
                    }
                }

                if (IsComplete)
                {
                    btLoad.Visible  = false;
                    btStart.Visible = true;
                }
                else
                {
                    btLoad.Visible  = true;
                    btStart.Visible = false;
                }

                btPre.Enable = btNext.Enable = true;

                if (page <= 1)
                {
                    btPre.Enable = false;
                }

                if (page >= maps.Length)
                {
                    btNext.Enable = false;
                }

                btPre.Update();

                btPlay.Update();

                btPause.Update();

                btNext.Update();

                btLoad.Update();

                btStart.Update();
            }
            else
            {
            }

            if (elapsedTime >= 0.2f)
            {
                if (IsLoading)
                {
                }
                else
                {
                    if (LoadScreenEvent == null)
                    {
                    }
                    else
                    {
                        IsLoading = true;

                        if (Session.MainGame.mainGameScreen != null)
                        {
                            Session.MainGame.mainGameScreen.mainMapLayer.StopThreads();

                            Session.MainGame.mainGameScreen.DisposeMapTileMemory(false, true);

                            Session.MainGame.mainGameScreen.Dispose();

                            Session.MainGame.mainGameScreen = null;

                            GameScenario.ProcessCommonData(CommonData.Current);
                        }

                        Session.Current.Clear();

                        CacheManager.Clear(CacheType.Live);

                        GC.Collect();

#if DEBUG
                        try
                        {
                            LoadScreenEvent.Invoke(null, null);
                        }
                        catch (Exception e)
                        {
                            throw new Exception("加載出錯:" + e);
                            //Program.PrintError(e);
                            //Environment.Exit(1);
                        }
                        ClearEvent();
                        IsComplete = true;
                        if (Mode == "Start")
                        {
                        }
                        else
                        {
                            Session.MainGame.loadingScreen = null;
                        }
#else
                        new Platforms.PlatformTask(() =>
                        {
                            try
                            {
                                LoadScreenEvent.Invoke(null, null);
                            }
                            catch (Exception e)
                            {
                                throw new Exception("加載出錯:" + e);
                                //Program.PrintError(e);
                                //Environment.Exit(1);
                            }

                            ClearEvent();
                            IsComplete = true;
                            if (Mode == "Start")
                            {
                            }
                            else
                            {
                                Session.MainGame.loadingScreen = null;
                            }
                        }).Start();
#endif
                    }
                }
            }
        }