public void AddToDeck(int indexOfCharacter) { // the method that adds to the deck (again the PunRPC version) // I intentionally kept the RPC parts seperate from other functionality even though it is less // efficient writing, so I can better differentiate them for myself while I get used to them // also it helps me to make sure I only transfer what I need and nothing more Participant.Character target = (Participant.Character)indexOfCharacter; deck.Add(target); }
public Participant.Character DrawInfluence() { // this gets used by the player objects to access the central deck. the fact that each role only exists // three times is relevant, so I need a central deck. I use the buffered RPC call to further ensure integrity of the deck int randomPick = Random.Range(0, deck.Count); Participant.Character returnValue = deck[randomPick]; pv.RPC("RemoveFromDeck", RpcTarget.AllBuffered, ((int)returnValue)); return(returnValue); }
public void RemoveFromDeck(int indexOfCharacter) { // this is the actual method that removes from the deck when drawn, using the PunRPC tag, it is // executed on all matching instances of this object over the network Participant.Character target = (Participant.Character)indexOfCharacter; for (int i = 0; i < deck.Count; i++) { if (deck[i] == target) { deck.RemoveAt(i); break; } } }
public void ReturnInfluence(Participant.Character card) { // some things require cards be returned to the deck, again buffered to ensure integrity pv.RPC("AddToDeck", RpcTarget.AllBuffered, (int)card); }