void UpdatePortraits(string Pname, PhotonPlayer Owner) { if (PhotonNetwork.isMasterClient) { bool slotGiven = false; //THIS LINE ADD THE NEW CONECTED PLAYER TO THE PLAYER DATABASE ON GAME MANAGER OBJ dataScript.AddPlayerNameToList(Pname, Owner); for (int i = 0; i < totalSlots + 1; i++) { foreach (GameObject slot in allslots) { Char_Slot tmpSlot = slot.GetComponent <Char_Slot>(); if (tmpSlot.isEmpty && slotGiven == false && tmpSlot.slotNumber == i) { tmpSlot.ChangePortrait(Pname, Owner, tmpSlot.slotEmpty, false); photonView.RPC("SendSlotNumber", PhotonTargets.Others, Pname, tmpSlot.slotNumber, Owner); photonView.RPC("UpdateCharPick", PhotonTargets.Others, tmpSlot.NameBox.text, tmpSlot.slotNumber, tmpSlot.charName, Owner, tmpSlot.isReady); //networkView.RPC("SendSlotNumber", uLink.RPCMode.Others, Pname, tmpSlot.slotNumber, Owner); //networkView.RPC("UpdateCharPick", Owner, tmpSlot.NameBox.text, tmpSlot.slotNumber, tmpSlot.charName, Owner, tmpSlot.isReady); slotGiven = true; } if (tmpSlot.isEmpty == false) { photonView.RPC("UpdateCharPick", PhotonTargets.Others, tmpSlot.NameBox.text, tmpSlot.slotNumber, tmpSlot.charName, tmpSlot.networkOwner, tmpSlot.isReady); //networkView.RPC("UpdateCharPick", Owner, tmpSlot.NameBox.text, tmpSlot.slotNumber, tmpSlot.charName, tmpSlot.networkOwner, tmpSlot.isReady); } } } } }
public void uLink_OnDisconnectedFromServer() { foreach (GameObject slot in allslots) { Char_Slot tmp = slot.GetComponent <Char_Slot>(); tmp.charName = CharacterClass.charName.Empty; tmp.isEmpty = true; tmp.isReady = false; tmp.NameBox.text = ""; Char_Slot tmpSlot = slot.GetComponent <Char_Slot>(); tmp.ChangePortrait("", PhotonNetwork.player, tmpSlot.slotEmpty, true); } }
void SendSlotNumber(string Pname, int currentSlotRPC, PhotonPlayer Owner) { if (PhotonNetwork.player == Owner) { currentSlot = currentSlotRPC; } foreach (GameObject slot in allslots) { Char_Slot tmpSlot = slot.GetComponent <Char_Slot>(); if (tmpSlot.slotNumber == currentSlotRPC) { tmpSlot.ChangePortrait(Pname, Owner, tmpSlot.slotEmpty, false); } } }
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); } } } }
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; } } } }
public void CreateLayout() { allslots = new List <GameObject>(); foreach (GameObject slotObj in GameObject.FindGameObjectsWithTag("Slot")) { allslots.Add(slotObj); } foreach (GameObject slot in allslots) { Char_Slot slotScript = slot.GetComponent <Char_Slot>(); if (slotScript.slotNumber > totalSlots) { Destroy(slot.transform.parent.gameObject); } } }
void ReadyRPC(int currentSlotRPC, PhotonPlayer Owner) { //if (PhotonNetwork.isMasterClient) //{ GameObject particleCamObj = GameObject.Find("CameraParticle"); particleCamObj.SetActive(false); clientScript.ShowGameMenu(); //Destroy(charRectObj); charSlotCount = 0; foreach (GameObject slot in allslots) { Char_Slot tmpSlot = slot.GetComponent <Char_Slot>(); if (tmpSlot.slotNumber == currentSlotRPC) { tmpSlot.isReady = true; } } foreach (GameObject charSlot in allCharslots) { Char_Pick tmp = charSlot.GetComponent <Char_Pick>(); tmp.charButton.interactable = false; //Destroy(charSlot); } foreach (GameObject slot in allslots) { Char_Slot tmpSlot = slot.GetComponent <Char_Slot>(); if (tmpSlot.slotNumber == currentSlotRPC && tmpSlot.networkOwner == Owner) { tmpSlot.isReady = true; //networkView.RPC("ReadyRPC", Owner, currentSlotRPC, uLink.Network.player); //CHARACTER SPAWN if (currentSlotRPC % 2 == 1) { //transform.parent = null; //Application.LoadLevel("MainScene"); //Debug.Log("test"); GameObject spawnManager = GameObject.Find("SpawnManager_mn"); SpawnScript SpawnScr = spawnManager.GetComponent <SpawnScript>(); for (int i = 0; i < charPickList.Count; i++) { if (charPickList[i].characterName == tmpSlot.charName) { //Debug.Log(charPickList[i].charPrefabDir); //Debug.Log(tmpSlot.charName); //charPickedDir = charPickList[i].charPrefabDir; //charPickedName = tmpSlot.charName; //charPickedTeam = "red"; SpawnScr.SpawnBlueTeamPlayer(Owner, charPickList[i].charPrefabDir, tmpSlot.charName); return; } } } else { GameObject spawnManager = GameObject.Find("SpawnManager_mn"); SpawnScript SpawnScr = spawnManager.GetComponent <SpawnScript>(); for (int i = 0; i < charPickList.Count; i++) { if (charPickList[i].characterName == tmpSlot.charName) { //charPickedDir = charPickList[i].charPrefabDir; //harPickedName = tmpSlot.charName; //charPickedTeam = "blue"; SpawnScr.SpawnRedTeamPlayer(Owner, charPickList[i].charPrefabDir, tmpSlot.charName); return; } } } } //} } //if (uLink.Network.isClient) //{ //} }
void ReadyRPC(int currentSlotRPC, uLink.NetworkPlayer Owner) { if (uLink.Network.isServer) { foreach (GameObject slot in allslots) { Char_Slot tmpSlot = slot.GetComponent <Char_Slot>(); if (tmpSlot.slotNumber == currentSlotRPC && tmpSlot.networkOwner == Owner) { tmpSlot.isReady = true; networkView.RPC("ReadyRPC", Owner, currentSlotRPC, uLink.Network.player); //CHARACTER SPAWN if (currentSlotRPC % 2 == 1) { GameObject spawnManager = GameObject.Find("SpawnManager_mn"); SpawnScript SpawnScr = spawnManager.GetComponent <SpawnScript>(); for (int i = 0; i < charPickList.Count; i++) { if (charPickList[i].characterName == tmpSlot.charName) { Debug.Log("Spawn Blue"); SpawnScr.SpawnBlueTeamPlayer(Owner, charPickList[i].charPrefabDir, tmpSlot.charName); return; } } } else { GameObject spawnManager = GameObject.Find("SpawnManager_mn"); SpawnScript SpawnScr = spawnManager.GetComponent <SpawnScript>(); for (int i = 0; i < charPickList.Count; i++) { if (charPickList[i].characterName == tmpSlot.charName) { Debug.Log("Spawn Red"); SpawnScr.SpawnRedTeamPlayer(Owner, charPickList[i].charPrefabDir, tmpSlot.charName); return; } } } } } } if (uLink.Network.isClient) { GameObject particleCamObj = GameObject.Find("CameraParticle"); particleCamObj.SetActive(false); clientScript.ShowGameMenu(); Destroy(charRectObj); charSlotCount = 0; foreach (GameObject slot in allslots) { Char_Slot tmpSlot = slot.GetComponent <Char_Slot>(); if (tmpSlot.slotNumber == currentSlotRPC) { tmpSlot.isReady = true; } } foreach (GameObject charSlot in allCharslots) { Char_Pick tmp = charSlot.GetComponent <Char_Pick>(); tmp.charButton.interactable = false; Destroy(charSlot); } } }