private void P2C_QueryInFightInfo(MobaMessage msg)
        {
            InBattleRuntimeInfo probufMsg = msg.GetProbufMsg <InBattleRuntimeInfo>();

            PvpStateBase.LogState("receive P2C_QueryInFightInfo " + StringUtils.DumpObject(probufMsg));
            if (probufMsg == null)
            {
                PvpStateBase.LogState("no fight info");
            }
            else
            {
                GameManager.Instance.ReplayController.SaveReconnectSyncMsgForRecord(msg.Param);
                PvpProtocolTools.SyncFightInfo(probufMsg);
                if (probufMsg.roomState == 3)
                {
                    Singleton <PvpManager> .Instance.AbandonGame(PvpErrorCode.StateError);
                }
            }
            if (this.TargetState == PlayerState.InFight || probufMsg != null)
            {
                this.RecoverFinish(new PvpStateStart(PvpStateCode.PvpStart));
            }
            else
            {
                SendMsgManager.Instance.SendPvpMsg(PvpCode.C2P_LoadingOK, null);
                this.RecoverFinish(new PvpStateLoad());
            }
        }
示例#2
0
        private void P2C_QueryInFightInfo(MobaMessage msg)
        {
            InBattleRuntimeInfo probufMsg = msg.GetProbufMsg <InBattleRuntimeInfo>();

            PvpStateBase.LogState("receive P2C_QueryInFightInfo " + StringUtils.DumpObject(probufMsg));
            this.SyncFightInfo(probufMsg);
        }
示例#3
0
 protected override void OnAfterLoadOk(InBattleRuntimeInfo info)
 {
     if (Singleton <PvpManager> .Instance.LoadStatus == LoadSceneStatus.Finished)
     {
         this.SyncFightInfo(info);
         PvpStateManager.Instance.ChangeState(new PvpStateStart(PvpStateCode.PvpStart));
         FrameSyncManager.Instance.ResetInfoOnOnBattleStart();
     }
 }
示例#4
0
        private void P2C_LoadingOK(MobaMessage msg)
        {
            InBattleRuntimeInfo probufMsg = msg.GetProbufMsg <InBattleRuntimeInfo>();

            PvpStateBase.LogState("receive P2C_LoadingOK " + StringUtils.DumpObject(probufMsg));
            Singleton <PvpManager> .Instance.HasRecvLoadingOk = true;
            Singleton <PvpManager> .Instance.GameStartTime    = new DateTime?(DateTime.Now);
            this.OnAfterLoadOk(probufMsg);
        }
        private void P2C_RefreshInFightInfo(MobaMessage msg)
        {
            PvpServer.LockScreen(false);
            InBattleRuntimeInfo probufMsg = msg.GetProbufMsg <InBattleRuntimeInfo>();

            PvpStateBase.LogState("receive P2C_RefreshInFightInfo  " + StringUtils.DumpObject(probufMsg));
            PvpProtocolTools.SyncFightInfo(probufMsg);
            if (probufMsg != null && probufMsg.roomState == 3)
            {
                Singleton <PvpManager> .Instance.AbandonGame(PvpErrorCode.StateError);
            }
            this.RecoverFinish(new PvpStateStart(PvpStateCode.PvpStart));
        }
示例#6
0
        private void P2C_QueryInFightInfo(MobaMessage msg)
        {
            OperationResponse operationResponse = msg.Param as OperationResponse;

            byte[] array = (byte[])operationResponse.Parameters[0];
            InBattleRuntimeInfo inBattleRuntimeInfo = SerializeHelper.Deserialize <InBattleRuntimeInfo>(array);

            if (array.Length == 0)
            {
                inBattleRuntimeInfo = null;
            }
            PvpStateBase.LogState("receive P2C_QueryInFightInfo " + StringUtils.DumpObject(inBattleRuntimeInfo));
            this.SyncFightInfo(inBattleRuntimeInfo);
        }
        private static void ResetHeroStatistic(InBattleRuntimeInfo fightInfo)
        {
            if (fightInfo.unitCounters != null)
            {
                foreach (KeyValuePair <int, PlayerCounter> current in fightInfo.unitCounters)
                {
                    PvpStatisticMgr.HeroData heroData = Singleton <PvpManager> .Instance.StatisticMgr.GetHeroData(-current.Key);

                    if (heroData != null)
                    {
                        PlayerCounter value = current.Value;
                        heroData.HeroKill    = value.killHoreCount;
                        heroData.MonsterKill = value.killMonsterCount;
                        heroData.Assist      = value.helpKillHoreCount;
                        heroData.FirstKill   = value.isFirstBlood;
                        heroData.Death       = value.deadCount;
                    }
                    else
                    {
                        Debug.LogError("can't get hero with id: " + current.Key);
                    }
                }
            }
            if (fightInfo.teamInfos != null && fightInfo.teamInfos.Length >= 2)
            {
                for (int i = 0; i < Mathf.Min(fightInfo.teamInfos.Length, 3); i++)
                {
                    GroupTeamInfo groupTeamInfo = fightInfo.teamInfos[i];
                    int           teamType      = i;
                    if (i == 2)
                    {
                        teamType = 3;
                    }
                    PvpStatisticMgr.GroupData groupData = Singleton <PvpManager> .Instance.StatisticMgr.GetGroupData(teamType);

                    groupData.TeamKill            = groupTeamInfo.teamKill;
                    groupData.TeamLv              = groupTeamInfo.Level;
                    groupData.TeamCurExp          = groupTeamInfo.exp;
                    groupData.TeamTowerDestroy    = groupTeamInfo.killTowerCount;
                    groupData.TeamEpicMonsterKill = groupTeamInfo.killSpeMonsterCount;
                    groupData.TeamDeath           = groupTeamInfo.deadCount;
                }
                if (fightInfo.teamInfos.Length > 3)
                {
                    ClientLogger.Error("cannot handle it any more, too many teams");
                }
            }
            Singleton <TriggerManager> .Instance.SendGameStateEvent(GameEvent.UpdateView);
        }
        public static void SyncFightInfo(InBattleRuntimeInfo fightInfo)
        {
            if (fightInfo == null || fightInfo.teamInfos == null)
            {
                return;
            }
            if (fightInfo.frameTime > 0)
            {
                FrameSyncManager.Instance.OneFrameTime = (double)((float)fightInfo.frameTime / 1000f);
            }
            PvpProtocolTools.ResetHeroStatistic(fightInfo);
            GameManager.Instance.SurrenderMgr.SyncInfos(fightInfo.surrenderInfos);
            Singleton <PvpManager> .Instance.RoomInfo.CtrlUniqueIds.Clear();

            if (fightInfo.unitInfos == null)
            {
                return;
            }
            PvpProtocolTools.SyncSceneState(fightInfo.sceneValues);
            Singleton <PvpManager> .Instance.GameStartTime = new DateTime?(DateTime.Now - TimeSpan.FromTicks(fightInfo.gameTime));
            Dictionary <int, Units> allMapUnits = MapManager.Instance.GetAllMapUnits();
            List <Units>            list        = new List <Units>();

            foreach (Units unit in allMapUnits.Values)
            {
                if ((!unit.isHero && !unit.isHome && !unit.isBuilding) || unit.MirrorState)
                {
                    if (unit.isLive)
                    {
                        UnitRuntimeInfo unitRuntimeInfo = fightInfo.unitInfos.FirstOrDefault((UnitRuntimeInfo x) => x.baseUnitInfo.unitId == unit.unique_id);
                        if (unitRuntimeInfo == null)
                        {
                            list.Add(unit);
                        }
                    }
                }
            }
            foreach (Units current in list)
            {
                MapManager.Instance.DespawnUnit(current);
            }
            for (int i = 0; i < fightInfo.unitInfos.Length; i++)
            {
                PvpProtocolTools.SyncSingleUnit(fightInfo.unitInfos[i]);
            }
            Singleton <MiniMapView> .Instance.UpdateAfterReConect();
        }
示例#9
0
 private void SyncFightInfo(InBattleRuntimeInfo fightInfo)
 {
     if (fightInfo == null)
     {
         PvpStateBase.LogState("no fight info");
         this.TryStartOberving();
         return;
     }
     if (fightInfo.roomState == 3)
     {
         Singleton <PvpManager> .Instance.AbandonGame(PvpErrorCode.StateError);
     }
     else
     {
         PvpProtocolTools.SyncFightInfo(fightInfo);
         this.TryStartOberving();
     }
 }
示例#10
0
        private void SyncFightInfo(InBattleRuntimeInfo fightInfo)
        {
            if (Singleton <PvpManager> .Instance.LoadStatus != LoadSceneStatus.Finished)
            {
                return;
            }
            if (fightInfo == null)
            {
                this.TryStartObserving();
                PvpStateBase.LogState("no fight info");
                return;
            }
            RoomState roomState = (RoomState)fightInfo.roomState;

            PvpStateBase.LogState("roomstate " + roomState);
            switch (roomState)
            {
            case RoomState.Wait:
                this.TryStartObserving();
                break;

            case RoomState.Fighting:
            case RoomState.LogicStart:
                PvpProtocolTools.SyncFightInfo(fightInfo);
                this.TryStartObserving();
                PvpStateManager.Instance.ChangeState(new PvpStateStart(PvpStateCode.PvpStart));
                break;

            case RoomState.End:
                Singleton <PvpManager> .Instance.AbandonGame(PvpErrorCode.StateError);

                break;

            default:
                ClientLogger.Assert(false, "unknown roomstate " + roomState);
                break;
            }
        }
示例#11
0
 protected override void OnAfterLoadOk(InBattleRuntimeInfo info)
 {
     this.SyncFightInfo(info);
     Singleton <PvpManager> .Instance.GameStartTime = new DateTime?(DateTime.Now);
     FrameSyncManager.Instance.ResetInfoOnOnBattleStart();
 }
示例#12
0
 protected virtual void OnAfterLoadOk(InBattleRuntimeInfo info)
 {
 }