private void OnRequestedSpawnPoint(byte[] data) { // Only the master client can provide spawn points if (!PhotonNetwork.IsMasterClient) { return; } Byterizer byterizer = new Byterizer(); byterizer.LoadDeep(data); GridPosition gridPosition = GetFreeSpawnPoint(); byterizer.Push(gridPosition.X); byterizer.Push(gridPosition.Z); data = byterizer.GetBuffer(); // Raising Net Event RaiseEventOptions eventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.Others, CachingOption = EventCaching.AddToRoomCache }; SendOptions sendOptions = new SendOptions { Reliability = true }; PhotonNetwork.RaiseEvent((byte)NetworkedGameEvents.SEND_SPAWN_POINT, data, eventOptions, sendOptions); }
public void InitializeLobby() { Debug.Log("Initializing the lobby"); // Initializing the Lobby Details // Only the master client can choose the Judge to _IsReady = false; _LobbyDetails.InitializeLobbyConnectionDetails(PhotonNetworkManager.Instance.MaximumNumberOfPlayersInARoom); if (PhotonNetwork.IsMasterClient) { int[] indices = _LobbyDetails.Initialize(); RaiseEventOptions eventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.All, CachingOption = EventCaching.AddToRoomCache }; SendOptions sendOptions = new SendOptions { Reliability = true }; Byterizer byterizer = new Byterizer(); byterizer.Push(indices[0]); byterizer.Push(indices[1]); byte[] data = byterizer.GetBuffer(); PhotonNetwork.RaiseEvent((byte)LobbyNetworkedEvents.CHOOSE_JUDGE_AND_DISH, data, eventOptions, sendOptions); } }
private void OnCombatOptionSelected(object combatOptions) { int[] combatData = (int[])combatOptions; Byterizer byterizer = new Byterizer(); byterizer.Push(combatData[0]); byterizer.Push((byte)combatData[1]); byte[] data = byterizer.GetBuffer(); // Raising Net Event (No data required in this case) PhotonNetwork.RaiseEvent((byte)NetworkedGameEvents.ON_SELECTED_COMBAT_OPTION, data, _RaiseEventOptions, _SendOptions); }
protected override void OnSelectedIngredient(object selectedIngredient) { base.OnSelectedIngredient(selectedIngredient); IngredientMinion ingredient = (IngredientMinion)selectedIngredient; var ingredientView = ingredient.GetComponent <PhotonView>(); // Preparing payload Byterizer byterizer = new Byterizer(); byterizer.Push(_PhotonView.ViewID); byterizer.Push(ingredientView.ViewID); byte[] data = byterizer.GetBuffer(); // Raising Net Event PhotonNetwork.RaiseEvent((byte)NetworkedGameEvents.ON_SELECTED_INGREDIENT, data, _RaiseEventOptions, _SendOptions); }
private void OnStartedCombatTimer(object timeData) { float time = (float)timeData; Byterizer byterizer = new Byterizer(); byterizer.Push(time); byte[] data = byterizer.GetBuffer(); PhotonNetwork.RaiseEvent((byte)NetworkedGameEvents.ON_START_COMBAT_TIMER, data, _RaiseEventOptions, _SendOptions); }
protected override void OnSelectedNode(ANode node) { base.OnSelectedNode(node); var nodeView = node.GetComponent <PhotonView>(); if (nodeView == null) { return; } // Preparing payload Byterizer byterizer = new Byterizer(); byterizer.Push(_PhotonView.ViewID); byterizer.Push(nodeView.ViewID); byte[] data = byterizer.GetBuffer(); // Raising Net Event PhotonNetwork.RaiseEvent((byte)NetworkedGameEvents.ON_SELECTED_NODE, data, _RaiseEventOptions, _SendOptions); }
private void OnShowCombatResults(object results) { // Only the master client sends the flag to show reults if (!PhotonNetwork.IsMasterClient) { return; } // Telling the other clients to show the results int[] combatData = (int[])results; Byterizer byterizer = new Byterizer(); byterizer.Push(combatData[0]); byterizer.Push((byte)combatData[1]); byterizer.Push(combatData[2]); byte[] data = byterizer.GetBuffer(); // Raising Net Event PhotonNetwork.RaiseEvent((byte)NetworkedGameEvents.ON_COMBAT_SEQUENCE_RESULT, data, _RaiseEventOptions, _SendOptions); }
private void OnTriggerEnter(Collider other) { // Checking for hero collisions only in the master client if (PhotonNetwork.IsMasterClient && !IsInCombat) { // Checking if the heroes collided HeroController hero = other.GetComponent <HeroController>(); if (hero != null) { IsInCombat = true; _CombatData.HeroesCollidedEvent.Invoke(null); return; } // Ignoring picking up of ingredients if they have entered a combat scenario IngredientMinion ingredient = other.GetComponent <IngredientMinion>(); if (ingredient != null) { PickUpIngredient(ingredient); PhotonView ingredientView = ingredient.GetComponent <PhotonView>(); Byterizer byterizer = new Byterizer(); byterizer.Push(ingredientView.ViewID); byterizer.Push(GetComponent <PhotonView>().ViewID); byte[] data = byterizer.GetBuffer(); // Initializing Network variables RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.Others }; SendOptions sendOptions = new SendOptions { Reliability = true }; PhotonNetwork.RaiseEvent((byte)NetworkedGameEvents.PICKED_UP_INGREDIENT, data, raiseEventOptions, sendOptions); } } }
private void RequestSpawnPoint() { Byterizer byterizer = new Byterizer(); byterizer.Push(PhotonNetwork.LocalPlayer.UserId); byte[] data = byterizer.GetBuffer(); // Raising Net Event RaiseEventOptions eventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.Others, CachingOption = EventCaching.AddToRoomCache }; SendOptions sendOptions = new SendOptions { Reliability = true }; PhotonNetwork.RaiseEvent((byte)NetworkedGameEvents.REQUEST_SPAWN_POINT, data, eventOptions, sendOptions); }
public void ReadyUp(int indexOfHeroData) { if (!_IsReady && PhotonNetwork.InRoom) { Debug.Log("Readying up..."); // Configuring the event RaiseEventOptions eventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.Others, CachingOption = EventCaching.AddToRoomCache }; SendOptions sendOptions = new SendOptions { Reliability = true }; Byterizer byterizer = new Byterizer(); byterizer.Push(indexOfHeroData); byte[] data = byterizer.GetBuffer(); PhotonNetwork.RaiseEvent((byte)LobbyNetworkedEvents.PLAYER_READIED_UP, data, eventOptions, sendOptions); _IsReady = true; OnPlayerReadiedUp(true, indexOfHeroData); } }