void UpdateChangeSlot(string Pname, int currentSelectionRPC, int currentSlotRPC, int slotNumber, PhotonPlayer Owner) { //THIS LOOP SEARCH FOR THE CURRENT SELECTED CHARACTER AND MOVES TO THE NEXT SLOT foreach (GameObject charSlot in allCharslots) { Char_Pick tmp = charSlot.GetComponent <Char_Pick>(); // IF THE CHARACTER MATCH THE CURRENT SELECTION if ((int)tmp.charName == currentSelectionRPC) { foreach (GameObject slot in allslots) { Char_Slot tmpSlot = slot.GetComponent <Char_Slot>(); if (tmpSlot.slotNumber == slotNumber) { if (PhotonNetwork.isMasterClient) { if (tmpSlot.isEmpty) { Debug.Log("RPC SENT TO CLIENTTS"); photonView.RPC("UpdateChangeSlot", PhotonTargets.Others, Pname, currentSelectionRPC, currentSlotRPC, slotNumber, Owner); } else { return; } } tmpSlot.charName = tmp.charName; tmpSlot.ChangePortrait(Pname, Owner, tmp.GetComponent <Image>().sprite, false); emptySlot--; } if (tmpSlot.slotNumber == currentSlotRPC) { tmpSlot.ChangePortrait(Pname, Owner, tmp.GetComponent <Image>().sprite, true); emptySlot--; } } if (PhotonNetwork.player == Owner) { currentSlot = slotNumber; } } } }
void UpdateCharPick(string Pname, int currentSlotRPC, int charNumber, PhotonPlayer Owner, bool sReady) { if (PhotonNetwork.isMasterClient) { //networkView.RPC("UpdateCharPick", uLink.RPCMode.Others, Pname,currentSlotRPC, charNumber, Owner, sReady); photonView.RPC("UpdateCharPick", PhotonTargets.Others, Pname, currentSlotRPC, charNumber, Owner, sReady); } //give the charnumber to the current selection of the owner player if (PhotonNetwork.player == Owner) { currentSelection = charNumber; } //if the player already pick a character, look for the portrait and send it to the slot if (charNumber > 0) { foreach (GameObject charSlot in allCharslots) { Char_Pick tmp = charSlot.GetComponent <Char_Pick>(); if ((int)tmp.charName == charNumber) { foreach (GameObject slot in allslots) { Char_Slot tmpSlot = slot.GetComponent <Char_Slot>(); if (tmpSlot.slotNumber == currentSlotRPC) { tmpSlot.charName = tmp.charName; tmpSlot.isReady = sReady; tmpSlot.ChangePortrait(Pname, Owner, tmp.GetComponent <Image>().sprite, false); emptySlot--; } } } } } else { //if the player hasnt pick the character, only set the name foreach (GameObject slot in allslots) { Char_Slot tmpSlot = slot.GetComponent <Char_Slot>(); if (tmpSlot.slotNumber == currentSlotRPC) { tmpSlot.ChangePortrait(Pname, Owner, tmpSlot.slotEmpty, false); } } } }