Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- public class GameStateController : NetworkBehaviour {
- //Get all the players
- //Check if all of them are in the jail
- //Win the game if they get to the win region
- //Lose the game if both players are in jail
- public int numberOfPlayers;
- [SyncVar] public GameObject[] players;
- // Use this for initialization
- void Start () {
- if (isServer) CmdInstantiatePlayersArray(numberOfPlayers);
- }
- [Command]
- void CmdInstantiatePlayersArray(int length) {
- players = new GameObject[length];
- }
- [Command]
- public void CmdAddPlayer(string name) {
- for(int i = 0; i < players.Length; i++) {
- if (players[i].name.Contains("Player"))
- continue;
- players[i] = GameObject.Find(name).gameObject;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement