Пример #1
0
 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;
             }
         }
     }
 }
Пример #2
0
        private void SyncUserToObservers(User infoUser)
        {
            Room room = GetRoom();

            if (null != infoUser && null != room && null != room.GetActiveScene())
            {
                UserInfo userInfo = infoUser.Info;
                if (null != userInfo)
                {
                    Vector3 pos = userInfo.GetMovementStateInfo().GetPosition3D();

                    ArkCrossEngineMessage.Position pos_bd0 = new ArkCrossEngineMessage.Position();
                    pos_bd0.x = pos.X;
                    pos_bd0.z = pos.Z;
                    Msg_CRC_Create bd0 = new Msg_CRC_Create();
                    bd0.role_id        = infoUser.RoleId;
                    bd0.hero_id        = infoUser.HeroId;
                    bd0.camp_id        = infoUser.CampId;
                    bd0.role_level     = infoUser.Level;
                    bd0.is_player_self = false;
                    bd0.position       = pos_bd0;
                    bd0.face_dirction  = (float)userInfo.GetMovementStateInfo().GetFaceDir();
                    for (int index = 0; index < userInfo.GetSkillStateInfo().GetAllSkill().Count; index++)
                    {
                        bd0.skill_levels.Add(userInfo.GetSkillStateInfo().GetSkillInfoByIndex(index).SkillLevel);
                    }
                    bd0.scene_start_time = StartTime;
                    bd0.nickname         = infoUser.Name;
                    NotifyAllObserver(bd0);

                    DataSyncUtility.SyncBuffListToObservers(userInfo, this);

                    Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(userInfo);
                    NotifyAllObserver(propBuilder);

                    Msg_RC_SyncCombatStatisticInfo combatBuilder = DataSyncUtility.BuildSyncCombatStatisticInfo(userInfo);
                    NotifyAllObserver(combatBuilder);

                    LogSys.Log(LOG_TYPE.DEBUG, "send user {0} msg to observers", infoUser.RoleId);
                }
            }
        }
Пример #3
0
        private void SyncUserToUserHelper(User infoUser, User user, bool isSelf)
        {
            Room room = GetRoom();

            if (null != infoUser && null != user && null != room && null != room.GetActiveScene())
            {
                UserInfo userInfo = infoUser.Info;
                if (null != userInfo)
                {
                    Vector3 pos = userInfo.GetMovementStateInfo().GetPosition3D();
                    ArkCrossEngineMessage.Position pos_bd0 = new ArkCrossEngineMessage.Position();
                    pos_bd0.x = pos.X;
                    pos_bd0.z = pos.Z;
                    Msg_CRC_Create bd0 = new Msg_CRC_Create();
                    bd0.role_id        = infoUser.RoleId;
                    bd0.hero_id        = infoUser.HeroId;
                    bd0.camp_id        = infoUser.CampId;
                    bd0.role_level     = infoUser.Level;
                    bd0.is_player_self = isSelf;
                    bd0.position       = pos_bd0;
                    bd0.face_dirction  = (float)userInfo.GetMovementStateInfo().GetFaceDir();
                    for (int index = 0; index < userInfo.GetSkillStateInfo().GetAllSkill().Count; index++)
                    {
                        bd0.skill_levels.Add(userInfo.GetSkillStateInfo().GetSkillInfoByIndex(index).SkillLevel);
                    }
                    bd0.scene_start_time = StartTime;
                    bd0.nickname         = infoUser.Name;
                    user.SendMessage(bd0);
                    ///
                    if (infoUser.PresetIndex >= 0)
                    {
                        Msg_RC_UpdateUserBattleInfo uusMsg = new Msg_RC_UpdateUserBattleInfo();
                        uusMsg.role_id      = infoUser.Info.GetId();
                        uusMsg.preset_index = infoUser.PresetIndex;
                        for (int i = 0; i < infoUser.Skill.Count; i++)
                        {
                            Msg_RC_UpdateUserBattleInfo.PresetInfo preset_info = new Msg_RC_UpdateUserBattleInfo.PresetInfo();
                            preset_info.skill_id    = infoUser.Skill[i].SkillId;
                            preset_info.skill_level = infoUser.Skill[i].SkillLevel;
                            uusMsg.skill_info.Add(preset_info);
                        }
                        for (int i = 0; i < infoUser.Equip.Count; i++)
                        {
                            Msg_RC_UpdateUserBattleInfo.EquipInfo equip_info = new Msg_RC_UpdateUserBattleInfo.EquipInfo();
                            equip_info.equip_id              = infoUser.Equip[i].ItemId;
                            equip_info.equip_level           = infoUser.Equip[i].ItemLevel;
                            equip_info.equip_random_property = infoUser.Equip[i].ItemRandomProperty;
                            uusMsg.equip_info.Add(equip_info);
                        }
                        for (int i = 0; i < infoUser.Legacy.Count; i++)
                        {
                            Msg_RC_UpdateUserBattleInfo.LegacyInfo legacy_info = new Msg_RC_UpdateUserBattleInfo.LegacyInfo();
                            legacy_info.legacy_id              = infoUser.Legacy[i].ItemId;
                            legacy_info.legacy_level           = infoUser.Legacy[i].ItemLevel;
                            legacy_info.legacy_random_property = infoUser.Legacy[i].ItemRandomProperty;
                            legacy_info.legacy_IsUnlock        = infoUser.Legacy[i].IsUnlock;
                            uusMsg.legacy_info.Add(legacy_info);
                        }
                        foreach (XSoulPartInfo part in infoUser.XSouls.GetAllXSoulPartData().Values)
                        {
                            Msg_RC_UpdateUserBattleInfo.XSoulDataInfo xsoul_info = new Msg_RC_UpdateUserBattleInfo.XSoulDataInfo();
                            xsoul_info.ItemId     = part.XSoulPartItem.ItemId;
                            xsoul_info.Level      = part.XSoulPartItem.Level;
                            xsoul_info.Experience = part.XSoulPartItem.Experience;
                            xsoul_info.ModelLevel = part.ShowModelLevel;
                            uusMsg.XSouls.Add(xsoul_info);
                        }
                        if (null != infoUser.Partner)
                        {
                            Msg_RC_UpdateUserBattleInfo.PartnerDataInfo partner_info = new Msg_RC_UpdateUserBattleInfo.PartnerDataInfo();
                            partner_info.PartnerId    = infoUser.Partner.Id;
                            partner_info.PartnerLevel = infoUser.Partner.CurAdditionLevel;
                            partner_info.PartnerStage = infoUser.Partner.CurSkillStage;
                            uusMsg.Partners.Add(partner_info);
                        }
                        user.SendMessage(uusMsg);
                    }
                    ///
                    DataSyncUtility.SyncBuffListToUser(userInfo, user);

                    Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(userInfo);
                    user.SendMessage(propBuilder);

                    Msg_RC_SyncCombatStatisticInfo combatBuilder = DataSyncUtility.BuildSyncCombatStatisticInfo(userInfo);
                    user.SendMessage(combatBuilder);

                    LogSys.Log(LOG_TYPE.DEBUG, "send user {0} msg to user {1}", infoUser.RoleId, user.RoleId);
                }
            }
        }
Пример #4
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);
                }
            }
        }