Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5.  
  6. public class GameStateController : NetworkBehaviour {
  7.  
  8. //Get all the players
  9. //Check if all of them are in the jail
  10. //Win the game if they get to the win region
  11. //Lose the game if both players are in jail
  12. public int numberOfPlayers;
  13.  
  14. [SyncVar] public GameObject[] players;
  15.  
  16. // Use this for initialization
  17. void Start () {
  18. if (isServer) CmdInstantiatePlayersArray(numberOfPlayers);
  19. }
  20.  
  21. [Command]
  22. void CmdInstantiatePlayersArray(int length) {
  23. players = new GameObject[length];
  24. }
  25.  
  26. [Command]
  27. public void CmdAddPlayer(string name) {
  28. for(int i = 0; i < players.Length; i++) {
  29. if (players[i].name.Contains("Player"))
  30. continue;
  31. players[i] = GameObject.Find(name).gameObject;
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement