Exemplo n.º 1
0
        public override void Read(NetIncomingMessage inInputStream)
        {
            bool stateBit;

            //Debug.Log($"GameMode read");

            stateBit = inInputStream.ReadBoolean();
            if (stateBit)
            {
                mEntries.Clear();
                int entryCount = inInputStream.ReadInt32();
                //just replace everything that's here, it don't matter...
                for (int i = 0; i < entryCount; ++i)
                {
                    var entry = new core.Entry();
                    entry.Read(inInputStream);
                    mEntries.Add(entry);
                }
            }

            stateBit = inInputStream.ReadBoolean();
            if (stateBit)
            {
                var mode = (core.GameModeType)inInputStream.ReadUInt32(MaxGameModeTypeBits);
                game_mode = CreateGameMode(mode);
                game_mode.Read(inInputStream);
                mGameModeData = ACDC.GameModeData[(int)mode];
            }

            stateBit = inInputStream.ReadBoolean();
            if (stateBit)
            {
                state = (GameModeState)inInputStream.ReadUInt32(MaxGameModeStateBits);
                if (state == GameModeState.End)
                {
                    game_mode.ReadGameResult(inInputStream, this);
                    OnGameEnd();
                }
                //Debug.Log($"GameMode state {state}");
            }

            stateBit = inInputStream.ReadBoolean();
            if (stateBit)
            {
                // 최대 RTT 보정
                if (NetworkManager.Instance.GetRoundTripTimeClientSide() > 1f)
                {
                    StartTime = core.Timing.sInstance.GetFrameStartTime() + inInputStream.ReadFloat() - (1f * 0.5f);
                }
                else
                {
                    StartTime = core.Timing.sInstance.GetFrameStartTime() + inInputStream.ReadFloat() - (NetworkManager.Instance.GetRoundTripTimeClientSide() * 0.5f);
                }
                Debug.Log($"GameMode Start StartTime:{StartTime}, RemainTime:{RemainTime}, timestamp:{core.Timing.sInstance.GetFrameStartTime()}, RTT:{NetworkManager.Instance.GetRoundTripTimeClientSide()}");
                IsSetPlayTime = true;
            }
        }