Exemple #1
0
        private void CalcPvpCombatInfo(int killerLinkId, int killedLinkId, string killerNickname, string killedNickname)
        {
            int totalKillCountForBlue = 0;
            int totalKillCountForRed  = 0;

            for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                UserInfo user = linkNode.Value;
                if (user.GetCampId() == (int)CampIdEnum.Blue)
                {
                    totalKillCountForBlue += user.GetCombatStatisticInfo().KillHeroCount;
                }
                else
                {
                    totalKillCountForRed += user.GetCombatStatisticInfo().KillHeroCount;
                }
            }

            Msg_RC_PvpCombatInfo builder = new Msg_RC_PvpCombatInfo();

            builder.kill_hero_count_for_blue = totalKillCountForBlue;
            builder.kill_hero_count_for_red  = totalKillCountForRed;
            builder.link_id_for_killer       = killerLinkId;
            builder.link_id_for_killed       = killedLinkId;
            builder.killer_nickname          = killerNickname;
            builder.killed_nickname          = killedNickname;

            NotifyAllUser(builder);
        }
Exemple #2
0
        private void CalcKillIncome(UserInfo user)
        {
            long curTime = TimeUtility.GetServerMilliseconds();

            if (m_IsPvpScene)
            {
                int lvl2 = user.GetLevel();
                int lvl1 = lvl2 - 1;
                if (lvl1 < 0)
                {
                    lvl1 = 0;
                }
                PlayerLevelupExpConfig cfg1 = PlayerConfigProvider.Instance.GetPlayerLevelupExpConfigById(lvl1);
                PlayerLevelupExpConfig cfg2 = PlayerConfigProvider.Instance.GetPlayerLevelupExpConfigById(lvl2);
                if (null != cfg1 && null != cfg2)
                {
                    int      exp    = (cfg2.m_ConsumeExp - cfg1.m_ConsumeExp) * 70 / 100;
                    UserInfo killer = UserManager.GetUserInfo(user.KillerId);
                    if (null != killer)
                    {
                        //被英雄击杀连杀数清0
                        user.GetCombatStatisticInfo().ClearContinueKillCount();
                        //击杀英雄连死数清0
                        killer.GetCombatStatisticInfo().ClearContinueDeadCount();

                        user.GetCombatStatisticInfo().AddContinueDeadCount(1);
                        killer.GetCombatStatisticInfo().AddContinueKillCount(1);

                        killer.GetCombatStatisticInfo().AddKillHeroCount(1);
                        if (killer.GetCombatStatisticInfo().LastKillHeroTime + 10000 < curTime)
                        {
                            killer.GetCombatStatisticInfo().ClearMultiKillCount();
                        }
                        killer.GetCombatStatisticInfo().AddMultiKillCount(1);
                        killer.GetCombatStatisticInfo().LastKillHeroTime = curTime;

                        User us       = killer.CustomData as User;
                        User killedUs = user.CustomData as User;
                        if (us != null && killedUs != null)
                        {
                            CalcPvpCombatInfo(killer.GetLinkId(), user.GetLinkId(), us.Name, killedUs.Name);
                        }
                        if (user.AttackerInfos.Count > 0)
                        {
                            foreach (int id in user.AttackerInfos.Keys)
                            {
                                UserInfo assit = UserManager.GetUserInfo(id);
                                CharacterInfo.AttackerInfo attackInfo = user.AttackerInfos[id];
                                if (null != assit && killer != assit && attackInfo.m_AttackTime + 5000 >= curTime)
                                {
                                    assit.GetCombatStatisticInfo().AddAssitKillCount(1);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
        private void SyncSceneObjectsToUser(User user)
        {
            if (null != user)
            {
                UserInfo userInfo = user.Info;
                Room     room     = GetRoom();
                if (null != userInfo && null != room && null != room.GetActiveScene())
                {
                    for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
                    {
                        NpcInfo npc = linkNode.Value;
                        if (null != npc)
                        {
                            Msg_RC_CreateNpc bder = DataSyncUtility.BuildCreateNpcMessage(npc);
                            if (npc.AppendAttrId > 0)
                            {
                                bder.add_attr_id = npc.AppendAttrId;
                            }
                            user.SendMessage(bder);
                        }
                    }

                    int totalKillCountForBlue = 0;
                    int totalKillCountForRed  = 0;
                    for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
                    {
                        UserInfo user_info = linkNode.Value;
                        if (user_info.GetCampId() == (int)CampIdEnum.Blue)
                        {
                            totalKillCountForBlue += user_info.GetCombatStatisticInfo().KillHeroCount;
                        }
                        else
                        {
                            totalKillCountForRed += user_info.GetCombatStatisticInfo().KillHeroCount;
                        }
                    }

                    Msg_RC_PvpCombatInfo combat_bd = new Msg_RC_PvpCombatInfo();
                    combat_bd.kill_hero_count_for_blue = totalKillCountForBlue;
                    combat_bd.kill_hero_count_for_red  = totalKillCountForRed;
                    combat_bd.link_id_for_killer       = -1;
                    combat_bd.link_id_for_killed       = -1;
                    combat_bd.killed_nickname          = "";
                    combat_bd.killer_nickname          = "";
                    user.SendMessage(combat_bd);
                }
            }
        }
Exemple #4
0
        internal static void Execute(object msg, User user)
        {
            Msg_CR_HitCountChanged hitCountMsg = msg as Msg_CR_HitCountChanged;

            if (null == hitCountMsg)
            {
                return;
            }
            UserInfo us = user.Info;

            if (null != us)
            {
                us.GetCombatStatisticInfo().MaxMultiHitCount = hitCountMsg.max_multi_hit_count;
                us.GetCombatStatisticInfo().HitCount         = hitCountMsg.hit_count;
            }
        }
 private void TickLevelup()
 {
     for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
     {
         UserInfo info = linkNode.Value;
         if (!info.IsDead())
         {
             if (info.GetCombatStatisticInfo().DataChanged)
             {
                 Msg_RC_SyncCombatStatisticInfo combatBuilder = DataSyncUtility.BuildSyncCombatStatisticInfo(info);
                 NotifyAllUser(combatBuilder);
                 info.GetCombatStatisticInfo().DataChanged = false;
             }
         }
     }
 }
Exemple #6
0
        internal static Msg_RC_SyncCombatStatisticInfo BuildSyncCombatStatisticInfo(UserInfo user)
        {
            Msg_RC_SyncCombatStatisticInfo builder = new Msg_RC_SyncCombatStatisticInfo();
            CombatStatisticInfo            info    = user.GetCombatStatisticInfo();

            builder.role_id          = user.GetId();
            builder.kill_hero_count  = info.KillHeroCount;
            builder.assit_kill_count = info.AssitKillCount;
            builder.kill_npc_count   = info.KillNpcCount;
            builder.dead_count       = info.DeadCount;
            return(builder);
        }
Exemple #7
0
        private static void UpdateCharacterHitCount(CharacterInfo character, int hit_count)
        {
            UserInfo user = character as UserInfo;

            if (user == null)
            {
                return;
            }
            CombatStatisticInfo combat_info = user.GetCombatStatisticInfo();

            combat_info.MultiHitCount = hit_count;
            combat_info.LastHitTime   = TimeUtility.GetServerMilliseconds();
        }
Exemple #8
0
        private void UpdateKillCount(NpcInfo npc)
        {
            if (null == npc)
            {
                return;
            }
            UserInfo killer = null;
            UserInfo user   = UserManager.GetUserInfo(npc.KillerId);

            if (null != user)
            {
                killer = user;
            }
            else
            {
                NpcInfo parter = NpcManager.GetNpcInfo(npc.KillerId);
                if (null != parter && parter.OwnerId > 0)
                {
                    killer = UserManager.GetUserInfo(parter.OwnerId);
                }
            }
            if (null != killer)
            {
                if (m_IsAttemptScene)
                {
                    if ((int)NpcTypeEnum.BigBoss == npc.NpcType)
                    {
                        killer.GetCombatStatisticInfo().AddKillNpcCount(1);
                    }
                }
                else
                {
                    killer.GetCombatStatisticInfo().AddKillNpcCount(1);
                }
            }
        }
        private void TickUsers()
        {
            for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                UserInfo info = linkNode.Value;
                if (info.GetEquipmentStateInfo().EquipmentChanged)
                {
                    RefreshItemSkills(info);
                }
                if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged || info.GetLegacyStateInfo().LegacyChanged)
                {
                    UserAttrCalculator.Calc(info);
                    info.LevelChanged = false;
                    info.GetSkillStateInfo().BuffChanged          = false;
                    info.GetEquipmentStateInfo().EquipmentChanged = false;
                    info.GetLegacyStateInfo().LegacyChanged       = false;
                }
                if (info.Hp <= 0)
                {
                    if (info.DeadTime <= 0)
                    {
                        //计算击杀收益
                        CalcKillIncome(info);
                        info.GetCombatStatisticInfo().AddDeadCount(1);  //死亡计数+1
                                                                        //解除控制
                        ReleaseControl(info);
                        //发送玩家死亡消息
                        Msg_RC_Dead build = new Msg_RC_Dead();
                        build.role_id = info.GetId();
                        NotifyAllUser(build);
                        PlayerLevelupExpConfig cfg = PlayerConfigProvider.Instance.GetPlayerLevelupExpConfigById(info.GetLevel());
                        info.SetStateFlag(Operate_Type.OT_AddBit, CharacterState_Type.CST_BODY);

                        m_StorySystem.SendMessage("userkilled", info.GetId(), GetLivingUserCount());

                        TryFireAllUserKilled();
                        NoticeAttempRoomClosing();

                        info.DeadTime = TimeUtility.GetServerMilliseconds();
                        if (null != cfg && m_IsPvpScene)
                        {
                            info.ReviveTime = TimeUtility.GetServerMilliseconds() + cfg.m_RebornTime * 1000;
                        }
                        else
                        {
                            info.ReviveTime = TimeUtility.GetServerMilliseconds() + info.ReleaseTime + 2000;
                        }
                        NpcInfo npc = NpcManager.GetNpcInfo(info.PartnerId);
                        if (null != npc && npc.NpcType == (int)NpcTypeEnum.Partner)
                        {
                            npc.NeedDelete = true;
                        }
                    }
                    else
                    {
                        /*
                         * long delta = TimeUtility.GetServerMilliseconds() - info.DeadTime;
                         * if (delta > info.ReleaseTime) {
                         * info.DeadTime = info.ReviveTime;
                         * Msg_RC_Disappear build = new Msg_RC_Disappear();
                         * build.role_id = info.GetId();
                         * NotifyAllUser(build);
                         * }
                         */
                    }
                }
            }
        }
Exemple #10
0
        internal void SyncForNewObserver(Observer observer)
        {
            if (null != observer)
            {
                Room room = GetRoom();
                if (null != room && null != room.GetActiveScene())
                {
                    //同步其他玩家数据与物品给自己
                    foreach (User other in room.RoomUsers)
                    {
                        if (!other.IsEntered)
                        {
                            continue;
                        }
                        UserInfo otherInfo = other.Info;
                        if (null != otherInfo)
                        {
                            Vector3 pos = otherInfo.GetMovementStateInfo().GetPosition3D();
                            ArkCrossEngineMessage.Position pos_bd = new ArkCrossEngineMessage.Position();
                            pos_bd.x = (float)pos.X;
                            pos_bd.z = (float)pos.Z;
                            Msg_CRC_Create bd = new Msg_CRC_Create();
                            bd.role_id        = other.RoleId;
                            bd.hero_id        = other.HeroId;
                            bd.camp_id        = other.CampId;
                            bd.role_level     = other.Level;
                            bd.is_player_self = false;
                            bd.position       = pos_bd;
                            bd.face_dirction  = (float)otherInfo.GetMovementStateInfo().GetFaceDir();
                            for (int index = 0; index < otherInfo.GetSkillStateInfo().GetAllSkill().Count; index++)
                            {
                                bd.skill_levels.Add(otherInfo.GetSkillStateInfo().GetSkillInfoByIndex(index).SkillLevel);
                            }
                            bd.scene_start_time = StartTime;
                            bd.nickname         = other.Name;
                            observer.SendMessage(bd);

                            DataSyncUtility.SyncBuffListToObserver(otherInfo, observer);

                            Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(otherInfo);
                            observer.SendMessage(propBuilder);

                            Msg_RC_SyncCombatStatisticInfo combatBuilder = DataSyncUtility.BuildSyncCombatStatisticInfo(otherInfo);
                            observer.SendMessage(combatBuilder);

                            LogSys.Log(LOG_TYPE.DEBUG, "send user {0} msg to observer {1}", other.RoleId, observer.Guid);
                        }
                    }
                    //同步场景数据给观察者
                    for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
                    {
                        NpcInfo npc = linkNode.Value;
                        if (null != npc)
                        {
                            Msg_RC_CreateNpc bder = DataSyncUtility.BuildCreateNpcMessage(npc);
                            observer.SendMessage(bder);
                        }
                    }

                    int totalKillCountForBlue = 0;
                    int totalKillCountForRed  = 0;
                    for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
                    {
                        UserInfo user_info = linkNode.Value;
                        if (user_info.GetCampId() == (int)CampIdEnum.Blue)
                        {
                            totalKillCountForBlue += user_info.GetCombatStatisticInfo().KillHeroCount;
                        }
                        else
                        {
                            totalKillCountForRed += user_info.GetCombatStatisticInfo().KillHeroCount;
                        }
                    }

                    Msg_RC_PvpCombatInfo combat_bd = new Msg_RC_PvpCombatInfo();
                    combat_bd.kill_hero_count_for_blue = totalKillCountForBlue;
                    combat_bd.kill_hero_count_for_red  = totalKillCountForRed;
                    combat_bd.link_id_for_killer       = -1;
                    combat_bd.link_id_for_killed       = -1;
                    combat_bd.killed_nickname          = "";
                    combat_bd.killer_nickname          = "";
                    observer.SendMessage(combat_bd);
                }
            }
        }