// 检查游戏是否可以开始
        private void CheckGameStart()
        {
            bool flag = this.replayMode == ReplayMode.LOAD_REPLAY;

            if (flag) // 加载回放模式
            {
                this.RunSimulation(false);
            }
            else // 非加载回放模式
            {
                bool flag2 = true;
                int  i     = 0;
                int  count = this.activePlayers.Count;
                while (i < count)
                {
                    flag2 &= this.activePlayers[i].sentSyncedStart;
                    i++;
                }
                bool flag3 = flag2;
                if (flag3)
                {
                    this.RunSimulation(false);
                    SyncedData.pool.FillStack(this.activePlayers.Count * (this.syncWindow + this.rollbackWindow));
                }
                else
                {
                    this.RaiseEvent(196, SyncedInfo.Encode(new SyncedInfo
                    {
                        playerId = this.localPlayer.ID
                    }));
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 先检测远端玩家都准备好没,如果没有发送196事件 告诉所有远端玩家我已经准备好了
 /// </summary>
 private void CheckGameStart()
 {
     //默认是ReplayMode.NO_REPLAY
     if (this.replayMode == ReplayMode.LOAD_REPLAY)
     {
         this.RunSimulation(false);
     }
     else
     { //检测所有玩家是否已经准备好了
         bool flag  = true;
         int  i     = 0;
         int  count = this.activePlayers.Count;
         while (i < count)
         {
             flag &= this.activePlayers[i].sentSyncedStart;
             i++;
         }
         //所有玩家已经准备好了
         if (flag)
         {
             this.RunSimulation(false);
             SyncedData.pool.FillStack(this.activePlayers.Count * (this.syncWindow + this.rollbackWindow));
         }
         //发送196事件,告诉远端玩家 我已经准备好了
         else
         {
             this.RaiseEvent(SYNCED_GAME_START_CODE, SyncedInfo.Encode(new SyncedInfo
             {
                 playerId = this.localPlayer.ID
             }));
         }
     }
 }
Esempio n. 3
0
        private void CheckGameStart()
        {
            bool flag = this.replayMode == ReplayMode.LOAD_REPLAY;

            if (flag)
            {
                this.RunSimulation(false);
            }
            else
            {
                bool flag2 = true;
                foreach (TSPlayer current in this.players.Values)
                {
                    flag2 &= current.sentSyncedStart;
                }
                bool flag3 = flag2;
                if (flag3)
                {
                    this.RunSimulation(false);
                }
                else
                {
                    this.RaiseEvent(196, SyncedInfo.Encode(new SyncedInfo
                    {
                        playerId = this.localPlayer.ID
                    }));
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 对刚体body的位置和旋转数据的一个同步校验
 /// </summary>
 /// <param name="tick"></param>
 private void SendInfoChecksum(int tick)
 {
     Debug.Log("SendInfoChecksum");
     if (replayMode != ReplayMode.LOAD_REPLAY)
     {
         SyncedInfo syncedInfo = bufferSyncedInfo.Current();
         syncedInfo.playerId = localPlayer.ID;
         syncedInfo.tick     = tick;
         syncedInfo.checksum = GetChecksumForSyncedInfo();
         bufferSyncedInfo.MoveNext();
         RaiseEvent(CHECKSUM_CODE, SyncedInfo.Encode(syncedInfo));
     }
 }
        private void SendInfoChecksum(int tick)
        {
            bool flag = this.replayMode == ReplayMode.LOAD_REPLAY;

            if (!flag)
            {
                SyncedInfo syncedInfo = this.bufferSyncedInfo.Current();
                syncedInfo.playerId = this.localPlayer.ID;
                syncedInfo.tick     = tick;
                syncedInfo.checksum = this.GetChecksumForSyncedInfo();
                this.bufferSyncedInfo.MoveNext();
                this.RaiseEvent(198, SyncedInfo.Encode(syncedInfo));
            }
        }
Esempio n. 6
0
        private void CheckGameStart()
        {
            Debug.Log("CheckGameStart");
            if (replayMode == ReplayMode.LOAD_REPLAY)
            {
                RunSimulation(false);
            }
            else
            {
                //检测所有玩家是否已经准备好了
                bool flag  = true;
                int  i     = 0;
                int  count = activePlayers.Count;
                while (i < count)
                {
                    flag &= activePlayers[i].sentSyncedStart;
                    i++;
                }


                //所有玩家已经准备好了
                if (flag)
                {
                    RunSimulation(false);
                    SyncedData.pool.FillStack(activePlayers.Count * (syncWindow + rollbackWindow));
                }
                //其他玩家还没有准备好,发送196事件
                else
                {
                    RaiseEvent(SYNCED_GAME_START_CODE, SyncedInfo.Encode(new SyncedInfo
                    {
                        playerId = this.localPlayer.ID
                    }));
                }
            }
        }