/* De-spawning/disconnection. */ /** * Removes disconnected players locally. * PUN calls this method automatically on other clients. */ void OnPhotonPlayerDisconnected(PhotonPlayer disconnected) { Debug.Log("Player " + disconnected.ToString() + " disconnected."); RemovePlayerFromList(disconnected, playersInLobby); RemovePlayerFromList(disconnected, playersInGame); }
void SpawnModule(PhotonPlayer owner, GameObject prefab, string prefabPath) { Vector2 pos = spawnPoints[0]; spawnPoints.RemoveAt(0); float rot = 0; Debug.Log("Spawning " + prefab.name + " for " + owner.ToString()); GameObject module = ObjectConstructor.ConstructModule(prefab, owner, pos, rot); inGameModules.Add(module, prefabPath); int controllerID = module.GetComponent <ModuleController>().info.view.viewID; foreach (PhotonPlayer player in playersInGame) { view.RPC("SpawnModule", player, prefabPath, owner, controllerID, pos, rot); } }
public void OnGUI() { if (!PhotonNetwork.inRoom) { return; } GUILayout.BeginArea(this.GuiRect); GUILayout.Label("In-Game", new GUILayoutOption[0]); GUILayout.Label("For simplicity, this demo just shows the players in this room. The list will expand when more join.", new GUILayoutOption[0]); GUILayout.Label("Your (random) name: " + PhotonNetwork.playerName, new GUILayoutOption[0]); GUILayout.Label(PhotonNetwork.playerList.Length + " players in this room.", new GUILayoutOption[0]); GUILayout.Label("The others are:", new GUILayoutOption[0]); PhotonPlayer[] otherPlayers = PhotonNetwork.otherPlayers; for (int i = 0; i < otherPlayers.Length; i++) { PhotonPlayer photonPlayer = otherPlayers[i]; GUILayout.Label(photonPlayer.ToString(), new GUILayoutOption[0]); } if (GUILayout.Button("Leave", new GUILayoutOption[0])) { PhotonNetwork.LeaveRoom(); } GUILayout.EndArea(); }
/// <summary> /// Function typically called from the action "PhotonViewRpcBroadcasFsmEventToPlayer" that use RPC to send information about the event to broadcast /// </summary> /// <param name='target'> /// Photon player Target. /// </param> /// <param name='globalEventName'> /// Global Fsm event name to broadcast to the player target /// </param> /// <param name='stringData'> /// String data to pass with this event. WARNING: this is not supposed to be (nor efficient) a way to synchronize data. This is simply to comply with /// the ability for FsmEvent to include data. /// </param> public void PhotonRpcFsmBroadcastEventWithString(PhotonPlayer target,string globalEventName,string stringData) { if (LogMessageInfo) { Debug.Log("RPC to send string:"+stringData+" with global Fsm Event:"+globalEventName+" to player:"+target.ToString()); } photonView.RPC("rpc_s", target, globalEventName, stringData); }
/// <summary> /// Function typically called from the action "PhotonViewRpcBroadcasFsmEvent" that use RPC to send information about the event to broadcast /// </summary> /// <param name='target'> /// Photon player Target. /// </param> /// <param name='globalEventName'> /// Global Fsm event name to broadcast to the player target /// </param> public void PhotonRpcBroadcastFsmEvent(PhotonPlayer target,string globalEventName) { if (LogMessageInfo) { Debug.Log("RPC to send global Fsm Event:"+globalEventName+" to player:"+target.ToString()); } photonView.RPC("rpc", target, globalEventName); }
/* Player connection/spawning. */ /** * Adds newly connected players to the unspawned player list. * Enables spawning (unsafe-ish) */ void OnPhotonPlayerConnected(PhotonPlayer player) { Debug.LogFormat("Adding player {0} to spawn list", player.ToString()); playersInLobby.Add(player); playersSpawning = true; }
/// <summary> /// Function typically called from the action "PhotonViewRpcBroadcasFsmEventToPlayer" that use RPC to send information about the event to broadcast /// </summary> /// <param name='target'> /// Photon player Target. /// </param> /// <param name='globalEventName'> /// Global Fsm event name to broadcast to the player target /// </param> /// <param name='stringData'> /// String data to pass with this event. WARNING: this is not supposed to be (nor efficient) a way to synchronize data. This is simply to comply with /// the ability for FsmEvent to include data. /// </param> public void PhotonRpcFsmBroadcastEventWithString(PhotonPlayer target, string globalEventName, string stringData) { if (LogMessageInfo) { Debug.Log("RPC to send string:" + stringData + " with global Fsm Event:" + globalEventName + " to player:" + target.ToString()); } photonView.RPC("rpc_s", target, globalEventName, stringData); }
/// <summary> /// Function typically called from the action "PhotonViewRpcBroadcasFsmEvent" that use RPC to send information about the event to broadcast /// </summary> /// <param name='target'> /// Photon player Target. /// </param> /// <param name='globalEventName'> /// Global Fsm event name to broadcast to the player target /// </param> public void PhotonRpcBroadcastFsmEvent(PhotonPlayer target, string globalEventName) { if (LogMessageInfo) { Debug.Log("RPC to send global Fsm Event:" + globalEventName + " to player:" + target.ToString()); } photonView.RPC("rpc", target, globalEventName); }
// ------------------------------------------------------------------------------------------------------------------- public void AddCommand(PhotonPlayer player, int lockStepTurn, int commandsLockStepTurn) { if (commandsLockStepTurn == lockStepTurn) { m_playersConfirmedCurrentCommand.Add(player); } else if (commandsLockStepTurn == lockStepTurn - 1) { m_playersConfirmedPriorCommand.Add(player); } else { //TODO: Error Handling logger.Debug("WARNING!!!! Unexpected lockstepID Confirmed : " + lockStepTurn + " from player: " + player.ToString()); } }
void OnPhotonPlayerDisconnected(PhotonPlayer other){ Debug.Log("Player Left " + other.ToString()); }
public override void OnPhotonPlayerConnected(PhotonPlayer newPlayer) { print(newPlayer.ToString()); }