private void TickUsers() { for (LinkedListNode <UserInfo> linkNode = m_UserMgr.Users.FirstValue; null != linkNode; linkNode = linkNode.Next) { UserInfo info = linkNode.Value; if (info.LevelChanged || info.GetShootStateInfo().WeaponChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged) { LogSystem.Debug("UserAttrCalculate LevelChanged:{0} WeaponChanged:{1} BuffChanged:{2} EquipmentChanged:{3}", info.LevelChanged, info.GetShootStateInfo().WeaponChanged, info.GetSkillStateInfo().BuffChanged, info.GetEquipmentStateInfo().EquipmentChanged); UserAttrCalculator.Calc(info); info.LevelChanged = false; info.GetShootStateInfo().WeaponChanged = false; info.GetSkillStateInfo().BuffChanged = false; info.GetEquipmentStateInfo().EquipmentChanged = false; } } UserInfo player = WorldSystem.Instance.GetPlayerSelf(); if (null != player && player.Hp <= 0) { if (player.DeadTime <= 0) { GfxSystem.PublishGfxEvent("ge_show_relive", "ui", null); player.DeadTime = TimeUtility.GetServerMilliseconds(); } } }
private void OnUserSkill(UserInfo user, int skillId) { Scene scene = user.SceneContext.CustomData as Scene; if (null != scene) { SkillInfo skillInfo = user.GetSkillStateInfo().GetCurSkillInfo(); if (null == skillInfo || !skillInfo.IsSkillActivated) { scene.SkillSystem.StartSkill(user.GetId(), skillId); Msg_CRC_Skill skillBuilder = new Msg_CRC_Skill(); skillBuilder.role_id = user.GetId(); skillBuilder.skill_id = skillId; ArkCrossEngineMessage.Position posBuilder1 = new ArkCrossEngineMessage.Position(); posBuilder1.x = user.GetMovementStateInfo().GetPosition3D().X; posBuilder1.z = user.GetMovementStateInfo().GetPosition3D().Z; skillBuilder.stand_pos = posBuilder1; skillBuilder.face_direction = (float)user.GetMovementStateInfo().GetFaceDir(); skillBuilder.want_face_dir = (float)user.GetMovementStateInfo().GetFaceDir(); LogSystem.Debug("Send Msg_CRC_Skill, EntityId={0}, SkillId={1}", user.GetId(), skillId); scene.NotifyAreaUser(user, skillBuilder, false); } } }
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); } } }
private void RefreshItemSkills(UserInfo user) { user.RefreshItemSkills((int id) => { return(user.GetSkillStateInfo().GetImpactInfoById(id)); }, (int id) => { }); Msg_RC_RefreshItemSkills builder = new Msg_RC_RefreshItemSkills(); builder.role_id = user.GetId(); NotifyAllUser(builder); }
private void OnUserStopSkill(UserInfo user) { Scene scene = user.SceneContext.CustomData as Scene; if (null != scene) { SkillInfo skillInfo = user.GetSkillStateInfo().GetCurSkillInfo(); if (null == skillInfo || skillInfo.IsSkillActivated) { scene.SkillSystem.StopSkill(user.GetId()); } Msg_CRC_StopSkill skillBuilder = new Msg_CRC_StopSkill(); skillBuilder.role_id = user.GetId(); LogSystem.Debug("Send Msg_CRC_StopSkill, EntityId={0}", user.GetId()); scene.NotifyAreaUser(user, skillBuilder, false); } }
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); } } }
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); * } */ } } } }
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); } } }