// Update is called once per frame void Update() { if (!isServer) { gameState = currState; } else { currState = gameState; } ///Check if the haunt has started yet. if (isServer && gameState == HauntState.EXPLORE) { elapsed += Time.deltaTime; if (elapsed >= checkInterval) { //Debug.Log ("Checking Haunts"); foreach (Haunt haunt in haunts) { if (haunt.CanStartHaunt()) { //Debug.Log ("Started Haunt"); gameHaunt = GameObject.Instantiate(haunt.gameObject); NetworkServer.Spawn(gameHaunt); gameState = HauntState.PREP; RpcHauntStarted(gameHaunt); return; } } elapsed = 0; } } else if (isServer && gameState == HauntState.PREP) { if (ready.Count == NetworkGame.GetPlayers().Length) { gameState = HauntState.HAUNT; RpcPrepEnd(); } } else if (isServer && gameState == HauntState.END) { if (prevState != HauntState.END) { RpcHauntEnded(); } } prevState = gameState; }
public static void EndHaunt() { gameState = HauntState.END; }