public void onReady() { GameObject[] lobbyPlayers = GameObject.FindGameObjectsWithTag("lobbyplayer"); // May happen during network delays. if (lobbyPlayers.Length <= 0) { Debug.Log("LOBBY_HUD::onReady: No lobby players found!"); //FindObjectOfType<NetworkPlayerSelect>().GetComponent<NetworkPlayerSelect>().TryToAddPlayer(); } foreach (GameObject player in lobbyPlayers) { NetworkLobbyPlayer lobbyPlayer = player.GetComponent <NetworkLobbyPlayer>(); if (!lobbyPlayer.isLocalPlayer) { continue; } if (!lobbyPlayer.readyToBegin) { lobbyPlayer.SendReadyToBeginMessage(); } else { lobbyPlayer.SendNotReadyToBeginMessage(); } StartCoroutine(this.initLobbyRoom(0.0f)); } }
// Send a list of all the player names and ready-state to the player. private void sendLobbyPlayersMessage(int id) { LobbyPlayerMessage message = new LobbyPlayerMessage(); List <Player> players = new List <Player>(); // Update the ready-state for each connected lobby player. foreach (var conn in NetworkServer.connections) { NetworkLobbyPlayer lobbyPlayer = null; if ((conn != null) && (conn.playerControllers.Count > 0) && (conn.playerControllers[0].gameObject != null)) { lobbyPlayer = conn.playerControllers[0].gameObject.GetComponent <NetworkLobbyPlayer>(); } if (lobbyPlayer != null) { this._players[conn.connectionId].readyLobby = lobbyPlayer.readyToBegin; players.Add(this._players[conn.connectionId]); } } message.players = new LobbyPlayer[players.Count]; for (int i = 0; i < players.Count; i++) { message.players[i] = new LobbyPlayer(); message.players[i].name = players[i].name; message.players[i].animal = players[i].animal; message.players[i].ready = players[i].readyLobby; } NetworkServer.SendToClient(id, (short)NetworkMessageType.MSG_LOBBY_PLAYERS, message); }
// Use this for initialization void Awake() { DontDestroyOnLoad(this.gameObject); nlp = GetComponent <NetworkLobbyPlayer> (); nlp.readyToBegin = true; NetworkLobbyManager nlm = FindObjectOfType <NetworkLobbyManager> (); // Debug.Log(nlm.startPositions.Count); }
public override void OnLobbyStartServer() { if (lobbySlots.Length == 0) { lobbySlots = new NetworkLobbyPlayer[maxPlayers]; } base.OnLobbyStartServer(); }
// Needs to be optimized currently does this multiple times once for each client public void LoadCurrentPrompts(NetworkLobbyPlayer player, List <int> randIntList) { Debug.Log("gamecontrol loadprompt executes " + randIntList.Count); currentPromptsDict = new Dictionary <int, List <string> >(); foreach (int randInt in randIntList) { currentPromptsDict.Add(randInt, AllPromptsDict[randInt]); } }
void AddPlayerItem(NetworkLobbyPlayer player) { var listItem = Instantiate(playerListItemBehaviourPrefab, playerList); listItem.SetPlayerName(player.name); listItem.SetReady(player.readyToBegin); playerItemMap.Add(player, listItem); }
void Start() { if (!isServer) { return; } _lPlayer = GetComponent <NetworkLobbyPlayer>(); }
public void Update() { CurrentLocalPlayer = UILobbyManager.LocalLobbyPlayer; if (SyncEveryFrame) { SyncReadyState(); } }
public override void OnServerAddPlayer(NetworkConnection conn) { if (SceneManager.GetActiveScene().name == "main menu") { bool isLeader = LobbyPlayers.Count == 0; NetworkLobbyPlayer networkLobbyPlayerInstance = Instantiate(networkLobbyPlayerPrefab); networkLobbyPlayerInstance.IsLeader = isLeader; NetworkServer.AddPlayerForConnection(conn, networkLobbyPlayerInstance.gameObject); } }
//Skrypt identyfikujący lokalnego gracza void Start() { PlayerList = GameObject.FindGameObjectWithTag("PlayerList"); LobbyManger = NetworkLobbyManager.singleton.GetComponent <NetworkLobbyManager>(); LobbyPlayer = gameObject.GetComponent <NetworkLobbyPlayer>(); menu = GameObject.FindGameObjectWithTag("Menu").GetComponent <Menu>(); if (isLocalPlayer) { LobbyManger.gameObject.GetComponent <NetworkLobbyManagerScript>().Player(gameObject.GetComponent <NetworkLobbyPlayer>()); } LocalEnable(LobbyPlayer.readyToBegin); }
public override void OnServerAddPlayer(NetworkConnection conn) { if (SceneManager.GetActiveScene().path == menuScene) { bool isLeader = RoomPlayers.Count == 0; NetworkLobbyPlayer roomPlayerInstance = Instantiate(roomPlayerPrefab); roomPlayerInstance.IsLeader = isLeader; //roomPlayerInstance.SelectedWeapon = SelectionScreen.SelectedWeapon; //roomPlayerInstance.SelectedQuirk = SelectionScreen.SelectedQuirk; NetworkServer.AddPlayerForConnection(conn, roomPlayerInstance.gameObject); } }
public override void OnServerDisconnect(NetworkConnection conn) { if (conn.identity != null) { NetworkLobbyPlayer player = conn.identity.GetComponent <NetworkLobbyPlayer>(); RoomPlayers.Remove(player); //NotifyPlayersOfReadyState(); } base.OnServerDisconnect(conn); }
public override void OnServerAddPlayer(NetworkConnection conn) { if ("Assets/Scenes/" + SceneManager.GetActiveScene().name + ".unity" == MenuScene) { bool isLeader = RoomPlayers.Count == 0; NetworkLobbyPlayer roomPlayerInstance = Instantiate(RoomPlayerPrefab); roomPlayerInstance.IsLeader = isLeader; NetworkServer.AddPlayerForConnection(conn, roomPlayerInstance.gameObject); } base.OnServerAddPlayer(conn); }
public void RpcSetReady() { if (GameObject.FindGameObjectsWithTag("LobbyPlayer").Length > 0) { foreach (GameObject netPlayerObj in GameObject.FindGameObjectsWithTag("LobbyPlayer")) { NetworkLobbyPlayer netPlayer = netPlayerObj.GetComponent <NetworkLobbyPlayer>(); if (netPlayer.isLocalPlayer) { netPlayer.SendReadyToBeginMessage(); } } } }
public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayer, GameObject gamePlayer) { Debug.Log("OnLobbyServerSceneLoadedForPlayer"); NetworkLobbyPlayer nlp = lobbyPlayer.GetComponent <NetworkLobbyPlayer>(); var playerIndex = nlp.slot + 1; PlayerNetwork pn = gamePlayer.GetComponent <PlayerNetwork>(); pn.GetComponent <Unit_ID>().CmdSetPlayerIndex(playerIndex); pn.GetComponent <Unit_ID>().CmdSetMyUniqueID("Player" + playerIndex); pn.connectionId = nlp.connectionToClient.connectionId; return(true); }
void Start() { Manager = FindObjectOfType <LobbyNetworkScript>(); InitialMenu = this.transform.FindChild("InitialMenu").gameObject; NameInputField = InitialMenu.transform.FindChild("Name").GetComponent <InputField>(); NameInputField.text = randomNames[Random.Range(0, randomNames.Length)]; AICountInputField = InitialMenu.transform.FindChild("AI Count").GetComponent <InputField>(); CardCopyInputField = InitialMenu.transform.FindChild("Copy Count").GetComponent <InputField>(); JoinAddressInputField = InitialMenu.transform.FindChild("JoinAddress").GetComponent <InputField>(); ServerInfoText = this.transform.FindChild("ServerInfo").GetComponent <Text>(); ClientInfoText = this.transform.FindChild("ClientInfo").GetComponent <Text>(); ReadyMenu = this.transform.FindChild("ReadyMenu").gameObject; ReadyCheck = ReadyMenu.transform.FindChild("ReadyCheck").GetComponent <Toggle>(); myPlayer = null; }
//========================== Value Set public void SetMaxPlayers(int max) { max = Mathf.Clamp(max, 1, 254); // 需要更新 if (max > maxPlayers) { NetworkLobbyPlayer[] slots = new NetworkLobbyPlayer[max]; for (int i = 0; i < lobbySlots.Length; i++) { slots [i] = lobbySlots [i]; } lobbySlots = slots; } maxPlayers = max; }
// Use this for initialization public override void OnStartLocalPlayer() { // Find any other player objects and their position relative to this player LobbyPlayer[] players = FindObjectsOfType <LobbyPlayer>(); if (players.Length > 1) { multiplePlayers = true; foreach (LobbyPlayer player in players) { if (player == this) { continue; } if (player.transform.position.x >= transform.position.x) { playerOnRight = true; } else { playerOnRight = false; } otherPlayer = player; player.otherPlayer = this; player.multiplePlayers = true; } transform.position = new Vector3(-3, 0, 0); } else { transform.position = new Vector3(3, 0, 0); } if (isLocalPlayer) { lobbyMan = FindObjectOfType <LobbyMan>(); lobbyPlayer = GetComponent <NetworkLobbyPlayer>(); networkMan = FindObjectOfType <NetworkMan>(); readyButton.gameObject.SetActive(true); notReadyButton.gameObject.SetActive(false); SetUpButton(readyButton.GetComponent <_2DContextButton>()); } else { readyButton.enabled = false; notReadyButton.enabled = false; } }
void Update() { if (!NetworkClient.active && !NetworkServer.active && Manager.matchMaker == null) { InitialMenu.SetActive(true); ReadyMenu.SetActive(false); ServerInfoText.gameObject.SetActive(false); ClientInfoText.gameObject.SetActive(false); AICountInputField.text = Manager.aiPlayerCount.ToString(); CardCopyInputField.text = Manager.cardCopyCount.ToString(); Manager.networkAddress = JoinAddressInputField.text; myPlayer = null; } else { InitialMenu.SetActive(false); ReadyMenu.SetActive(true); ServerInfoText.gameObject.SetActive(NetworkServer.active); if (NetworkServer.active) { ServerInfoText.text = "Server: port=" + Manager.networkPort; } ClientInfoText.gameObject.SetActive(NetworkClient.active); if (NetworkClient.active) { ClientInfoText.text = "Client: address=" + Manager.networkAddress + " port=" + Manager.networkPort; } if (myPlayer == null) { foreach (NetworkLobbyPlayer p in Manager.lobbySlots) { if (p != null && p.isLocalPlayer) { myPlayer = p; } } } else { ReadyCheck.isOn = myPlayer.readyToBegin; } } }
public static GameObject AddToPlayerList(NetworkLobbyPlayer lobbyPlayer) { if (singleton && singleton.PlayerListPrefab && singleton.PlayerListContentAnchor) { GameObject playerListObject = (GameObject)Instantiate(singleton.PlayerListPrefab, Vector3.zero, Quaternion.identity); RectTransform child = playerListObject.GetComponent <RectTransform>(); child.SetParent(singleton.PlayerListContentAnchor, false); UIPlayerListingEntry entry = playerListObject.GetComponent <UIPlayerListingEntry>(); entry.Player = lobbyPlayer; return(playerListObject); } else { return(null); } }
public void Init() { realInfoManager = gameObject.GetComponent <LobbyPlayerManager_Server>(); realInfoManager.Init(); lobbyPlayer = gameObject.GetComponent <NetworkLobbyPlayer>(); realInfoManager.Init(); if (isLocalPlayer) { gameObject.tag = "localPlayer"; string name = GameObject.Find("_SCRIPTS_").GetComponent <SettingsManager>().GetPlayerName(); CmdSetName(name); } //GetComponent<NetworkLobbyPlayer>().SendReadyToBeginMessage(); //lobbyPlayer.readyToBegin = true; }
// Use this for initialization void Start() { manager = GetComponent <NetworkLobbyPlayer> (); GameObject panelParent = GameObject.Find("PanelParent"); playerPanel = (GameObject)Instantiate(playerPanel, panelParent.transform); playerPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); PanelPositionHandler.s.panels.Add(playerPanel); panelScript = playerPanel.GetComponent <LobyPlayerPanel> (); panelScript.playerid = id; panelScript.playerSlot = playerSlot; panelScript.playerState = manager.readyToBegin; panelScript.myPlayer = this; if (isLocalPlayer) { panelScript.isLocalPlayer = true; localPlayer = this; gameObject.name = "Local lobey player"; } else { panelScript.isLocalPlayer = false; } if (isServer && DataHandler.s == null) { GameObject _dataHandler = (GameObject)Instantiate(prefabDataHandler, Vector3.zero, Quaternion.identity); _dataHandler.GetComponent <DataHandler> ().SetUp(); NetworkServer.Spawn(_dataHandler); } if (isLocalPlayer) { CmdSetUpPlayer(); } }
// Use this for initialization void Start() { manager = GetComponent <NetworkLobbyPlayer> (); GameObject panelParrent = GameObject.Find("PanelParent"); playerPanel = (GameObject)Instantiate(playerPanel, panelParrent.transform); playerPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); panelScript = playerPanel.GetComponent <LobyPlayerPanel> (); panelScript.playerid = manager.slot; panelScript.playerState = manager.readyToBegin; panelScript.myPlayer = this; if (isLocalPlayer) { panelScript.isLocalPlayer = true; } else { panelScript.isLocalPlayer = false; } }
public AddPlayerEvent(NetworkLobbyPlayer player) { Player = player; }
public void RemovePlayer(NetworkLobbyPlayer player) { player.RemovePlayer(); }
void Awake() { cc = GetComponent <ColorControl>(); lobbyPlayer = GetComponent <NetworkLobbyPlayer>(); }
//!!!KONIEC FUNKCJI ZWIĄZANYCH Z TWORZENIEM I ŁĄCZENIEM SIĘ Z GRĄ!!! //!!!POCZĄTEK FUNKCJI NetworkLobbyManager'a I ZWIĄZANYCH Z POŁĄCZONYMI GRACZAMI!!! //Funkcja wywoływana przez lokalnego gracza do indetyfikacji public void Player(NetworkLobbyPlayer player) { LobbyPlayer = player; }
void Awake() { lobbyPlayer = GetComponent <NetworkLobbyPlayer>(); playerUI = GetComponent <PlayerLobby>(); }
public PlayerReadyEvent(NetworkLobbyPlayer player, bool ready) { Player = player; Ready = ready; }
public RemovePlayerEvent(NetworkLobbyPlayer player) { Player = player; }