private void CheckNpcOwnerId(NpcInfo info) { if (null == info) { return; } if (info.OwnerId > 0) { Room room = GetRoom(); if (null != room && null != room.GetActiveScene()) { int new_owner_id = 0; bool is_online = false; foreach (User v in room.RoomUsers) { if (null != v.Info && v.UserControlState != (int)UserControlState.UserDropped && v.UserControlState != (int)UserControlState.Remove) { new_owner_id = v.Info.GetId(); if (new_owner_id == info.OwnerId) { is_online = true; break; } } } if (!is_online) { info.OwnerId = new_owner_id; Msg_RC_SyncNpcOwnerId builder = DataSyncUtility.BuildSyncNpcOwnerIdMessage(info); NotifyAreaUser(info, builder, false); } } } }
private void OnUserPropertyChanged(UserInfo user) { Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(user); Scene scene = user.SceneContext.CustomData as Scene; if (null != scene) { scene.NotifyAllUser(propBuilder); } }
private void ReleaseControl(UserInfo user) { if (null != user.ControlledObject) { int controller = user.GetId(); int controlled = user.ControlledObject.GetId(); CharacterInfo.ReleaseControlObject(user, user.ControlledObject); Msg_RC_ControlObject builder = DataSyncUtility.BuildControlObjectMessage(controller, controlled, false); NotifyAllUser(builder); } }
private void ReleaseControl(NpcInfo npc) { if (null != npc.ControllerObject) { int controller = npc.ControllerObject.GetId(); int controlled = npc.GetId(); CharacterInfo.ReleaseControlObject(npc.ControllerObject, npc); Msg_RC_ControlObject builder = DataSyncUtility.BuildControlObjectMessage(controller, controlled, false); NotifyAllUser(builder); } }
private void OnUserFace(UserInfo user) { Scene scene = user.SceneContext.CustomData as Scene; if (null != scene) { Msg_RC_UserFace userFaceBuilder = DataSyncUtility.BuildUserFaceMessage(user); if (null != userFaceBuilder) { scene.NotifyAreaUser(user, userFaceBuilder, false); } } }
private void OnNpcTargetChange(NpcInfo npc) { Scene scene = npc.SceneContext.CustomData as Scene; if (null != scene) { Msg_RC_NpcTarget npcTargetBuilder = DataSyncUtility.BuildNpcTargetMessage(npc); if (null != npcTargetBuilder) { scene.NotifyAreaUser(npc, npcTargetBuilder); } } }
private void OnNpcMove(NpcInfo npc) { Scene scene = npc.SceneContext.CustomData as Scene; if (null != scene && !npc.GetMovementStateInfo().IsSkillMoving) { Msg_RC_NpcMove npcMoveBuilder = DataSyncUtility.BuildNpcMoveMessage(npc); if (null != npcMoveBuilder) { scene.NotifyAreaUser(npc, npcMoveBuilder); } } }
internal void OnUserRevive(Msg_LR_UserReLive msg) { User user = m_Room.GetUserByGuid(msg.UserGuid); if (null != user) { UserInfo info = user.Info; info.SetHp(Operate_Type.OT_Absolute, info.GetActualProperty().HpMax); info.SetEnergy(Operate_Type.OT_Absolute, info.GetActualProperty().EnergyMax); info.DeadTime = 0; DataSyncUtility.SyncUserPropertyToCaredUsers(info); DataSyncUtility.SyncUserReliveToCaredUsers(info); } }
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); } } }
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; } } } }
private void DropNpc(Vector3 pos, int money, string model, string particle) { //给每个玩家掉落一个 Data_Unit unit = new Data_Unit(); unit.m_Id = -1; unit.m_LinkId = 100001; unit.m_AiLogic = (int)AiStateLogicId.DropOut_AutoPick; unit.m_RotAngle = 0; for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next) { UserInfo userInfo = linkNode.Value; if (null != userInfo) { float x = CrossEngineHelper.Random.NextFloat() * 4 - 2; float z = CrossEngineHelper.Random.NextFloat() * 4 - 2; pos.X += x; pos.Z += z; NpcInfo npcInfo = NpcManager.AddNpc(unit); npcInfo.GetMovementStateInfo().SetPosition(pos); npcInfo.GetMovementStateInfo().SetFaceDir(0); npcInfo.GetMovementStateInfo().IsMoving = false; npcInfo.SetAIEnable(true); npcInfo.SetCampId((int)CampIdEnum.Friendly); npcInfo.OwnerId = userInfo.GetId(); npcInfo.DropMoney = money; DropOutInfo dropInfo = new DropOutInfo(); dropInfo.DropType = DropOutType.GOLD; dropInfo.Value = money; dropInfo.Model = model; dropInfo.Particle = particle; npcInfo.GetAiStateInfo().AiDatas.AddData <DropOutInfo>(dropInfo); npcInfo.SetModel(dropInfo.Model); User us = userInfo.CustomData as User; if (null != us) { Msg_RC_CreateNpc builder = DataSyncUtility.BuildCreateNpcMessage(npcInfo); us.SendMessage(builder); } } } }
private void NpcEnterCampSight(NpcInfo npc, int campid) { Msg_RC_NpcEnter bder = DataSyncUtility.BuildNpcEnterMessage(npc); NotifyCampUsers(campid, bder); Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(npc); NotifyCampUsers(campid, propBuilder); Msg_RC_NpcMove npcMoveBuilder = DataSyncUtility.BuildNpcMoveMessage(npc); NotifyCampUsers(campid, npcMoveBuilder); Msg_RC_NpcTarget npcFaceTargetBuilder = DataSyncUtility.BuildNpcTargetMessage(npc); if (npcFaceTargetBuilder != null) { NotifyCampUsers(campid, npcFaceTargetBuilder); } }
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 UserEnterCampSight(UserInfo enter_user_info, int campid) { User enter_user = enter_user_info.CustomData as User; if (enter_user == null) { return; } IList <UserInfo> camp_users = m_SightManager.GetCampUsers(campid); foreach (UserInfo user_info in camp_users) { User user = user_info.CustomData as User; if (user == null) { continue; } if (enter_user_info.GetId() != user_info.GetId()) { user.AddICareUser(enter_user); //send message Vector3 enter_user_pos = enter_user_info.GetMovementStateInfo().GetPosition3D(); ArkCrossEngineMessage.Position pos_bd0 = new ArkCrossEngineMessage.Position(); pos_bd0.x = enter_user_pos.X; pos_bd0.z = enter_user_pos.Z; Msg_RC_Enter bder = new Msg_RC_Enter(); bder.role_id = enter_user.RoleId; bder.hero_id = enter_user.HeroId; bder.camp_id = enter_user.CampId; bder.position = pos_bd0; bder.face_dir = (float)enter_user_info.GetMovementStateInfo().GetFaceDir(); bder.is_moving = enter_user_info.GetMovementStateInfo().IsMoving; bder.move_dir = (float)enter_user_info.GetMovementStateInfo().GetMoveDir(); user.SendMessage(bder); Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(enter_user_info); user.SendMessage(propBuilder); DataSyncUtility.SyncBuffListToUser(enter_user_info, user); } } }
internal void DropNpc(int ownerId, int fromNpcId, DropOutType dropType, string model, string particle, int num) { if (ownerId > 0) { UserInfo user = UserManager.GetUserInfo(ownerId); if (null == user) { NpcInfo npc = NpcManager.GetNpcInfo(ownerId); while (null != npc) { user = UserManager.GetUserInfo(npc.OwnerId); if (null != user) { break; } else { npc = NpcManager.GetNpcInfo(npc.OwnerId); } } } if (null != user) { Data_Unit unit = new Data_Unit(); unit.m_Id = -1; switch (dropType) { case DropOutType.GOLD: unit.m_LinkId = (int)DropNpcTypeEnum.GOLD; break; case DropOutType.HP: unit.m_LinkId = (int)DropNpcTypeEnum.HP; break; case DropOutType.MP: unit.m_LinkId = (int)DropNpcTypeEnum.MP; break; case DropOutType.MULT_GOLD: unit.m_LinkId = (int)DropNpcTypeEnum.MUTI_GOLD; break; } unit.m_RotAngle = 0; NpcInfo npcInfo = NpcManager.AddNpc(unit); npcInfo.GetMovementStateInfo().SetFaceDir(0); npcInfo.GetMovementStateInfo().IsMoving = false; npcInfo.SetAIEnable(true); npcInfo.SetCampId(user.GetCampId()); npcInfo.OwnerId = user.GetId(); DropOutInfo dropInfo = new DropOutInfo(); dropInfo.DropType = dropType; dropInfo.Value = num; dropInfo.Model = model; dropInfo.Particle = particle; npcInfo.GetAiStateInfo().AiDatas.AddData <DropOutInfo>(dropInfo); npcInfo.SetModel(dropInfo.Model); User us = user.CustomData as User; if (null != us) { Msg_RC_DropNpc builder = DataSyncUtility.BuildDropNpcMessage(npcInfo, fromNpcId, (int)dropType, num, model); us.SendMessage(builder); } } } else { int ct = UserManager.Users.Count; int rd = CrossEngineHelper.Random.Next(0, ct); UserInfo user = null; if (UserManager.Users.TryGetValue(rd, out user)) { Data_Unit unit = new Data_Unit(); unit.m_Id = -1; switch (dropType) { case DropOutType.GOLD: unit.m_LinkId = (int)DropNpcTypeEnum.GOLD; break; case DropOutType.HP: unit.m_LinkId = (int)DropNpcTypeEnum.HP; break; case DropOutType.MP: unit.m_LinkId = (int)DropNpcTypeEnum.MP; break; case DropOutType.MULT_GOLD: unit.m_LinkId = (int)DropNpcTypeEnum.MUTI_GOLD; break; } unit.m_RotAngle = 0; NpcInfo npcInfo = NpcManager.AddNpc(unit); npcInfo.GetMovementStateInfo().SetFaceDir(0); npcInfo.GetMovementStateInfo().IsMoving = false; npcInfo.SetAIEnable(true); npcInfo.SetCampId(user.GetCampId()); npcInfo.OwnerId = user.GetId(); DropOutInfo dropInfo = new DropOutInfo(); dropInfo.DropType = dropType; dropInfo.Value = num; dropInfo.Model = model; dropInfo.Particle = particle; npcInfo.GetAiStateInfo().AiDatas.AddData <DropOutInfo>(dropInfo); npcInfo.SetModel(dropInfo.Model); User us = user.CustomData as User; if (null != us) { Msg_RC_DropNpc builder = DataSyncUtility.BuildDropNpcMessage(npcInfo, fromNpcId, (int)dropType, num, model); us.SendMessage(builder); } } } }
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); } } }
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 TickRecover() { float hp_coefficient = 1.0f; float mp_coefficient = 1.0f; Data_SceneConfig scene_data = SceneConfigProvider.Instance.GetSceneConfigById(m_SceneResId); if (null != scene_data) { hp_coefficient = scene_data.m_RecoverHpCoefficient; mp_coefficient = scene_data.m_RecoverMpCoefficient; } for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next) { UserInfo info = linkNode.Value; if (!info.IsDead()) { float hpRecover = info.GetActualProperty().HpRecover *hp_coefficient; float epRecover = info.GetActualProperty().EnergyRecover *mp_coefficient; if (hpRecover > 0.0001) { if (info.Hp + (int)hpRecover >= info.GetActualProperty().HpMax) { info.SetHp(Operate_Type.OT_Absolute, (int)info.GetActualProperty().HpMax); } else { info.SetHp(Operate_Type.OT_Relative, (int)hpRecover); } } if (epRecover > 0.0001) { if (info.Energy + (int)epRecover >= info.GetActualProperty().EnergyMax) { info.SetEnergy(Operate_Type.OT_Absolute, (int)info.GetActualProperty().EnergyMax); } else { info.SetEnergy(Operate_Type.OT_Relative, (int)epRecover); } } if (hpRecover > 0.0001 || epRecover > 0.0001) { Msg_RC_SyncProperty builder = DataSyncUtility.BuildSyncPropertyMessage(info); NotifyAreaUser(info, builder, false); } } } for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next) { NpcInfo info = linkNode.Value; if (!info.IsDead()) { float hpRecover = info.GetActualProperty().HpRecover; float npRecover = info.GetActualProperty().EnergyRecover; if (hpRecover > 0.0001) { if (info.Hp + (int)hpRecover >= info.GetActualProperty().HpMax) { info.SetHp(Operate_Type.OT_Absolute, (int)info.GetActualProperty().HpMax); } else { info.SetHp(Operate_Type.OT_Relative, (int)hpRecover); } } if (npRecover > 0.0001) { if (info.Energy + (int)npRecover >= info.GetActualProperty().EnergyMax) { info.SetEnergy(Operate_Type.OT_Absolute, (int)info.GetActualProperty().EnergyMax); } else { info.SetEnergy(Operate_Type.OT_Relative, (int)npRecover); } } if (hpRecover > 0.0001 || npRecover > 0.0001) { Msg_RC_SyncProperty builder = DataSyncUtility.BuildSyncPropertyMessage(info); NotifyAreaUser(info, builder, false); } } } }
internal void SummonPartner(Msg_CR_SummonPartner msg) { UserInfo userInfo = UserManager.GetUserInfo(msg.obj_id); if (null != userInfo) { // summonpartner PartnerInfo partnerInfo = userInfo.GetPartnerInfo(); if (null != partnerInfo && (TimeUtility.GetServerMilliseconds() - userInfo.LastSummonPartnerTime > partnerInfo.CoolDown || userInfo.LastSummonPartnerTime == 0)) { Data_Unit data = new Data_Unit(); data.m_Id = -1; data.m_LinkId = partnerInfo.LinkId; data.m_CampId = userInfo.GetCampId(); data.m_Pos = userInfo.GetMovementStateInfo().GetPosition3D(); data.m_RotAngle = 0; data.m_AiLogic = partnerInfo.GetAiLogic(); data.m_AiParam[0] = ""; data.m_AiParam[1] = ""; data.m_AiParam[2] = partnerInfo.GetAiParam().ToString(); data.m_IsEnable = true; NpcInfo npc = NpcManager.AddNpc(data); if (null != npc) { AppendAttributeConfig aac = AppendAttributeConfigProvider.Instance.GetDataById(partnerInfo.GetAppendAttrConfigId()); float inheritAttackAttrPercent = partnerInfo.GetInheritAttackAttrPercent(); float inheritDefenceAttrPercent = partnerInfo.GetInheritDefenceAttrPercent(); if (null != aac) { // attack npc.GetBaseProperty().SetAttackBase(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().AttackBase *inheritAttackAttrPercent)); npc.GetBaseProperty().SetFireDamage(Operate_Type.OT_Absolute, userInfo.GetActualProperty().FireDamage *inheritAttackAttrPercent); npc.GetBaseProperty().SetIceDamage(Operate_Type.OT_Absolute, userInfo.GetActualProperty().IceDamage *inheritAttackAttrPercent); npc.GetBaseProperty().SetPoisonDamage(Operate_Type.OT_Absolute, userInfo.GetActualProperty().PoisonDamage *inheritAttackAttrPercent); // defence npc.GetBaseProperty().SetHpMax(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().HpMax *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetEnergyMax(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().EnergyMax *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetADefenceBase(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().ADefenceBase *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetMDefenceBase(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().MDefenceBase *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetFireERD(Operate_Type.OT_Absolute, userInfo.GetActualProperty().FireERD *inheritDefenceAttrPercent); npc.GetBaseProperty().SetIceERD(Operate_Type.OT_Absolute, userInfo.GetActualProperty().IceERD *inheritDefenceAttrPercent); npc.GetBaseProperty().SetPoisonERD(Operate_Type.OT_Absolute, userInfo.GetActualProperty().PoisonERD *inheritDefenceAttrPercent); // reset hp & energy npc.SetHp(Operate_Type.OT_Absolute, npc.GetBaseProperty().HpMax); npc.SetEnergy(Operate_Type.OT_Absolute, npc.GetBaseProperty().EnergyMax); } npc.SetAIEnable(true); npc.GetSkillStateInfo().RemoveAllSkill(); npc.BornTime = TimeUtility.GetServerMilliseconds(); List <int> skillList = partnerInfo.GetSkillList(); if (null != skillList) { for (int i = 0; i < skillList.Count; ++i) { SkillInfo skillInfo = new SkillInfo(skillList[i]); npc.GetSkillStateInfo().AddSkill(skillInfo); } } userInfo.LastSummonPartnerTime = TimeUtility.GetServerMilliseconds(); npc.OwnerId = userInfo.GetId(); userInfo.PartnerId = npc.GetId(); if (partnerInfo.BornSkill > 0) { SkillInfo skillInfo = new SkillInfo(partnerInfo.BornSkill); npc.GetSkillStateInfo().AddSkill(skillInfo); } ArkCrossEngineMessage.Msg_RC_CreateNpc builder = DataSyncUtility.BuildCreateNpcMessage(npc); NotifyAllUser(builder); } } } }
internal void StartSkill(int objId, int skillId) { CharacterInfo obj = CurScene.SceneContext.GetCharacterInfoById(objId); if (null != obj) { SkillInstanceInfo inst = NewSkillInstance(skillId); if (null != inst) { obj.GetSkillStateInfo().SetCurSkillInfo(skillId); SkillInfo skillInfo = obj.GetSkillStateInfo().GetCurSkillInfo(); if (null != skillInfo) { if (MakeSkillCast(obj, skillInfo)) { ArkCrossEngineMessage.Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(obj); Scene scene = obj.SceneContext.CustomData as Scene; if (null != scene) { scene.NotifyAllUser(propBuilder); } } else { skillInfo.m_EnableImpactsToMyself = null; skillInfo.m_EnableImpactsToOther = null; skillInfo.m_LeftEnableMoveCount = 0; skillInfo.m_LeftEnableImpactsToMyself.Clear(); skillInfo.m_LeftEnableImpactsToOther.Clear(); return; } skillInfo.IsSkillActivated = true; m_SkillLogicInfos.Add(new SkillLogicInfo(objId, inst)); SkillLogicInfo logicInfo = m_SkillLogicInfos.Find(info => info.SenderId == objId && info.SkillId == skillId); if (null != logicInfo) { //目前没有与技能释放者相关的分析属性,对每个技能暂时只需要分析一次 if (null == skillInfo.m_EnableImpactsToMyself || null == skillInfo.m_EnableImpactsToOther) { if (!logicInfo.SkillInst.AlreadyAnalyzed) { logicInfo.SkillInst.Analyze(obj); foreach (int skill in logicInfo.SkillInst.SummonNpcSkills) { List <int> impacts = AnalyzeNpcSkills(skill, logicInfo.SkillInst); logicInfo.SkillInst.EnableImpactsToOther.AddRange(impacts); } } skillInfo.m_EnableMoveCount = logicInfo.SkillInst.EnableMoveCount; skillInfo.m_MaxMoveDistance = logicInfo.SkillInst.MaxMoveDelta; skillInfo.m_EnableImpactsToOther = logicInfo.SkillInst.EnableImpactsToOther; skillInfo.m_EnableImpactsToMyself = logicInfo.SkillInst.EnableImpactsToMyself; skillInfo.m_EnableSummonNpcs = logicInfo.SkillInst.SummonNpcs; /* * LogSys.Log(LOG_TYPE.WARN, "Skill {0} EnableMoveCount {1} MaxMoveDistanceSqr {2}\n\tEnableImpactsToOther {3}\n\tEnableImpactsToMyself {4}\n\tSummonNpcSkills {5}", skillId, skillInfo.m_EnableMoveCount, skillInfo.m_MaxMoveDistanceSqr, * string.Join<int>(",", skillInfo.m_EnableImpactsToOther), * string.Join<int>(",", skillInfo.m_EnableImpactsToMyself), * string.Join<int>(",", logicInfo.SkillInst.SummonNpcSkills)); */ } skillInfo.m_LeftEnableMoveCount = skillInfo.m_EnableMoveCount; skillInfo.m_LeftEnableImpactsToMyself.AddRange(skillInfo.m_EnableImpactsToMyself); skillInfo.m_LeftEnableImpactsToOther.Clear(); if (logicInfo.SkillInst.IsSimulate) { obj.GetSkillStateInfo().SimulateEndTime = TimeUtility.GetServerMilliseconds() + logicInfo.SkillInst.MaxSkillLifeTime; } logicInfo.SkillInst.Start(obj); /* * DashFire.LogSystem.Warn("StartSkill {0} {1} EnableMoveCount {2} MaxMoveDistance {3}\n\tEnableImpactsToOther {4}\n\tEnableImpactsToMyself {5}\n\tSummonNpcSkills {6}", objId, skillId, skillInfo.m_LeftEnableMoveCount, skillInfo.m_MaxMoveDistanceSqr, * string.Join<int>(",", skillInfo.m_EnableImpactsToOther), * string.Join<int>(",", skillInfo.m_EnableImpactsToMyself), * string.Join<int>(",", logicInfo.SkillInst.SummonNpcSkills)); */ } } else { LogSystem.Error("{0} StartSkill can't find skill {1}", objId, skillId); } } } else { LogSystem.Debug("not find game obj by id " + objId); } }