public static List <string> BuildPlayerPreloadAssets(List <string> assets = null) { if (assets == null) { assets = new List <string>(); } // Player shadow assets.Add(CombatConfig.sdefaultSelfShadow); // Player model var model = ConfigManager.Get <CreatureInfo>(modulePlayer.proto); if (model) { assets.AddRange(model.models); } // Player weapons BuildWeaponPreloadAssets(modulePlayer.proto, modulePlayer.gender, moduleEquip.weaponID, moduleEquip.weaponItemID, moduleEquip.offWeaponID, moduleEquip.offWeaponItemID, assets, true); // Buff effects BuildBuffPreloadAssets(modulePlayer.buffs, assets); // Equipments assets.AddRange(CharacterEquip.GetEquipAssets(moduleEquip.currentDressClothes)); // Pet BuildPetPreloadAssets(assets, modulePet.FightingPet); return(assets); }
protected virtual void OnCreateCreatures() { var info = modulePlayer.BuildPlayerInfo(); m_player = Creature.Create(info, playerStart, new Vector3(0, 90, 0), true, "player", modulePlayer.name_); m_player.roleId = modulePlayer.id_; m_player.roleProto = modulePlayer.proto; CharacterEquip.ChangeCloth(m_player, moduleEquip.currentDressClothes); _SetDOFFocusTarget(m_player.transform); //创建宠物 if (modulePet.FightingPetID <= 0) { return; } var pet = modulePet.FightingPet; if (pet != null) { var show = ConfigManager.Get <ShowCreatureInfo>(pet.ID); if (show == null) { Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", pet.ID); return; } var showData = show.GetDataByIndex(0); var data = showData.data.GetValue <ShowCreatureInfo.SizeAndPos>(0); m_player.pet = PetCreature.Create(m_player, pet, playerStart + data.pos, data.rotation, false, Module_Home.PET_OBJECT_NAME); m_player.pet.localScale *= data.size; m_player.pet.localEulerAngles = data.rotation; } }
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); }
protected override List <string> OnBuildPreloadAssets(List <string> assets = null) { base.OnBuildPreloadAssets(assets); PropItemInfo weaponInfo = ConfigManager.Get <PropItemInfo>(moduleLabyrinth.sneakPlayerDetail.fashion.weapon); LoadStateMachineEffect(assets, weaponInfo.subType, weaponInfo.ID, 0, 1); // @TODO: 尽管现在性别绑定到职业了,但逻辑上必须使用性别 LoadAllBuffAsset(assets); // enermy model var model = ConfigManager.Get <CreatureInfo>(moduleLabyrinth.lastSneakPlayer.GetProto()); if (model) { assets.AddRange(model.models); } //添加装备和时装 assets.AddRange(CharacterEquip.GetEquipAssets(moduleLabyrinth.sneakPlayerDetail.fashion)); assets.AddRange(CharacterEquip.GetAnimatorAssets(moduleLabyrinth.sneakPlayerDetail.fashion)); var pet = moduleLabyrinth.lastSneakPlayer.pet; if (pet != null && pet.itemId > 0) { var petInfo = PetInfo.Create(pet); if (petInfo != null) { Module_Battle.BuildPetPreloadAssets(assets, petInfo); } } assets.AddRange(FillLabyrithBuffAsset()); return(assets); }
public static List <string> BuildPlayerSimplePreloadAssets(PMatchProcessInfo info, List <string> assets = null) { if (assets == null) { assets = new List <string>(); } // Player model var model = ConfigManager.Get <CreatureInfo>(info.roleProto); if (model) { assets.AddRange(model.models); } var w = WeaponInfo.GetWeapon(0, info.fashion.weapon); // Player weapons BuildWeaponSimplePreloadAssets(info.roleProto, info.gender, w.weaponID, w.weaponItemId, assets); // Equipments assets.AddRange(CharacterEquip.GetEquipAssets(info.fashion)); return(assets); }
protected override void OnCreateCreatures() { base.OnCreateCreatures(); // Create default player m_player.regenRagePercent = 0.3f; // Regen 30% rage every second moduleAI.AddCreatureToCampDic(m_player); var info = modulePlayer.BuildPlayerInfo(modulePlayer.proto); info.name = Util.GetString(9208); m_enermy = Creature.Create(info, new Vector3_(CombatConfig.spvpStart.y, 0, 0), new Vector3(0, 90, 0), false, "enermy", info.name); m_enermy.FaceTo(player); var es = Module_Equip.SelectRandomEquipments(m_player.gender, m_player.roleProto); m_enermy.avatar = es[0] + "_" + es[1] + "_" + es[2]; m_enermy.avatarBox = m_player.avatarBox; m_enermy.roleProto = m_player.roleProto; moduleAI.AddCreatureToCampDic(m_enermy); CharacterEquip.ChangeCloth(m_enermy, es); m_enermy.maxHealth = (int)(player.attack + player.elementAttack) * 20; m_enermy.health = m_enermy.maxHealth; m_enermy.regenHealthPercent = 0.3; player.AddEventListener(CreatureEvents.DEAD, OnCreatureDead); m_enermy.AddEventListener(CreatureEvents.DEAD, OnCreatureDead); EventManager.AddEventListener(CreatureEvents.Dying, OnCreatureDying); }
/// <summary> /// Create a player creature at position pos and set direction to direction. /// </summary> /// <returns></returns> public Creature CreatePlayer(Vector3 pos, CreatureDirection direction, bool buff = false, bool skill = false) { var node = Level.current.startPos; var info = modulePlayer.BuildPlayerInfo(-1, buff, skill); var player = Creature.Create(info, pos, true, PLAYER_OBJECT_NAME, modulePlayer.name_); player.roleId = modulePlayer.id_; player.roleProto = modulePlayer.proto; player.direction = direction; Util.AddChild(node, player.transform, true); CharacterEquip.ChangeCloth(player, moduleEquip.currentDressClothes); m_playerPosition = player.position; m_playerRotation = player.eulerAngles; m_playerScale = player.localScale; var visible = ChildIsVisible(player.name); player.gameObject.SetActive(visible); if (visible) { Level.SetDOFFocusTarget(player.transform); } return(player); }
protected override List <string> BuildPreloadAssets() { var assets = base.BuildPreloadAssets(); assets.Add(Module_Bordlands.BORDLAND_MONSTER_ANIMATOR_NAME); //add player data var c = ConfigManager.Get <CreatureInfo>(modulePlayer.proto); assets.AddRange(c.models); assets.Add(Creature.GetAnimatorName(moduleEquip.weaponID, modulePlayer.gender)); assets.AddRange(CharacterEquip.GetEquipAssets(moduleEquip.currentDressClothes)); assets.Add(headPanelName); assets.Add(GeneralConfigInfo.ssceneTextObject); // Player shadow assets.Add(CombatConfig.sdefaultSelfShadow); if (moduleBordlands.bordlandsSettlementReward != null) { assets.Add(Window_RandomReward.ASSET_NAME); } if (modulePet.FightingPet != null) { Module_Battle.BuildPetSimplePreloadAssets(modulePet.FightingPet, assets, 1); } var emjioList = ConfigManager.GetAll <FaceName>(); for (int i = 0; i < emjioList.Count; i++) { assets.Add(emjioList[i]?.head_icon); } return(assets); }
public void InitData() { characterSkin = new CharacterSkin(this); characterEquip = new CharacterEquip(this); characterAnim = new CharacterAnim(this); CharacterItems = new CharacterItems(this); }
public void ChangeNewFashion(PShopItem item, Creature creature) { PItem newItem = moduleEquip.GetNewPItem(item.itemTypeId, item.itemTypeId); PropItemInfo info = ConfigManager.Get <PropItemInfo>(newItem.itemTypeId); PItem containItem = m_changeFashion.Find((p) => { var _info = p.GetPropItem(); if (!_info) { return(false); } return(_info.itemType == PropType.FashionCloth && info.subType == _info.subType); }); if (containItem != null) { m_changeFashion.Remove(containItem); m_changeFashion.Add(newItem); } else { m_changeFashion.Add(newItem); } CharacterEquip.ChangeCloth(creature, m_changeFashion); changedCloth = true; }
private void CreateTeamPlayer() { var members = moduleTeam.members; if (members != null) { for (var i = 0; i < members.Length; ++i) { var pi = members[i]; var info = modulePlayer.BuildPlayerInfo(pi); var isPlayer = pi.roleId == LoadParamTeam.MasterId; var pos = new Vector3_(playerStart.x - i, 0, 0); var p = Creature.Create(info, pos, new Vector3(0, 90, 0), isPlayer, i + ":" + pi.roleId, pi.roleName); p.roleId = pi.roleId; p.roleProto = pi.roleProto; p.teamIndex = i; p.avatar = pi.avatar; p.enableUpdate = false; p.SetCreatureCamp(CreatureCamp.PlayerCamp); if (isPlayer) { m_player = p; moduleBattle.SetPlayerTeamIndex(p.teamIndex); } if (pi.teamLeader > 0) { m_teamLeader = p; } else { m_normalMember = p; } m_teamMembers.Add(p); CharacterEquip.ChangeCloth(p, pi.fashion); if (pi.pet != null && pi.pet.itemTypeId != 0) { var show = ConfigManager.Get <ShowCreatureInfo>(pi.pet.itemTypeId); if (show == null) { Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", pi.pet.itemTypeId); continue; } var showData = show.GetDataByIndex(0); var data = showData.data.GetValue <ShowCreatureInfo.SizeAndPos>(0); p.pet = PetCreature.Create(p, PetInfo.Create(pi.pet), p.position_ + data.pos, p.eulerAngles, false, Module_Home.PET_OBJECT_NAME); p.pet.enableUpdate = false; } } } }
public BindNodeInfo(int _type, Transform root, CharacterEquip e) { type = (FashionSubType)_type; i = (int)type; isMesh = type != FashionSubType.Hair && type != FashionSubType.HeadDress && type != FashionSubType.HairDress && type != FashionSubType.FaceDress && type != FashionSubType.NeckDress; isSetSlot = type == FashionSubType.TwoPieceSuit || type == FashionSubType.FourPieceSuit; m_root = root; m_e = e; }
private void ChangeNpcMode(string mesh) { if (moduleNpc.curNpc == null || moduleNpc.curNpc.curNpcCreature == null || string.IsNullOrEmpty(mesh)) { return; } CharacterEquip.ChangeNpcFashion(moduleNpc.curNpc.curNpcCreature, mesh); curMesh = mesh; }
private List <string> GetPlayerPreloadAssets(List <PMazePlayer> infos) { List <string> list = new List <string>(); string temp = string.Empty; foreach (var p in infos) { //add creature var c = ConfigManager.Get <CreatureInfo>(p.GetProto()); if (!c) { Logger.LogError("wrong player proto with pmazePlayer : id:{0},name:{1},gender:{2} proto:{3}", p.roleId, p.roleName, p.gender, p.GetProto()); continue; } list.AddRange(c.models); if (p.fashion != null) { //add animator asset var prop = ConfigManager.Get <PropItemInfo>(p.fashion.weapon); if (prop) { temp = Creature.GetAnimatorName(prop.subType, p.gender); if (!list.Contains(temp)) { list.Add(temp); } } //equip assets List <string> equips = CharacterEquip.GetEquipAssets(p.fashion); foreach (var e in equips) { if (!list.Contains(e)) { list.Add(e); } } } //pet assets if (p.pet != null && p.pet.itemTypeId != 0) { var pet = PetInfo.Create(p.pet); Module_Battle.BuildPetSimplePreloadAssets(pet, list, 1); } } list.Distinct(); return(list); }
private void RestoreModes() { if (moduleNPCDating.curDatingNpcMsg == null || string.IsNullOrEmpty(moduleNPCDating.curDatingNpcMsg.mode)) { return; } if (moduleNPCDating.curDatingNpcMsg.mode == curMesh) { return; } CharacterEquip.ChangeNpcFashion(moduleNPCDating.curDatingNpcMsg.curNpcCreature, moduleNPCDating.curDatingNpcMsg.mode); }
public Creature CreateNpc(int npcInfoId, Vector3 pos, Vector3 rot, Transform node, string name = "") { var npcInfo = ConfigManager.Get <NpcInfo>(npcInfoId); if (npcInfo == null) { return(null); } var i = ConfigManager.Get <CreatureInfo>(CREATURE_TEMPLATE).Clone <CreatureInfo>(); i.models = new string[] { npcInfo.mode }; i.weaponID = npcInfo.stateMachine; i.weaponItemID = 0; i.offWeaponItemID = 0; i.gender = 0; var npc = Creature.Create(i, pos, false, name, name); if (!npc) { return(null); } npc.transform.localEulerAngles = rot; var wt = npc.transform.Find("model/weapon"); if (wt) { wt.gameObject.SetActive(false); } if (npcInfo.type == 1) { var _npc = moduleNpc.GetTargetNpc((NpcTypeID)npcInfoId); if (_npc != null) { CharacterEquip.ChangeNpcFashion(npc, _npc.mode); _npc.UpdateCurCreature(npc); } } Util.AddChild(node, npc.transform, true); DispatchEvent(EventLoadNpc, Event_.Pop(npc)); return(npc); }
public Creature CreatePlayer(PMatchProcessInfo pi, Vector3 pos, CreatureDirection direction, bool buff = false, bool skill = false) { var node = Level.current.startPos; var info = modulePlayer.BuildPlayerInfo(pi, buff, skill); var creature = Creature.Create(info, pos, false, pi.roleId + ":" + pi.roleName); creature.roleId = pi.roleId; creature.roleProto = pi.roleProto; creature.direction = direction; Util.AddChild(node, creature.transform, true); CharacterEquip.ChangeCloth(creature, pi.fashion); return(creature); }
protected Creature CreateTeamPlayer(PTeamMemberInfo rInfo, Vector3 pos, int index = 0) { if (rInfo == null) { return(null); } var info = modulePlayer.BuildPlayerInfo(rInfo); var isPlayer = rInfo.roleId == LoadParamTeam.MasterId; var p = Creature.Create(info, pos, new Vector3(0, 90, 0), isPlayer, index + ":" + rInfo.roleId, rInfo.roleName); p.roleId = rInfo.roleId; p.roleProto = rInfo.roleProto; p.teamIndex = index; p.avatar = rInfo.avatar; p.enableUpdate = false; if (isPlayer) { m_player = p; moduleBattle.SetPlayerTeamIndex(p.teamIndex); } CharacterEquip.ChangeCloth(p, rInfo.fashion); if (rInfo.pet == null || rInfo.pet.itemTypeId == 0) { return(p); } var show = ConfigManager.Get <ShowCreatureInfo>(rInfo.pet.itemTypeId); if (show == null) { Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", rInfo.pet.itemTypeId); return(p); } var showData = show.GetDataByIndex(0); var data = showData.data.GetValue <ShowCreatureInfo.SizeAndPos>(0); p.pet = PetCreature.Create(p, PetInfo.Create(rInfo.pet), p.position_ + data.pos, p.eulerAngles, false, Module_Home.PET_OBJECT_NAME); p.pet.enableUpdate = false; return(p); }
public static List <string> BuildPlayerPreloadAssets(PTeamMemberInfo info, List <string> assets = null) { if (assets == null) { assets = new List <string>(); } if (info == null) { return(assets); } // Player shadow if (info.roleId == modulePlayer.id_) { assets.Add(CombatConfig.sdefaultSelfShadow); } // Player model var model = ConfigManager.Get <CreatureInfo>(info.roleProto); if (model) { assets.AddRange(model.models); } var w = WeaponInfo.GetWeapon(0, info.fashion.weapon); var ww = WeaponInfo.GetWeapon(0, info.fashion.gun); // Player weapons BuildWeaponPreloadAssets(info.roleProto, info.gender, w.weaponID, w.weaponItemId, ww.weaponID, ww.weaponItemId, assets); // Buff effects BuildBuffPreloadAssets(info.buffs, assets); // Equipments assets.AddRange(CharacterEquip.GetEquipAssets(info.fashion)); // Pet BuildPetPreloadAssets(assets, info.pet != null && info.pet.itemTypeId != 0 ? PetInfo.Create(info.pet) : null); return(assets); }
private List <string> GetPlayerPreloadAssets(PNmlPlayer[] infos) { List <string> list = new List <string>(); string temp = string.Empty; foreach (var p in infos) { //add creature var c = ConfigManager.Get <CreatureInfo>(p.GetProto()); list.AddRange(c.models); //add animator asset var prop = ConfigManager.Get <PropItemInfo>(p.fashion.weapon); if (prop) { temp = Creature.GetAnimatorName(prop.subType, p.gender); if (!list.Contains(temp)) { list.Add(temp); } } //equip assets List <string> equips = CharacterEquip.GetEquipAssets(p.fashion); foreach (var e in equips) { if (!list.Contains(e)) { list.Add(e); } } if (p.pet != null && p.pet.itemTypeId != 0) { var pet = PetInfo.Create(p.pet); Module_Battle.BuildPetSimplePreloadAssets(pet, list, 1); } } list.Distinct(); return(list); }
public void HandlePlayer(Creature player, PNmlPlayer info, bool isPlayer = false) { Util.SetLayer(player.gameObject, Layers.MODEL); player.isPlayer = isPlayer; player.enableUpdate = false; player.behaviour.enabled = false; player.gameObject.SetActive(m_playerVisible || isPlayer); player.gameObject.name = isPlayer ? "self" : info.roleName; CharacterEquip.ChangeCloth(player, info.fashion); BordlandsCreature bc = player.activeRootNode.GetComponentDefault <BordlandsCreature>(); PropItemInfo weaponInfo = ConfigManager.Get <PropItemInfo>(info.fashion.weapon); if (weaponInfo) { bc.LoadPlayerRuntimeAnimator(Creature.GetAnimatorName(weaponInfo.subType, info.gender), weaponInfo.subType, (byte)info.gender); } bc.playerType = isPlayer ? BordlandsCreature.BordLandCreatureType.Self : BordlandsCreature.BordLandCreatureType.Player; bc.roleInfo = info; bc.creature = player; bc.InitPVECreatureBehaviour(); bc.creaturePos = info.pos.ToVector3(); if (player.pet) { player.pet.gameObject.SetActive(m_playerVisible || isPlayer); player.pet.position_ = bc.creaturePos - new Vector3(0.45f, 0, 0); } if (!isPlayer) { if (!m_otherPlayerCreatures.ContainsKey(info.roleId)) { m_otherPlayerCreatures.Add(info.roleId, null); } m_otherPlayerCreatures[info.roleId] = bc; } }
public void HandlePlayer(Creature player, PMazePlayer info, bool isPlayer = false) { Util.SetLayer(player.gameObject, Layers.MODEL); player.isPlayer = isPlayer; player.enableUpdate = false; player.behaviour.enabled = false; player.visible = moduleLabyrinth.playerVisible || isPlayer; if (player.pet) { player.pet.visible = player.visible; } player.gameObject.name = isPlayer ? "self" : info.roleName; CharacterEquip.ChangeCloth(player, info.fashion); LabyrinthCreature lc = player.activeRootNode.GetComponentDefault <LabyrinthCreature>(); lc.InitCreatureData(player, info); if (!isPlayer) { m_players.Add(lc); } }
public static List <string> BuildPlayerSimplePreloadAssets(List <string> assets = null) { if (assets == null) { assets = new List <string>(); } // Player model var model = ConfigManager.Get <CreatureInfo>(modulePlayer.proto); if (model) { assets.AddRange(model.models); } // Player weapons BuildWeaponSimplePreloadAssets(modulePlayer.proto, modulePlayer.gender, moduleEquip.weaponID, moduleEquip.weaponItemID, assets); // Equipments assets.AddRange(CharacterEquip.GetEquipAssets(moduleEquip.currentDressClothes)); return(assets); }
public NPCFashion(Transform _root, CharacterEquip _equip) { root = _root; equip = _equip; }
public static MonsterCreature CreateMonster(int monsterID, int group, int level, Vector3_ pos, Vector3 rot, StageInfo stage = null, string name = "", string uiName = "", bool needHealthBar = true) { var info = ConfigManager.Get <MonsterInfo>(monsterID); if (info == null) { Logger.LogError("MonsterCreature::Create: Create monster failed, could not find monster [{0}]", monsterID); return(null); } var rootNode = new GameObject().transform; if (!CreateMorphNodes(info.models, rootNode)) { Logger.LogError("MonsterCreature::Create: Create monster [{0}:{1}] failed, main model [{2}] not loaded", monsterID, info.name, CreatureInfo.GetMorphModelName(info.models, 0)); return(null); } rootNode.position = pos; rootNode.eulerAngles = rot; var c = Create <MonsterCreature>(string.IsNullOrEmpty(name) ? info.name : name, rootNode.gameObject); c.isCombat = true; c.InitPosition(pos); if (info.npcId > 0) { var npc = moduleNpc.GetTargetNpc(info.npcId); if (npc != null) { CharacterEquip.ChangeNpcFashion(c, npc.mode); } else { Logger.LogError($"monster表里monsterID = {info.npcId} 配置的NpcID错误,没有ID = {info.npcId}的Npc"); } } //如果配置有属性修正,则直接使用玩家的等级作为参考模板 int targetLevel = (stage != null && stage.levelCorrection) ? modulePlayer.roleInfo.level : level; double aggr = stage != null ? 1.0 + stage.aggressiveCorrection : 1.0; double defen = stage != null ? 1.0 + stage.defensiveCorrection : 1.0; bool isSuccess = false; MonsterAttriubuteInfo attribute = ConfigManager.Get <MonsterAttriubuteInfo>(info.AttributeConfigId); if (!attribute) { var attList = ConfigManager.GetAll <MonsterAttriubuteInfo>(); attribute = attList.GetValue(0); Logger.LogError("Could not find MonsterAttriubuteInfo with monsterId {0} AttributeConfigId [{1}] we will use attri with id {2} to replace", monsterID, info.AttributeConfigId, attribute ? attribute.ID : -1); } if (attribute) { for (int i = 0, length = attribute.monsterAttriubutes.Length; i < length; i++) { if (targetLevel == attribute.monsterAttriubutes[i].level) { isSuccess = true; c.UpdateConfig(info, attribute.monsterAttriubutes[i], aggr, defen); c._SetField(CreatureFields.Level, targetLevel); //怪物等级在怪物创建的时候去确定,初始化不赋值 break; } } //To avoid level is invalid if (!isSuccess) { MonsterAttriubuteInfo.MonsterAttriubute attri = attribute.monsterAttriubutes[attribute.monsterAttriubutes.Length - 1]; int maxLevel = attri.level; c.UpdateConfig(info, attri, aggr, defen); c._SetField(CreatureFields.Level, maxLevel); //怪物等级在怪物创建的时候去确定,初始化不赋值 Logger.LogError("怪物等级修正非法!player.level = {0} ,monster max level = {1} ", modulePlayer.roleInfo.level, maxLevel); } } c.isPlayer = false; c.isMonster = true; c.isRobot = false; c.roleProto = 0; c.uiName = string.IsNullOrEmpty(uiName) ? info ? info.name : c.name : uiName; //怪物属性记录 c.monsterInfo = info; c.monsterId = monsterID; c.monsterGroup = group; c.creatureCamp = group >= -1 ? CreatureCamp.MonsterCamp : group == -2 ? CreatureCamp.PlayerCamp : group == -3 ? CreatureCamp.NeutralCamp : CreatureCamp.None; c.monsterLevel = level; c.isBoss = false; c.isSendDeathCondition = false; c.teamIndex = GetMonsterRoomIndex(); c.obstacleMask = info.iobstacleMask; c.ignoreObstacleMask = info.iignoreObstacleMask; c.gameObject.name = Util.Format("{0}-> id:{1} group:{2} tIdx:{3}", info.name, info.ID, group, c.Identify); c.OnCreate(); c.hpVisiableCount = needHealthBar ? 1 : 0; return(c); }
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);*/ }); }
public void ChangeDefaultCloth(Creature creature) { CharacterEquip.ChangeCloth(creature, moduleEquip.currentDressClothes); OnAddDefaultData(); changedCloth = false; }
protected override void OnCreateCreatures() { m_isEnding = false; EventManager.AddEventListener(CreatureEvents.DEAD, OnCreatureDead); if (!moduleAI.IsStartAI) { moduleAI.StartAI(); } var players = LoadParam.players; for (var i = 0; i < players.Length; ++i) { var pi = players[i]; var info = modulePlayer.BuildPlayerInfo(pi); var isPlayer = pi.roleId == LoadParam.MasterId; var pos = new Vector3_(i == 0 ? CombatConfig.spvpStart.x : CombatConfig.spvpStart.y, 0, 0); var p = isPlayer || !LoadParam.IsMatchRobot ? Creature.Create(info, pos, new Vector3(0, 90, 0), isPlayer, i + ":" + pi.roleId, pi.roleName) : RobotCreature.Create(info, pos, new Vector3(0, 90, 0), i + ":" + pi.roleId, pi.roleName); if (i != 0) { p.direction = CreatureDirection.BACK; } p.roleId = pi.roleId; p.roleProto = pi.roleProto; p.teamIndex = i; p.avatar = pi.avatar; p.enableUpdate = false; if (isPlayer) { m_player = p; } m_players.Add(p); if (LoadParam.IsMatchRobot) { if (!isPlayer) { moduleAI.AddPlayerAI(p); } moduleAI.AddCreatureToCampDic(p); } CharacterEquip.ChangeCloth(p, pi.fashion); if (pi.pet != null && pi.pet.itemTypeId != 0) { var show = ConfigManager.Get <ShowCreatureInfo>(pi.pet.itemTypeId); if (show == null) { Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", pi.pet.itemTypeId); continue; } var showData = show.GetDataByIndex(0); var data = showData.data.GetValue <ShowCreatureInfo.SizeAndPos>(0); p.pet = PetCreature.Create(p, PetInfo.Create(pi.pet), p.position_ + data.pos, p.eulerAngles, false, Module_Home.PET_OBJECT_NAME); p.pet.enableUpdate = false; if (!moduleAI.IsStartAI) { moduleAI.StartAI(); } moduleAI.AddPetAI(p.pet); } } combatCamera.enabled = false; combatCamera.LookTo(new Vector3((float)((CombatConfig.spvpStart.x + CombatConfig.spvpStart.y) * 0.5), 0, 0)); }
protected override void OnCreateCreatures() { base.OnCreateCreatures(); EventManager.AddEventListener(CreatureEvents.DEAD, OnCreatureDead); //进入迷宫的时候要还原血量 if (modulePVE.reopenPanelType == PVEReOpenPanel.Labyrinth) { int damage = (int)(player.maxHealth * (1.0f - moduleLabyrinth.labyrinthSelfInfo.healthRate / 100f)); player.TakeDamage(null, DamageInfo.CreatePreCalculate(damage)); player.rage = moduleLabyrinth.labyrinthSelfInfo.angerRate; //Logger.LogDetail("进入关卡赋值血量和怒气health = {0},anger = {1}", player.healthRate, player.rageRate); } moduleAI.StartAI(); if (m_player.pet != null) { moduleAI.AddPetAI(m_player.pet); } //创建机器人 int enermyCreatureId = moduleLabyrinth.lastSneakPlayer.GetProto(); PFashion enermyFashion = moduleLabyrinth.sneakPlayerDetail.fashion; m_enermy = RobotCreature.CreateRobot(enermyCreatureId, Vector3.zero + Vector3.right * 5, new Vector3(0f, 90f, 0f), enermyFashion.weapon, enermyFashion.gun, "hero2", moduleLabyrinth.lastSneakPlayer.roleName); m_enermy.gameObject.name = "enermy_robot"; m_enermy.direction = CreatureDirection.BACK; m_enermy.avatar = moduleLabyrinth.lastSneakPlayer.avatar; m_enermy.roleProto = enermyCreatureId; CharacterEquip.ChangeCloth(m_enermy, moduleLabyrinth.sneakPlayerDetail.fashion); //重置属性 ((RobotCreature)m_enermy).ResetRobotAttribute(moduleLabyrinth.sneakPlayerDetail.roleAttrs, enermyFashion); //创建宠物 PItem pet = moduleLabyrinth.lastSneakPlayer.pet; if (pet != null && pet.itemTypeId != 0) { var show = ConfigManager.Get <ShowCreatureInfo>(pet.itemTypeId); if (show == null) { Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", pet.itemTypeId); } var showData = show.GetDataByIndex(0); var data = showData.data.GetValue <ShowCreatureInfo.SizeAndPos>(0); m_enermy.pet = PetCreature.Create(m_enermy, PetInfo.Create(pet), m_enermy.position_ + data.pos, m_enermy.eulerAngles, false, Module_Home.PET_OBJECT_NAME); moduleAI.AddPetAI(m_enermy.pet); } //设置被偷袭玩家BUFF if (moduleLabyrinth.sneakPlayerDetail.buffs != null) { ushort[] buffIds = moduleLabyrinth.sneakPlayerDetail.buffs; for (int i = 0, length = buffIds.Length; i < length; i++) { Buff.Create(buffIds[i], m_enermy); } } moduleAI.AddCreatureToCampDic(m_enermy); moduleAI.AddCreatureToCampDic(player); moduleAI.AddPlayerAI(m_enermy); combatCamera.enabled = false; combatCamera.LookTo(new Vector3((float)((CombatConfig.spvpStart.x + CombatConfig.spvpStart.y) * 0.5), 0, 0)); //set initial health and rage modulePVE.SetPveGameData(EnumPVEDataType.Health, m_player.healthRate); modulePVE.SetPveGameData(EnumPVEDataType.Rage, m_player.rageRate); }
private void OnPostGmLockClass(Event_ e) { var mm = (bool)e.param1; moduleGlobal.LockUI("拼命加载中...", 0.3f, 35.0f); PrepareAssets(Module_Battle.BuildPlayerPreloadAssets(), f => { moduleGlobal.UnLockUI(); if (!f || !this) { return; } if (!mm || !m_player) { var info = modulePlayer.BuildPlayerInfo(); var old = m_player; var pet = m_player?.pet; var pos = m_player ? m_player.position_ : playerStart; var dir = m_player ? m_player.direction : CreatureDirection.FORWARD; m_player = Creature.Create(info, pos, new Vector3(0, 90, 0), true, "player", modulePlayer.name_); m_player.roleId = modulePlayer.id_; m_player.roleProto = modulePlayer.proto; m_player.position = pos; m_player.direction = dir; m_player.teamIndex = old ? old.teamIndex : 0; m_player.roleId = old ? old.roleId : modulePlayer.id_; if (old) { m_player.regenRage = old.regenRage; m_player.regenRagePercent = old.regenRagePercent; m_player.regenHealth = old.regenHealth; m_player.regenHealthPercent = old.regenHealthPercent; m_player.attack = old.attack; } m_player.pet = pet; if (pet) { pet.ParentCreature = m_player; } if (old) { old.Destroy(); } CharacterEquip.ChangeCloth(m_player, moduleEquip.currentDressClothes); _SetDOFFocusTarget(m_player.transform); CreatePlayerAudioListener(); } else { m_player.elementType = (int)modulePlayer.elementType; m_player.UpdateWeapon(moduleEquip.weaponID, moduleEquip.weaponItemID); } }); }