Пример #1
0
        private void MainPage()
        {
            if (Global.Lobby.PlayersInLobbyCount > 0 && !NetworkLevelLoader.Instance.IsGameplayPaused)
            {
                if (!PhotonNetwork.isNonMasterClientInRoom)             // only host do these things
                {
                    if (PvP.Instance.CurrentGame == PvP.GameModes.NONE) // && !BattleRoyale.Instance.IsGameplayEnding)
                    {
                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button("Begin Deathmatch"))
                        {
                            PvP.Instance.StartGameplay((int)PvP.GameModes.Deathmatch, "A Deathmatch has begun!");
                        }
                        //if (GUILayout.Button("Begin Battle Royale"))
                        //{
                        //    ConfirmingBattleRoyale = true;
                        //}
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        if (GUILayout.Button("End Gameplay"))
                        {
                            PvP.Instance.StopGameplay("The host has ended the game.");
                        }
                    }

                    GUILayout.BeginHorizontal();
                    if (!PvP.Instance.FriendlyFireEnabled)
                    {
                        GUI.color = Color.red;
                        if (GUILayout.Button("Enable Friendly Fire"))
                        {
                            RPCManager.SendFriendyFire(true);
                        }
                    }
                    else
                    {
                        GUI.color = Color.green;
                        if (GUILayout.Button("Disable Friendly Fire"))
                        {
                            RPCManager.SendFriendyFire(false);
                        }
                        if (!PvP.Instance.FriendlyTargetingEnabled)
                        {
                            GUI.color = Color.red;
                            if (GUILayout.Button("Enable Friendly Targeting"))
                            {
                                RPCManager.SendFriendyTargeting(true);
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Disable Friendly Targeting"))
                            {
                                RPCManager.SendFriendyTargeting(false);
                            }
                        }
                    }
                    if (!PvP.Instance.EnemiesDisabled)
                    {
                        GUI.color = Color.green;
                        if (GUILayout.Button("Disable Enemies"))
                        {
                            RPCManager.SendSetEnemiesActive(false);
                        }
                    }
                    else
                    {
                        GUI.color = Color.red;
                        if (GUILayout.Button("Enable Enemies"))
                        {
                            RPCManager.SendSetEnemiesActive(true);
                        }
                    }
                    GUILayout.EndHorizontal();
                    GUI.color = Color.white;
                }
                // end host-only block

                GUILayout.Label("Characters: ");

                foreach (PlayerSystem ps in Global.Lobby.PlayersInLobby)
                {
                    if (!ps.ControlledCharacter.Initialized)
                    {
                        continue;
                    }

                    GUILayout.BeginHorizontal(GUI.skin.box);
                    GUI.skin.label.wordWrap = false;
                    GUI.color = TeamColors[ps.ControlledCharacter.Faction];

                    string label = ps.ControlledCharacter.Name;
                    if (ps.ControlledCharacter.IsWorldHost)
                    {
                        label += " [Host]";
                    }
                    else if (ps.ControlledCharacter.IsLocalPlayer)
                    {
                        label += " [Local]";
                    }
                    else
                    {
                        label += " [Online]";
                    }
                    GUILayout.Label(label, GUILayout.Width(130));

                    GUILayout.Label("Team: ", GUILayout.Width(40));

                    if (!PhotonNetwork.isNonMasterClientInRoom || ps.ControlledCharacter.IsLocalPlayer)
                    {
                        if (ps.ControlledCharacter.Faction != Character.Factions.NONE && PvP.Instance.CurrentGame == PvP.GameModes.NONE)
                        {
                            if (GUILayout.Button("<", GUILayout.Width(30)))
                            {
                                var newFaction = (Character.Factions)((int)ps.ControlledCharacter.Faction - 1);
                                PlayerManager.Instance.ChangeFactions(ps.ControlledCharacter, newFaction);
                            }
                        }
                        else
                        {
                            GUILayout.Space(35);
                        }
                    }

                    GUILayout.Label(ps.ControlledCharacter.Faction.ToString(), GUILayout.Width(80));

                    if (!PhotonNetwork.isNonMasterClientInRoom || ps.ControlledCharacter.IsLocalPlayer)
                    {
                        if (ps.ControlledCharacter.Faction != Character.Factions.Golden && PvP.Instance.CurrentGame == PvP.GameModes.NONE)
                        {
                            if (GUILayout.Button(">", GUILayout.Width(30)))
                            {
                                var newFaction = (Character.Factions)((int)ps.ControlledCharacter.Faction + 1);
                                PlayerManager.Instance.ChangeFactions(ps.ControlledCharacter, newFaction);
                            }
                        }
                        else
                        {
                            GUILayout.Space(35);
                        }

                        if (ps.ControlledCharacter.IsDead && PvP.Instance.CurrentGame == PvP.GameModes.NONE)
                        {
                            if (GUILayout.Button("Resurrect", GUILayout.Width(75)))
                            {
                                RPCManager.Instance.SendResurrect(ps.ControlledCharacter);
                            }
                        }
                    }

                    GUI.skin.label.wordWrap = true;
                    GUI.color = Color.white;
                    GUILayout.EndHorizontal();
                }
            }
            else
            {
                GUILayout.Label("Load up a character to begin...");
            }
        }