Пример #1
0
    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);
                    }
                }
            }
        }
    }
Пример #2
0
    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;
                }
            }
        }
    }
Пример #3
0
 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);
     }
 }
Пример #4
0
 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);
         }
     }
 }
Пример #5
0
    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);
                }
            }
        }
    }