예제 #1
0
 protected void FixedUpdate()
 {
     LockstepManager.Simulate();
     if (ReplayManager.IsPlayingBack)
     {
         if (hashChecked == false)
         {
             if (LockstepManager.FrameCount == hashFrame)
             {
                 hashChecked = true;
                 long newHash = AgentController.GetStateHash();
                 if (newHash != prevHash)
                 {
                     Debug.Log("Desynced!");
                 }
                 else
                 {
                     Debug.Log("Synced!");
                 }
             }
         }
     }
     else
     {
         hashFrame   = LockstepManager.FrameCount - 1;
         prevHash    = stateHash;
         stateHash   = AgentController.GetStateHash();
         hashChecked = false;
     }
 }
        void OnGUI()
        {
            GUILayout.Label("State Hash: " + AgentController.GetStateHash());

            if (GameManager.Instance != null && GameManager.Instance.MainNetworkHelper.IsConnected)
            {
                return;
            }
            #region Setting IP and RoomSize via GUI
            GUILayout.BeginVertical(GUILayout.Width(300f));
            GUILayout.Label("Time: " + Time.time.ToString());
            GUI.color = Color.white;
            GUILayout.Label("IP: ");
            IP = GUILayout.TextField(IP);

            GUILayout.Label("Room Size");
            int.TryParse(GUILayout.TextField(RoomSize.ToString()), out RoomSize);
            #endregion

            //Below = important!
            if (GUILayout.Button("Host"))
            {
                //Hosting with a room size of RoomSize
                ClientManager.HostGame(RoomSize);
            }
            if (GUILayout.Button("Connect"))
            {
                //Connecting to the server with ip address 'IP'
                ClientManager.ConnectGame(IP);
            }
            GUILayout.EndVertical();
        }
예제 #3
0
        public static int GetStateHash()
        {
            int hash = LSUtility.PeekRandom(int.MaxValue);

            hash += 1;
            hash ^= AgentController.GetStateHash();
            hash += 1;
            hash ^= ProjectileManager.GetStateHash();
            hash += 1;
            return(hash);
        }