SHARE
TWEET

Untitled

a guest Mar 20th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top