Advertisement
Guest User

test.cs

a guest
Jun 13th, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.Networking;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6.  
  7. public class Test : NetworkBehaviour {
  8.     public bool isReady
  9.     {
  10.         get
  11.         {
  12.             List<NetworkConnection> connections = NetworkServer.connections.FindAll(c => c != null).ToList();
  13.             NetworkConnection hostConnection = NetworkServer.localConnections.Find(c => c.isReady && c.hostId == -1);
  14.  
  15.             if (hostConnection != null && connections.All(c => c.isReady))
  16.                 return true;
  17.             return false;
  18.         }
  19.     }
  20.     public bool isRunningGame { get; private set; }
  21.  
  22.     void Start () {
  23.    
  24.     }
  25.    
  26.     void Update()
  27.     {
  28.         if (!isRunningGame && isServer)
  29.         {
  30.             if (isReady)
  31.             {
  32.                 RpcStartGame();
  33.             }
  34.         }
  35.     }
  36.  
  37.     [ClientRpc]
  38.     public void RpcStartGame()
  39.     {
  40.         isRunningGame = true;
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement