public static List <string> BuildPlayerSimplePreloadAssets(PRoleSummary info, List <string> assets = null) { if (assets == null) { assets = new List <string>(); } // Player model var model = ConfigManager.Get <CreatureInfo>(info.proto); if (model) { assets.Add(model.models[0]); } var w = WeaponInfo.GetWeapon(0, info.fashion.weapon); // Player weapons BuildWeaponSimplePreloadAssets(info.proto, info.gender, w.weaponID, w.weaponItemId, assets); // Equipments assets.AddRange(CharacterEquip.GetEquipAssets(info.fashion)); if (info.pet == null || info.pet.itemId == 0) { return(assets); } var rPet = PetInfo.Create(info.pet); BuildPetSimplePreloadAssets(rPet, assets, 2); return(assets); }
void _Packet(ScDropRole p) { moduleGlobal.UnLockUI(); if (p.result == 0) { var index = roleList.FindIndex(r => r.roleId == operatorRole); if (index != -1) { var arr = new PRoleSummary[roleList.Length - 1]; var m = 0; for (var i = 0; i < roleList.Length; i++) { if (i != index) { arr[m++] = roleList[i]; } else { roleList[i].Destroy(); } } roleList = arr; DispatchEvent(RoleListChangeEvent); } } DispatchModuleEvent(Response_DeleteRole, p); }
public CreatureInfo BuildPlayerInfo(PRoleSummary rRole) { var info = ConfigManager.Get <CreatureInfo>(rRole.proto); if (!info) { Logger.LogError("Module_Player::BuildPlayerInfo: Build CreatureInfo from PMatchInfo failed, could not find proto template config: {0}", rRole.proto); return(null); } info = info.Clone <CreatureInfo>(); var w = WeaponInfo.GetWeapon(0, rRole.fashion.weapon); var ww = WeaponInfo.GetWeapon(0, rRole.fashion.gun); if (w.isEmpty) { Logger.LogError("Creature::BuildPlayerInfo: MatchInfo has invalid weapon item:<b>[{0}]</b>", rRole.fashion.weapon); } if (ww.isEmpty) { Logger.LogError("Creature::BuildPlayerInfo: MatchInfo has invalid off weapon item:<b>[{0}]</b>", rRole.fashion.gun); } info.weaponID = w.weaponID; info.offWeaponID = ww.weaponID; info.weaponItemID = rRole.fashion.weapon; info.offWeaponItemID = rRole.fashion.gun; return(info); }
public static void Bind(Transform rRoot, PRoleSummary rRole, UnityAction rOnDeleteClick) { var profession = rRoot.GetComponent <Transform>("profession"); AtlasHelper.SetShared(profession, $"proicon_0{rRole.proto}"); Util.SetText(rRoot.GetComponent <Text>("name"), rRole.name); Util.SetText(rRoot.GetComponent <Text>("level"), $"Lv.{rRole.level}"); Util.SetText(rRoot.GetComponent <Text>("raidValue"), ConfigText.GetDefalutString(204, 36) + rRole.power); rRoot.GetComponent <Button>("delete_btn")?.onClick.AddListener(rOnDeleteClick); }
public void OnCreateRoleSuccess(PRoleSummary role) { Array.Resize(ref roleList, RoleCount + 1); roleList[RoleCount - 1] = role; DispatchEvent(RoleListChangeEvent); }
private void CreateRole(PRoleSummary rRole, RoleEntry rEntry) { if (rEntry?.root == null || rRole == null) { return; } rEntry.materialList.Clear(); //没有时装数据的角色不创建模型。避免报错 if (rRole.fashion.weapon == 0) { return; } Vector3 pos = Vector3.zero, rot = Vector3.zero; var info = ConfigManager.Get <ShowCreatureInfo>(20001 + rEntry.index); var d = info?.GetDataByIndex(rRole.proto); if (d != null && d.data?.Length > 0) { pos = d.data[0].pos; rot = d.data[0].rotation; } var assets = new List <string>(); Level.PrepareAssets(Module_Battle.BuildPlayerSimplePreloadAssets(rRole, assets), b => { rEntry.creature = Creature.Create(modulePlayer.BuildPlayerInfo(rRole), rEntry.root.position + pos, rot, true, rRole.name, rRole.name, false); rEntry.creature.transform.SetParent(rEntry.root); rEntry.creature.localRotation = Quaternion.Euler(rot); rEntry.creature.roleId = rRole.roleId; CharacterEquip.ChangeCloth(rEntry.creature, rRole.fashion); var renderers = rEntry.creature.gameObject.GetComponentsInChildren <Renderer>(); foreach (var r in renderers) { rEntry.materialList.AddRange(r.materials); } //暂时不显示宠物了 /*if (rRole.pet == null || rRole.pet.itemId == 0) * return; * * var rPet = PetInfo.Create(rRole.pet); * var rGradeInfo = rPet.UpGradeInfo; * var show = ConfigManager.Get<ShowCreatureInfo>(rPet.ID); * if (show == null) * { * Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", rPet.ID); * return; * } * var showData = show.GetDataByIndex(0); * var data = showData.data.GetValue<ShowCreatureInfo.SizeAndPos>(0); * rEntry.pet = moduleHome.CreatePet(rGradeInfo, data.pos + rEntry.creature.position, data.rotation, rEntry.root, true, * Module_Home.TEAM_PET_OBJECT_NAME); * rEntry.pet.transform.localScale *= data.size; * rEntry.pet.transform.localEulerAngles = data.rotation; * * renderers = rEntry.pet.gameObject.GetComponentsInChildren<Renderer>(); * foreach (var r in renderers) * rEntry.materialList.AddRange(r.materials);*/ }); }