Пример #1
0
 public override void update(GameTime time)
 {
     if (!didModeSelect)
     {
         return;
     }
     if (readyToLoad)
     {
         Multiplayer.lobby = false;
         NewSaveGame.Load(path);
         Game1.exitActiveMenu();
     }
     else if (Multiplayer.mode == Mode.Client && modeInit != null && modeInit.ThreadState != ThreadState.Running)
     {
         readyToLoad = true;
     }
 }
Пример #2
0
        public override void update(GameTime time)
        {
            if (pendingClient != null)
            {
                pendingClient.update();
                if (pendingClient.id != 255)
                {
                    readyToLoad = true;
                }
                else
                {
                    return;
                }
            }

            if (!didModeSelect || Multiplayer.problemStarting)
            {
                return;
            }
            if (readyToLoad)
            {
                if (pendingClient != null)
                {
                    Multiplayer.client = pendingClient;
                }
                Multiplayer.lobby = false;
                NewSaveGame.Load(path);
                Game1.exitActiveMenu();
            }
            else if (Multiplayer.mode == Mode.Client && modeInit != null && modeInit.ThreadState != ThreadState.Running)
            {
                readyToLoad = true;
            }
            else if (modeInit == null && Multiplayer.mode == Mode.Client)
            {
                if (showingFriends && friends != null)
                {
                    friends.update(time);
                }
                else if (showingLan)
                {
                    lan.update(time);
                }
            }
        }
Пример #3
0
        ////////////////////////////////////////
        public override void update(GameTime time)
        {
            base.update(time);
            if (this.timerToLoad > 0)
            {
                this.timerToLoad -= time.ElapsedGameTime.Milliseconds;
                if (this.timerToLoad <= 0)
                {
                    ////////////////////////////////////////
                    this.timerToLoad = 1;

                    pendingSelected = saveGames[selected];
                    if (didModeSelect)
                    {
                        if (modeInit == null)
                        {
                            if (portBox == null)
                            {
                                if (Multiplayer.mode == Mode.Client)
                                {
                                    ipBox        = new TextBox(Game1.content.Load <Texture2D>("LooseSprites\\textBox"), null, Game1.smallFont, Game1.textColor);
                                    ipBox.Width *= 3;
                                    ipBox.X      = buttonX + buttonW / 2 - (SpriteText.getWidthOfString("IP Address:") + ipBox.Width + 20) / 2 + SpriteText.getWidthOfString("IP Address:") + 20;
                                    ipBox.Y      = buttonY1 + buttonH / 2 - ipBox.Height / 2;
                                    ipBox.Text   = Multiplayer.ipStr;
                                }

                                portBox        = new TextBox(Game1.content.Load <Texture2D>("LooseSprites\\textBox"), null, Game1.smallFont, Game1.textColor);
                                portBox.Width *= 3;
                                portBox.X      = buttonX + buttonW / 2 - (SpriteText.getWidthOfString("IP Address:") + portBox.Width + 20) / 2 + SpriteText.getWidthOfString("IP Address:") + 20;
                                portBox.Y      = buttonY2 + buttonH / 2 - portBox.Height / 2;
                                portBox.Text   = Multiplayer.portStr;
                            }
                        }
                        else
                        {
                            if (Multiplayer.mode == Mode.Client && Multiplayer.client != null)
                            {
                                readyToLoad = true;
                            }
                        }
                    }

                    if (Multiplayer.problemStarting)
                    {
                        /*didModeSelect = false;
                         * this.loading = false;
                         * this.timerToLoad = 0;
                         * this.selected = -1;
                         * Util.SetInstanceField(typeof(TitleMenu), Game1.activeClickableMenu, "subMenu", new NewLoadMenu());
                         */
                        return;
                    }

                    if (!readyToLoad)
                    {
                        return;
                    }

                    if (!NewSaveGame.Load(this.saveGames[this.selected].favoriteThing))
                    {
                        didModeSelect    = false;
                        this.loading     = false;
                        this.timerToLoad = 0;
                        this.selected    = -1;
                        Util.SetInstanceField(typeof(TitleMenu), Game1.activeClickableMenu, "subMenu", new NewLoadMenu());
                        return;
                    }
                    Multiplayer.lobby = false;
                    this.timerToLoad  = 0;

                    ////////////////////////////////////////

                    for (int i = 0; i < this.saveGames.Count; i++)
                    {
                        if (i != this.selected)
                        {
                            this.saveGames[i].unload();
                        }
                    }

                    //if (Multiplayer.mode == Mode.Singleplayer) ////////////////////////////////////////
                    Game1.exitActiveMenu();
                }
            }
        }
Пример #4
0
        public override void update(GameTime time)
        {
            if (this.quit)
            {
                if (Game1.currentLoader.Current < 100)
                {
                    Game1.currentLoader.MoveNext();
                }
                else
                {
                    Game1.exitActiveMenu();
                }
                return;
            }

            ////////////////////////////////////////
            if (Multiplayer.mode == Mode.Client)
            {
                Log.info("Reloading world for next day");

                // Yes, it is necessary to do this again (previously done when the next day packet was sent before the fade)
                // This time newDayAfterFade has run, and so mail and stuff has changed
                var it = NewSaveGame.Save(true);
                while (it.Current < 100)
                {
                    it.MoveNext();
                    Thread.Sleep(5);
                }

                Multiplayer.client.processDelayedPackets();
                NewSaveGame.Load("MEOW", true);
                quit = true;
                return;
            }
            ////////////////////////////////////////

            if (!Game1.saveOnNewDay)
            {
                this.quit = true;
                if (Game1.activeClickableMenu.Equals(this))
                {
                    Game1.player.checkForLevelTenStatus();
                    Game1.exitActiveMenu();
                }
                return;
            }
            if (this.loader != null)
            {
                this.loader.MoveNext();
                if (this.loader.Current >= 100)
                {
                    this.margin -= time.ElapsedGameTime.Milliseconds;
                    if (this.margin <= 0)
                    {
                        Game1.playSound("money");
                        this.completePause   = 1500;
                        this.loader          = null;
                        Game1.game1.IsSaving = false;
                    }
                }
                this._ellipsisDelay -= (float)time.ElapsedGameTime.TotalSeconds;
                if (this._ellipsisDelay <= 0f)
                {
                    this._ellipsisDelay += 0.75f;
                    this._ellipsisCount++;
                    if (this._ellipsisCount > 3)
                    {
                        this._ellipsisCount = 1;
                    }
                }
            }
            else if (this.hasDrawn && this.completePause == -1)
            {
                ////////////////////////////////////////
                if (Multiplayer.mode == Mode.Host)
                {
                    foreach (Server.Client client in Multiplayer.server.clients)
                    {
                        // They should have sent their farmer data again.
                        // We can update their stuff before the new day.
                        client.processDelayedPackets();
                    }
                }
                ////////////////////////////////////////
                Game1.game1.IsSaving = true;
                this.loader          = NewSaveGame.Save(); // SaveGame -> NewSaveGame
            }
            if (this.completePause >= 0)
            {
                this.completePause -= time.ElapsedGameTime.Milliseconds;
                this.saveText.update(time);
                if (this.completePause < 0)
                {
                    this.quit          = true;
                    this.completePause = -9999;
                    if (Game1.activeClickableMenu.Equals(this))
                    {
                        Game1.player.checkForLevelTenStatus();
                        Game1.exitActiveMenu();
                    }
                    Game1.currentLocation.resetForPlayerEntry();
                }
            }
        }