//-------------------------------------- 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()); }
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(); }