private void TickArenaLogic()
        {
            if (!IsPvapScene())
            {
                return;
            }
            RoleInfo roleself = LobbyClient.Instance.CurrentRole;

            if (roleself == null)
            {
                return;
            }
            ArenaStateInfo arena_state = roleself.ArenaStateInfo;

            if (arena_state.IsBattleStarted && !arena_state.IsEntityCreated)
            {
                roleself.ArenaStateInfo.IsEntityCreated = true;
                CreatePlayerSelfParters();
                arena_state.TargetInfo = CreateArenaTarget(arena_state.ChallengeTarget);
            }
            if (!arena_state.IsChallengeOver && arena_state.IsBeginFight)
            {
                m_AiSystem.Tick();
            }
            ClientScriptSystem.Instance.Tick();
            CameraChangeCheck(arena_state, roleself);
            OverCheck(arena_state);
            TimeOutCheck(arena_state);
            if (arena_state.IsChallengeOver && arena_state.IsBeginFight)
            {
                arena_state.CheckChallengeResult();
            }
        }
        private void OverCheck(ArenaStateInfo state)
        {
            if (!state.IsBattleStarted || !state.IsEntityCreated)
            {
                return;
            }
            if (state.IsChallengeOver)
            {
                return;
            }
            bool isScuccess = false;

            if (IsPlayerAndPartnerAllDead(GetPlayerSelf(), state.CreatedPartners))
            {
                isScuccess            = false;
                state.IsChallengeOver = true;
            }
            else if (IsPlayerAndPartnerAllDead(state.TargetInfo, state.ChallengeTarget.CreatedPartners))
            {
                isScuccess            = true;
                state.IsChallengeOver = true;
            }
            if (state.IsChallengeOver)
            {
                state.IsChallengeSuccess = isScuccess;
                ClientScriptSystem.Instance.SendMessage("onenemykilled");
                //LobbyNetworkSystem.Instance.OnChallengeOver(isScuccess);
            }
        }
 private void TimeOutCheck(ArenaStateInfo state)
 {
     if (state.IsChallengeOver || !state.IsBeginFight)
     {
         return;
     }
     if (DateTime.Now >= state.EndFightLocalTime)
     {
         state.IsChallengeOver    = true;
         state.IsChallengeSuccess = false;
         ClientScriptSystem.Instance.SendMessage("timeout");
     }
 }
        private void ChangeCameraToPartner(ArenaStateInfo state)
        {
            NpcInfo not_dead_partner = FindNotdeadPartner(state.CreatedPartners);

            if (not_dead_partner != null)
            {
                NpcView view = EntityManager.Instance.GetNpcViewById(not_dead_partner.GetId());
                if (view != null)
                {
                    GfxSystem.SendMessage("GfxGameRoot", "CameraFollow", view.Actor);
                    state.CurCameraTargetPartner = not_dead_partner.GetId();
                }
            }
        }
        private void SetArenaCharacterCoefficient(CharacterInfo character)
        {
            ArenaStateInfo state = LobbyClient.Instance.CurrentRole.ArenaStateInfo;

            if (GetPlayerSelf() == null || state == null || state.ChallengeTarget == null)
            {
                return;
            }
            int level_self   = GetPlayerSelf().GetLevel();
            int level_target = state.ChallengeTarget.Level;

            character.HpMaxCoefficient     = CalcPvpCoefficient(level_self, level_target);
            character.EnergyMaxCoefficient = character.HpMaxCoefficient;
        }
 private void CameraChangeCheck(ArenaStateInfo state, RoleInfo self)
 {
     if (state.IsChallengeOver)
     {
         return;
     }
     if (self.GetPlayerSelfInfo().IsDead() && state.CurCameraTargetPartner == -1)
     {
         ChangeCameraToPartner(state);
     }
     if (state.CurCameraTargetPartner >= 0)
     {
         CharacterInfo npc = WorldSystem.Instance.GetCharacterById(state.CurCameraTargetPartner);
         if (npc != null && npc.IsDead())
         {
             ChangeCameraToPartner(state);
         }
     }
 }