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); }
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); } }
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); } } }