Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.Networking;
- using System.Collections.Generic;
- using System.Linq;
- public class Test : NetworkBehaviour {
- public bool isReady
- {
- get
- {
- List<NetworkConnection> connections = NetworkServer.connections.FindAll(c => c != null).ToList();
- NetworkConnection hostConnection = NetworkServer.localConnections.Find(c => c.isReady && c.hostId == -1);
- if (hostConnection != null && connections.All(c => c.isReady))
- return true;
- return false;
- }
- }
- public bool isRunningGame { get; private set; }
- void Start () {
- }
- void Update()
- {
- if (!isRunningGame && isServer)
- {
- if (isReady)
- {
- RpcStartGame();
- }
- }
- }
- [ClientRpc]
- public void RpcStartGame()
- {
- isRunningGame = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement