public void SetItemData(int index, ItemDataInfo info) { if (index >= 0 && index < c_PackageCapacity) { m_ItemData[index] = info; m_EquipmentChanged = true; } }
public ItemDataInfo GetItemData(int index) { ItemDataInfo info = null; if (index >= 0 && index < c_PackageCapacity) { info = m_ItemData[index]; } return(info); }
public int FindEmptyPos() { int pos = -1; for (int ix = 0; ix < c_PackageCapacity; ++ix) { ItemDataInfo info = m_ItemData[ix]; if (null == info) { pos = ix; break; } } return(pos); }
public int FindItemPos(int itemId, int startIndex) { int pos = -1; if (startIndex >= 0 && startIndex < c_PackageCapacity) { for (int ix = startIndex; ix < c_PackageCapacity; ++ix) { ItemDataInfo info = m_ItemData[ix]; if (null != info && info.ItemId == itemId) { pos = ix; break; } } } return(pos); }
public static void RefixAttrByEquipment(CharacterInfo obj) { //装备不会有百分比属性加成,所以不需要考虑当前值 //计算武器影响 int index = obj.GetShootStateInfo().CurrentWeaponIndex; if (index >= 0 && index < EquipmentInfo.c_MaxWeaponNum) { EquipmentDataInfo info = obj.GetEquipmentStateInfo().EquipmentInfo.Weapons[index]; if (null != info) { obj.GetActualProperty().SetMoveSpeed(Operate_Type.OT_Relative, info.GetAddSpd(0, obj.GetLevel())); obj.GetActualProperty().SetHpMax(Operate_Type.OT_Relative, (int)info.GetAddHpMax(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyMax(Operate_Type.OT_Relative, (int)info.GetAddNpMax(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyCoreMax(Operate_Type.OT_Relative, (int)info.GetAddEpMax(0, obj.GetLevel())); obj.GetActualProperty().SetCrgMax(Operate_Type.OT_Relative, (int)info.GetAddCrgMax(0, obj.GetLevel())); obj.GetActualProperty().SetHpRecover(Operate_Type.OT_Relative, info.GetAddHpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyRecover(Operate_Type.OT_Relative, info.GetAddNpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyCoreRecover(Operate_Type.OT_Relative, info.GetAddEpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetAttackBase(Operate_Type.OT_Relative, (int)info.GetAddAd(0, obj.GetLevel())); obj.GetActualProperty().SetDefenceBase(Operate_Type.OT_Relative, (int)info.GetAddDp(0, obj.GetLevel())); obj.GetActualProperty().SetCritical(Operate_Type.OT_Relative, info.GetAddCri(0, obj.GetLevel())); obj.GetActualProperty().SetCriticalPow(Operate_Type.OT_Relative, info.GetAddPow(0, obj.GetLevel())); obj.GetActualProperty().SetArmorPenetration(Operate_Type.OT_Relative, info.GetAddAndp(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyIntensity(Operate_Type.OT_Relative, info.GetAddAp(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyArmor(Operate_Type.OT_Relative, info.GetAddTay(0, obj.GetLevel())); obj.GetActualProperty().SetAttackRange(Operate_Type.OT_Relative, info.GetAddRange(0, obj.GetLevel())); obj.GetActualProperty().SetRps(Operate_Type.OT_Relative, info.GetAddRps(0, obj.GetLevel())); obj.GetActualProperty().SetCrg(Operate_Type.OT_Relative, (int)info.GetAddCrg(0, obj.GetLevel())); obj.GetActualProperty().SetCht(Operate_Type.OT_Relative, info.GetAddCht(0, obj.GetLevel())); obj.GetActualProperty().SetWdps(Operate_Type.OT_Relative, info.GetAddDps(0, obj.GetLevel())); obj.GetActualProperty().SetDamRange(Operate_Type.OT_Relative, info.GetAddDamRange(0, obj.GetLevel())); } } //计算防弹衣与挂件的影响 { EquipmentDataInfo info = obj.GetEquipmentStateInfo().EquipmentInfo.BodyArmor; if (null != info) { obj.GetActualProperty().SetMoveSpeed(Operate_Type.OT_Relative, info.GetAddSpd(0, obj.GetLevel())); obj.GetActualProperty().SetHpMax(Operate_Type.OT_Relative, (int)info.GetAddHpMax(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyMax(Operate_Type.OT_Relative, (int)info.GetAddNpMax(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyCoreMax(Operate_Type.OT_Relative, (int)info.GetAddEpMax(0, obj.GetLevel())); obj.GetActualProperty().SetCrgMax(Operate_Type.OT_Relative, (int)info.GetAddCrgMax(0, obj.GetLevel())); obj.GetActualProperty().SetHpRecover(Operate_Type.OT_Relative, (int)info.GetAddHpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyRecover(Operate_Type.OT_Relative, info.GetAddNpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyCoreRecover(Operate_Type.OT_Relative, info.GetAddEpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetAttackBase(Operate_Type.OT_Relative, (int)info.GetAddAd(0, obj.GetLevel())); obj.GetActualProperty().SetDefenceBase(Operate_Type.OT_Relative, (int)info.GetAddDp(0, obj.GetLevel())); obj.GetActualProperty().SetCritical(Operate_Type.OT_Relative, info.GetAddCri(0, obj.GetLevel())); obj.GetActualProperty().SetCriticalPow(Operate_Type.OT_Relative, info.GetAddPow(0, obj.GetLevel())); obj.GetActualProperty().SetArmorPenetration(Operate_Type.OT_Relative, info.GetAddAndp(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyIntensity(Operate_Type.OT_Relative, info.GetAddAp(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyArmor(Operate_Type.OT_Relative, info.GetAddTay(0, obj.GetLevel())); obj.GetActualProperty().SetAttackRange(Operate_Type.OT_Relative, info.GetAddRange(0, obj.GetLevel())); obj.GetActualProperty().SetRps(Operate_Type.OT_Relative, info.GetAddRps(0, obj.GetLevel())); obj.GetActualProperty().SetCrg(Operate_Type.OT_Relative, (int)info.GetAddCrg(0, obj.GetLevel())); obj.GetActualProperty().SetCht(Operate_Type.OT_Relative, info.GetAddCht(0, obj.GetLevel())); obj.GetActualProperty().SetWdps(Operate_Type.OT_Relative, info.GetAddDps(0, obj.GetLevel())); obj.GetActualProperty().SetDamRange(Operate_Type.OT_Relative, info.GetAddDamRange(0, obj.GetLevel())); } } foreach (EquipmentDataInfo info in obj.GetEquipmentStateInfo().EquipmentInfo.Pendant) { if (null != info) { obj.GetActualProperty().SetMoveSpeed(Operate_Type.OT_Relative, info.GetAddSpd(0, obj.GetLevel())); obj.GetActualProperty().SetHpMax(Operate_Type.OT_Relative, (int)info.GetAddHpMax(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyMax(Operate_Type.OT_Relative, (int)info.GetAddNpMax(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyCoreMax(Operate_Type.OT_Relative, (int)info.GetAddEpMax(0, obj.GetLevel())); obj.GetActualProperty().SetCrgMax(Operate_Type.OT_Relative, (int)info.GetAddCrgMax(0, obj.GetLevel())); obj.GetActualProperty().SetHpRecover(Operate_Type.OT_Relative, (int)info.GetAddHpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyRecover(Operate_Type.OT_Relative, info.GetAddNpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyCoreRecover(Operate_Type.OT_Relative, info.GetAddEpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetAttackBase(Operate_Type.OT_Relative, (int)info.GetAddAd(0, obj.GetLevel())); obj.GetActualProperty().SetDefenceBase(Operate_Type.OT_Relative, (int)info.GetAddDp(0, obj.GetLevel())); obj.GetActualProperty().SetCritical(Operate_Type.OT_Relative, info.GetAddCri(0, obj.GetLevel())); obj.GetActualProperty().SetCriticalPow(Operate_Type.OT_Relative, info.GetAddPow(0, obj.GetLevel())); obj.GetActualProperty().SetArmorPenetration(Operate_Type.OT_Relative, info.GetAddAndp(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyIntensity(Operate_Type.OT_Relative, info.GetAddAp(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyArmor(Operate_Type.OT_Relative, info.GetAddTay(0, obj.GetLevel())); obj.GetActualProperty().SetAttackRange(Operate_Type.OT_Relative, info.GetAddRange(0, obj.GetLevel())); obj.GetActualProperty().SetRps(Operate_Type.OT_Relative, info.GetAddRps(0, obj.GetLevel())); obj.GetActualProperty().SetCrg(Operate_Type.OT_Relative, (int)info.GetAddCrg(0, obj.GetLevel())); obj.GetActualProperty().SetCht(Operate_Type.OT_Relative, info.GetAddCht(0, obj.GetLevel())); obj.GetActualProperty().SetWdps(Operate_Type.OT_Relative, info.GetAddDps(0, obj.GetLevel())); obj.GetActualProperty().SetDamRange(Operate_Type.OT_Relative, info.GetAddDamRange(0, obj.GetLevel())); } } //计算pvp物品的影响 for (int ix = 0; ix < EquipmentStateInfo.c_PackageCapacity; ++ix) { ItemDataInfo info = obj.GetEquipmentStateInfo().GetItemData(ix); if (null != info) { obj.GetActualProperty().SetMoveSpeed(Operate_Type.OT_Relative, info.GetAddSpd(0, obj.GetLevel())); obj.GetActualProperty().SetHpMax(Operate_Type.OT_Relative, (int)info.GetAddHpMax(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyMax(Operate_Type.OT_Relative, (int)info.GetAddNpMax(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyCoreMax(Operate_Type.OT_Relative, (int)info.GetAddEpMax(0, obj.GetLevel())); obj.GetActualProperty().SetCrgMax(Operate_Type.OT_Relative, (int)info.GetAddCrgMax(0, obj.GetLevel())); obj.GetActualProperty().SetHpRecover(Operate_Type.OT_Relative, info.GetAddHpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyRecover(Operate_Type.OT_Relative, info.GetAddNpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyCoreRecover(Operate_Type.OT_Relative, info.GetAddEpRecover(0, obj.GetLevel())); obj.GetActualProperty().SetAttackBase(Operate_Type.OT_Relative, (int)info.GetAddAd(0, obj.GetLevel())); obj.GetActualProperty().SetDefenceBase(Operate_Type.OT_Relative, (int)info.GetAddDp(0, obj.GetLevel())); obj.GetActualProperty().SetCritical(Operate_Type.OT_Relative, info.GetAddCri(0, obj.GetLevel())); obj.GetActualProperty().SetCriticalPow(Operate_Type.OT_Relative, info.GetAddPow(0, obj.GetLevel())); obj.GetActualProperty().SetArmorPenetration(Operate_Type.OT_Relative, info.GetAddAndp(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyIntensity(Operate_Type.OT_Relative, info.GetAddAp(0, obj.GetLevel())); obj.GetActualProperty().SetEnergyArmor(Operate_Type.OT_Relative, info.GetAddTay(0, obj.GetLevel())); obj.GetActualProperty().SetAttackRange(Operate_Type.OT_Relative, info.GetAddRange(0, obj.GetLevel())); obj.GetActualProperty().SetRps(Operate_Type.OT_Relative, info.GetAddRps(0, obj.GetLevel())); obj.GetActualProperty().SetCrg(Operate_Type.OT_Relative, (int)info.GetAddCrg(0, obj.GetLevel())); obj.GetActualProperty().SetCht(Operate_Type.OT_Relative, info.GetAddCht(0, obj.GetLevel())); obj.GetActualProperty().SetWdps(Operate_Type.OT_Relative, info.GetAddDps(0, obj.GetLevel())); obj.GetActualProperty().SetDamRange(Operate_Type.OT_Relative, info.GetAddDamRange(0, obj.GetLevel())); } } }
//-------------------------------------- private void HandleCreateBattleRoom(Msg_LR_CreateBattleRoom createRoomMsg, PBChannel channel, int handle, uint seq) { LogSys.Log(LOG_TYPE.DEBUG, "channel:{0}, seq:{1}", channel, seq); bool canContinue = true; //先检查是否玩家已经在room上。 foreach (Msg_LR_RoomUserInfo rui in createRoomMsg.UsersList) { if (RoomPeerMgr.Instance.IsKeyExist(rui.Key)) { canContinue = false; LogSys.Log(LOG_TYPE.WARN, "User is already in room. UserGuid:{0}, Key:{1}", rui.Guid, rui.Key); break; } } if (!canContinue) { Msg_RL_ReplyCreateBattleRoom.Builder replyBuilder0 = Msg_RL_ReplyCreateBattleRoom.CreateBuilder(); replyBuilder0.SetRoomId(createRoomMsg.RoomId); replyBuilder0.SetIsSuccess(false); channel.Send(replyBuilder0.Build()); return; } List <User> users = new List <User>(); foreach (Msg_LR_RoomUserInfo rui in createRoomMsg.UsersList) { User rsUser = user_pool_.NewUser(); LogSys.Log(LOG_TYPE.INFO, "NewUser {0} for {1} {2}", rsUser.LocalID, rui.Guid, rui.Key); rsUser.Init(); if (!rsUser.SetKey(rui.Key)) { LogSys.Log(LOG_TYPE.WARN, "user who's key is {0} already in room!", rui.Key); LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for {1} {2}, [RoomManager.HandleCreateBattleRoom]", rsUser.LocalID, rui.Guid, rui.Key); user_pool_.FreeUser(rsUser.LocalID); continue; } rsUser.Guid = rui.Guid; rsUser.Name = rui.Nick; rsUser.HeroId = rui.Hero; rsUser.CampId = rui.Camp; rsUser.Level = rui.Level; rsUser.ArgFightingScore = rui.ArgScore; if (rui.IsMachine == true) { rsUser.UserControlState = (int)UserControlState.Ai; } else { rsUser.UserControlState = (int)UserControlState.User; } //装备数据 for (int index = 0; index < rui.ShopEquipmentsIdCount; ++index) { rsUser.ShopEquipmentsId.Add(rui.GetShopEquipmentsId(index)); } if (null != rsUser.Skill) { rsUser.Skill.Clear(); for (int i = 0; i < rui.SkillsCount; i++) { SkillTransmitArg skill_arg = new SkillTransmitArg(); skill_arg.SkillId = rui.SkillsList[i].SkillId; skill_arg.SkillLevel = rui.SkillsList[i].SkillLevel; rsUser.Skill.Add(skill_arg); } if (rui.HasPresetIndex) { rsUser.PresetIndex = rui.PresetIndex; } } /// if (null != rsUser.Equip) { rsUser.Equip.Clear(); for (int i = 0; i < rui.EquipsCount; i++) { ItemTransmitArg equip_arg = new ItemTransmitArg(); equip_arg.ItemId = rui.EquipsList[i].EquipId; equip_arg.ItemLevel = rui.EquipsList[i].EquipLevel; equip_arg.ItemRandomProperty = rui.EquipsList[i].EquipRandomProperty; rsUser.Equip.Add(equip_arg); } } /// if (null != rsUser.Legacy) { rsUser.Legacy.Clear(); for (int i = 0; i < rui.LegacysCount; i++) { ItemTransmitArg legacy_arg = new ItemTransmitArg(); legacy_arg.ItemId = rui.LegacysList[i].LegacyId; legacy_arg.ItemLevel = rui.LegacysList[i].LegacyLevel; legacy_arg.ItemRandomProperty = rui.LegacysList[i].LegacyRandomProperty; legacy_arg.IsUnlock = rui.LegacysList[i].LegacyIsUnlock; rsUser.Legacy.Add(legacy_arg); } } /// if (null != rsUser.XSouls) { rsUser.XSouls.GetAllXSoulPartData().Clear(); for (int i = 0; i < rui.XSoulsCount; i++) { ItemDataInfo item = new ItemDataInfo(); item.ItemId = rui.XSoulsList[i].ItemId; item.Level = rui.XSoulsList[i].Level; item.Experience = rui.XSoulsList[i].Experience; ItemConfig configer = ItemConfigProvider.Instance.GetDataById(item.ItemId); item.ItemConfig = configer; if (configer != null) { XSoulPartInfo part_info = new XSoulPartInfo((XSoulPart)configer.m_WearParts, item); part_info.ShowModelLevel = rui.XSoulsList[i].ModelLevel; rsUser.XSouls.SetXSoulPartData((XSoulPart)configer.m_WearParts, part_info); } } } // partner if (null != rui.Partner) { PartnerConfig partnerConfig = PartnerConfigProvider.Instance.GetDataById(rui.Partner.PartnerId); if (null != partnerConfig) { PartnerInfo partnerInfo = new PartnerInfo(partnerConfig); partnerInfo.CurAdditionLevel = rui.Partner.PartnerLevel; partnerInfo.CurSkillStage = rui.Partner.PartnerStage; rsUser.Partner = partnerInfo; } } users.Add(rsUser); LogSys.Log(LOG_TYPE.DEBUG, "enter room {0} scene {1} user info guid={2}, name={3}, key={4}, camp={5}", createRoomMsg.RoomId, createRoomMsg.SceneType, rui.Guid, rui.Nick, rui.Key, rui.Camp); } //临时测试人机机制 /* * Data_SceneConfig sceneCfg = SceneConfigProvider.Instance.GetSceneConfigById(createRoomMsg.SceneType); * if (1 == createRoomMsg.UsersCount && null != sceneCfg && sceneCfg.m_Type == (int)SceneTypeEnum.TYPE_PVP) { * for (int i = 0; i < 9; ++i) { * User rsUser = room_mgr_.NewUser(); * rsUser.Init(); * rsUser.SetKey(0xffffffff); * rsUser.Guid = 0xffffffff; * rsUser.Name = "Computer" + i; * rsUser.HeroId = CrossEngineHelper.Random.Next(1, 3); * rsUser.CampId = (i < 4 ? (int)CampIdEnum.Blue : (int)CampIdEnum.Red); * rsUser.UserControlState = (int)UserControlState.Ai; * users.Add(rsUser); * LogSys.Log(LOG_TYPE.DEBUG, "Computer enter room"); * } * } */ bool ret = false; if (users.Count == 0) { LogSys.Log(LOG_TYPE.WARN, "no user enter room"); ret = false; } else { ret = ActiveRoom(createRoomMsg.RoomId, createRoomMsg.SceneType, users.ToArray()); } if (ret) { LogSys.Log(LOG_TYPE.DEBUG, "user enter room success."); } else { LogSys.Log(LOG_TYPE.DEBUG, "user enter room failed!"); } Msg_RL_ReplyCreateBattleRoom.Builder replyBuilder = Msg_RL_ReplyCreateBattleRoom.CreateBuilder(); replyBuilder.SetRoomId(createRoomMsg.RoomId); replyBuilder.SetIsSuccess(ret); channel.Send(replyBuilder.Build()); }
internal bool AddNewUser(User newUser) { foreach (User us in room_users_) { if (us != null && us.Guid == newUser.Guid) { //当前玩家已在游戏房间内 LogSys.Log(LOG_TYPE.DEBUG, "Add user success: User already in the room! RoomID:{0}, Guid:{1}, OldUser[{2}]({3}) NewUser[{4}]({5}) ", cur_room_id_, us.Guid, us.LocalID, us.GetKey(), newUser.LocalID, newUser.GetKey()); LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for {1} {2}, [Room.AddNewUser]", newUser.LocalID, newUser.Guid, newUser.GetKey()); user_pool_.FreeUser(newUser.LocalID); return(true); } } can_close_time_ = 0; newUser.EnterRoomTime = TimeUtility.GetServerMilliseconds(); newUser.OwnRoom = this; newUser.RegisterObservers(room_observers_); newUser.Info = m_UserMgr.AddUser(newUser.HeroId); newUser.Info.SetUnitId(GlobalVariables.GetUnitIdByCampId(newUser.CampId)); newUser.Info.SetCampId(newUser.CampId); newUser.Info.SetLevel(newUser.Level); if ((int)UserControlState.Ai == newUser.UserControlState) { newUser.Info.GetAiStateInfo().AiLogic = (int)AiStateLogicId.PvpUser_General; newUser.IsEntered = true; } if (m_ActiveScene >= 0 && m_Scenes.Count > m_ActiveScene) { Scene scene = m_Scenes[m_ActiveScene]; scene.EnterScene(newUser.Info); if ((int)UserControlState.Ai == newUser.UserControlState) { Data_Unit unit = scene.MapData.ExtractData(DataMap_Type.DT_Unit, newUser.Info.GetUnitId()) as Data_Unit; if (null != unit) { newUser.Info.GetMovementStateInfo().SetPosition(unit.m_Pos); newUser.Info.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle); } } } foreach (User otheruser in room_users_) { if (otheruser != null) { otheruser.AddSameRoomUser(newUser); newUser.AddSameRoomUser(otheruser); } } room_users_.Add(newUser); LogSys.Log(LOG_TYPE.DEBUG, "Add user success ! RoomID:{0} , UserGuid:{1}({2})", cur_room_id_, newUser.Guid, newUser.GetKey()); if (null != newUser.Skill && 4 == newUser.Skill.Count) { newUser.Info.GetSkillStateInfo().RemoveAllSkill(); newUser.Info.ResetSkill(); for (int index = 0; index < newUser.Skill.Count; index++) { if (newUser.Skill[index].SkillId > 0) { SkillInfo info = new SkillInfo(newUser.Skill[index].SkillId); info.SkillLevel = newUser.Skill[index].SkillLevel; info.Postions.SetCurSkillSlotPos(newUser.PresetIndex, (SlotPosition)(index + 1)); SkillCategory cur_skill_pos = SkillCategory.kNone; if ((index + 1) == (int)SlotPosition.SP_A) { cur_skill_pos = SkillCategory.kSkillA; } else if ((index + 1) == (int)SlotPosition.SP_B) { cur_skill_pos = SkillCategory.kSkillB; } else if ((index + 1) == (int)SlotPosition.SP_C) { cur_skill_pos = SkillCategory.kSkillC; } else if ((index + 1) == (int)SlotPosition.SP_D) { cur_skill_pos = SkillCategory.kSkillD; } info.ConfigData.Category = cur_skill_pos; newUser.Info.GetSkillStateInfo().AddSkill(info); newUser.Info.ResetSkill(); /// AddSubSkill(newUser, info.SkillId, cur_skill_pos, info.SkillLevel); } } Data_PlayerConfig playerData = PlayerConfigProvider.Instance.GetPlayerConfigById(newUser.HeroId); if (null != playerData && null != playerData.m_FixedSkillList && playerData.m_FixedSkillList.Count > 0) { foreach (int skill_id in playerData.m_FixedSkillList) { if (null == newUser.Info.GetSkillStateInfo().GetSkillInfoById(skill_id)) { SkillInfo info = new SkillInfo(skill_id, 1); newUser.Info.GetSkillStateInfo().AddSkill(info); newUser.Info.ResetSkill(); } } } } if (null != newUser.Equip && newUser.Equip.Count > 0) { newUser.Info.GetEquipmentStateInfo().Reset(); for (int index = 0; index < newUser.Equip.Count; index++) { if (newUser.Equip[index].ItemId > 0) { ItemDataInfo info = new ItemDataInfo(newUser.Equip[index].ItemRandomProperty); info.ItemId = newUser.Equip[index].ItemId; info.Level = newUser.Equip[index].ItemLevel; info.RandomProperty = newUser.Equip[index].ItemRandomProperty; info.ItemConfig = ItemConfigProvider.Instance.GetDataById(info.ItemId); newUser.Info.GetEquipmentStateInfo().SetEquipmentData(index, info); } } } if (null != newUser.Legacy && newUser.Legacy.Count > 0) { newUser.Info.GetLegacyStateInfo().Reset(); for (int index = 0; index < newUser.Legacy.Count; index++) { if (null != newUser.Legacy[index] && newUser.Legacy[index].ItemId > 0 && newUser.Legacy[index].IsUnlock) { ItemDataInfo info = new ItemDataInfo(newUser.Legacy[index].ItemRandomProperty); info.ItemId = newUser.Legacy[index].ItemId; info.Level = newUser.Legacy[index].ItemLevel; info.RandomProperty = newUser.Legacy[index].ItemRandomProperty; info.IsUnlock = newUser.Legacy[index].IsUnlock; info.ItemConfig = ItemConfigProvider.Instance.GetDataById(info.ItemId); newUser.Info.GetLegacyStateInfo().SetLegacyData(index, info); } } newUser.Info.GetLegacyStateInfo().UpdateLegacyComplexAttr(); } if (null != newUser.Partner) { newUser.Info.SetPartnerInfo(newUser.Partner); } return(true); }
public void RefreshItemSkills(SendImpactToSelfDelegation sendImpactToSelf, StopMyImpactDelegation stopImpact) { //标记所有物品带的技能与buff foreach (SkillInfo info in GetSkillStateInfo().GetAllSkill()) { if (info.IsItemSkill) { info.IsMarkToRemove = true; } } foreach (ImpactInfo info in GetSkillStateInfo().GetAllImpact()) { if (info.m_IsItemImpact) { info.m_IsMarkToRemove = true; } } //刷新物品带的技能与buff EquipmentStateInfo equipInfo = GetEquipmentStateInfo(); for (int ix = 0; ix < EquipmentStateInfo.c_PackageCapacity; ++ix) { ItemDataInfo itemInfo = equipInfo.GetItemData(ix); if (null != itemInfo && itemInfo.ItemNum == 1 && null != itemInfo.ItemConfig) { ItemConfig cfg = itemInfo.ItemConfig; if (null != cfg.m_AddSkillOnEquiping) { foreach (int id in cfg.m_AddSkillOnEquiping) { SkillInfo skillInfo = GetSkillStateInfo().GetSkillInfoById(id); if (null == skillInfo) { skillInfo = new SkillInfo(id); skillInfo.IsItemSkill = true; skillInfo.IsMarkToRemove = false; GetSkillStateInfo().AddSkill(skillInfo); } else { skillInfo.IsMarkToRemove = false; } } } if (null != cfg.m_AddBuffOnEquiping && null != sendImpactToSelf) { //此分支为服务器端处理,参数为加impact的回调,这个回调里包括加impact并发消息给客户端(现在ImpactSystem是这样实现的) foreach (int id in cfg.m_AddBuffOnEquiping) { ImpactInfo impactInfo = GetSkillStateInfo().GetImpactInfoById(id); if (null == impactInfo) { impactInfo = sendImpactToSelf(id); if (null != impactInfo) { impactInfo.m_IsItemImpact = true; impactInfo.m_IsMarkToRemove = false; } } else { impactInfo.m_IsMarkToRemove = false; } } } } } //移除不再有效的技能与buff List <int> removeSkills = new List <int>(); foreach (SkillInfo info in GetSkillStateInfo().GetAllSkill()) { if (info.IsItemSkill && info.IsMarkToRemove) { removeSkills.Add(info.SkillId); } } foreach (int id in removeSkills) { GetSkillStateInfo().RemoveSkill(id); } removeSkills.Clear(); List <int> removeImpacts = new List <int>(); foreach (ImpactInfo info in GetSkillStateInfo().GetAllImpact()) { if (info.m_IsItemImpact && info.m_IsMarkToRemove) { removeImpacts.Add(info.m_ImpactId); } } foreach (int id in removeImpacts) { if (null != stopImpact) { stopImpact(id); } } removeImpacts.Clear(); }