예제 #1
0
 private void LoadWorld(WorldModel world)
 {
     SaveManager.SaveName          = world.Title;
     GameplaySaving.LoadLegacySave = false;
     SceneManager.LoadScene("gameplay");
     EverythingHider.HideEverything();
 }
    // todo: replace with proper loading screen
    private IEnumerator HideWorldForABit()
    {
        EverythingHider.HideEverything();

        yield return(new WaitForEndOfFrame());

        EverythingHider.UnHideEverything();
    }
예제 #3
0
파일: MulTUNG.cs 프로젝트: pipe01/MulTUNG
        public override bool Execute(IEnumerable <string> arguments)
        {
            if (Network.IsServer)
            {
                NetworkServer.Instance.Stop();

                EverythingHider.HideEverything();
                SceneManager.LoadScene("main menu");
            }

            return(true);
        }
예제 #4
0
    public void Load()
    {
        if (SelectedSaveFile == null)
        {
            return;
        }

        SaveManager.SaveName          = SelectedSaveFile.FileName;
        GameplaySaving.LoadLegacySave = SelectedSaveFile.LegacySave;
        UnityEngine.SceneManagement.SceneManager.LoadScene("gameplay");

        EverythingHider.HideEverything();
    }
    private void Awake()
    {
        GameplayUIManager.UIState = UIState.MainMenu;
        Instance = this;

        MegaMeshManager.ClearReferences();
        BehaviorManager.ClearAllLists();

        ShowMainMenu();

        string CurrentVersion    = "0.2.0";
        string LastLoadedVersion = Settings.Get("LastLoadedVersion", CurrentVersion);

        if (LastLoadedVersion != CurrentVersion)
        {
            ES3.DeleteFile("settings.txt");
        }                                                                            // some settings are obsolete and must be reset

        EverythingHider.UnHideEverything();
    }
예제 #6
0
        public void Disconnect(bool force = false)
        {
            Network.IsClient = false;

            if (ModUtilities.IsOnMainMenu || (LastStatus != NetConnectionStatus.Connected && !force))
            {
                return;
            }

            if (Client?.ConnectionStatus == NetConnectionStatus.Connected)
            {
                Client.Disconnect("bye");
            }

            this.PlayerID = -2;
            PlayerManager.Reset();

            EnterEvent.Reset();
            IsInGameplay = false;

            EverythingHider.HideEverything();
            SceneManager.LoadScene("main menu");
        }
예제 #7
0
 public void QuitToMainMenu()
 {
     EverythingHider.HideEverything();
     Time.timeScale = 1; // so that the main menu runs
     UnityEngine.SceneManagement.SceneManager.LoadScene("main menu");
 }
예제 #8
0
        public void Connect(IPEndPoint endPoint)
        {
            DisconnectReason = null;

            NetPeerConfiguration config = new NetPeerConfiguration("MulTUNG");

            Client = new NetClient(config);
            Client.Start();

            var approval = Client.CreateMessage();

            approval.Write(MulTUNG.Version.ToString());
            approval.Write(Username);

            var conn = Client.Connect(endPoint, approval);

            ThreadPool.QueueUserWorkItem(o =>
            {
                var c       = o as NetConnection;
                int elapsed = 0;

                while (true)
                {
                    Thread.Sleep(50);
                    elapsed += 50;

                    if ((c.Status != NetConnectionStatus.Connected && elapsed >= Constants.WaitForConnection) || DisconnectReason != null)
                    {
                        Network.IsClient = false;

                        string status = MulTUNG.Status = "Couldn't connect to remote server." + (DisconnectReason != null ? " Check the console for more details." : "");

                        IGConsole.Error("Couldn't connect to remote server: " + DisconnectReason);

                        Thread.Sleep(3000);

                        MulTUNG.ShowMainMenuCanvases();
                        MulTUNG.ShowStatusWindow = false;
                        MulTUNG.Status           = "";

                        break;
                    }
                    else if (c.Status == NetConnectionStatus.Connected)
                    {
                        Network.IsClient = true;

                        MulTUNG.SynchronizationContext.Send(_ =>
                        {
                            SaveManager.SaveName = MulTUNG.ForbiddenSaveName;
                            World.DeleteSave();

                            SceneManager.LoadScene("gameplay");
                            EverythingHider.HideEverything();
                        }, null);

                        while (ModUtilities.IsOnMainMenu)
                        {
                            Thread.Sleep(500);
                        }

                        Thread.Sleep(1000);

                        IsInGameplay = true;
                        EnterEvent.Set();

                        InitWorld();

                        break;
                    }
                }
            }, conn);

            ThreadPool.QueueUserWorkItem(_ =>
            {
                NetIncomingMessage msg;

                while (Client.Status == NetPeerStatus.Running)
                {
                    msg = Client.WaitMessage(int.MaxValue);

                    if (msg == null)
                    {
                        continue;
                    }

                    switch (msg.MessageType)
                    {
                    case NetIncomingMessageType.Data:
                        var packet = PacketDeserializer.DeserializePacket(new MessagePacketReader(msg));

                        if (Network.ProcessPacket(packet, this.PlayerID))
                        {
                            PacketLog.LogReceive(packet);
                        }

                        break;

                    case NetIncomingMessageType.StatusChanged:
                        var status = (NetConnectionStatus)msg.ReadByte();
                        Log.WriteLine("Status: " + status);

                        if (status == NetConnectionStatus.Disconnected)
                        {
                            string reason = msg.ReadString();

                            if (!string.IsNullOrEmpty(reason))
                            {
                                DisconnectReason = reason;
                            }

                            Disconnect();
                        }

                        LastStatus = Client.ConnectionStatus;
                        break;
                    }

                    Client.Recycle(msg);
                }
            });
        }