private void CreateNpcModel(int npcId) { string uiname = ((NpcTypeID)npcId).ToString(); var tfNpc = Module_Home.instance.FindChild(uiname); if (tfNpc != null) { moduleHome.HideOthers(uiname); return; } moduleHome.HideOthers(); Level.PrepareAssets(Module_Battle.BuildNpcSimplePreloadAssets(npcId), r => { moduleGlobal.UnLockUI(); if (!r) { return; } var npc = moduleHome.CreateNpc(npcId, Vector3.zero, new Vector3(0, 180, 0), uiname); if (npc) { npc.animator.enabled = false; npc.gameObject.SafeSetActive(true); } moduleHome.HideOthers(uiname); }); }
public void CreatePet(PetInfo rPet) { if (rPet == null) { return; } pet?.Destroy(); pet = null; var rGradeInfo = rPet.UpGradeInfo; if (rGradeInfo == null) { return; } PrepareAssets(Module_Battle.BuildPetSimplePreloadAssets(rPet, null, 0), b => { var show = ConfigManager.Get <ShowCreatureInfo>(rPet.ID); if (show == null) { Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", rPet.ID); return; } var showData = show.GetDataByIndex(1); var data = showData.data.GetValue <ShowCreatureInfo.SizeAndPos>(0); pet = moduleHome.CreatePet(rGradeInfo, data.pos, data.rotation, startPos, false, Module_Home.PET_OBJECT_NAME); pet.eulerAngles = data.rotation; pet.localPosition = data.pos; pet.transform.localScale *= data.size; }); }
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); }
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); }
/// <summary> /// 更新宠物模型 /// </summary> public void RefreshModule() { if (SelectPet == null || m_modeName == SelectPet.UpGradeInfo.mode) { return; } if (m_loadPetCoroutine != null) { Level.current.StopCoroutine(m_loadPetCoroutine); } if (m_loadEffectCoroutine != null) { Level.current.StopCoroutine(m_loadEffectCoroutine); } m_pet?.Destroy(); m_lockEffect?.Destroy(); var playUnlockEffect = modulePet.NewPetList.Contains(SelectPet.ID); m_modeName = SelectPet.UpGradeInfo.mode; m_loadPetCoroutine = Level.PrepareAssets(Module_Battle.BuildPetSimplePreloadAssets(SelectPet, null, 0), b => { var show = ConfigManager.Get <ShowCreatureInfo>(SelectPet.ID); if (show == null) { Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", SelectPet.ID); return; } var showData = show.GetDataByIndex(1); var data = showData.data.GetValue <ShowCreatureInfo.SizeAndPos>(0); m_pet = moduleHome.CreatePet(SelectPet.UpGradeInfo, data.pos, data.rotation, Level.current.startPos, false, PET_OBJECT_NAME); m_pet.eulerAngles = data.rotation; m_pet.localPosition = data.pos; m_pet.transform.localScale *= data.size; if (!modulePet.Contains(SelectPet.ID)) { m_loadEffectCoroutine = Level.PrepareAsset <GameObject>(GeneralConfigInfo.defaultConfig.lockEffect.effect, (t) => { m_lockEffect = m_pet.behaviour.effects.PlayEffect(GeneralConfigInfo.defaultConfig.lockEffect); m_loadEffectCoroutine = null; }); } else if (playUnlockEffect) { m_loadEffectCoroutine = Level.PrepareAsset <GameObject>(GeneralConfigInfo.defaultConfig.unlockEffect.effect, (t) => { m_pet.behaviour.effects.PlayEffect(GeneralConfigInfo.defaultConfig.unlockEffect); m_loadEffectCoroutine = null; }); } m_loadPetCoroutine = null; }); }
private void CreatePlayer() { if (master) { master.Destroy(); master = null; } var oc = ConfigManager.Get <ShowCreatureInfo>(20000)?.GetDataByIndex(modulePlayer.proto) ?? null; if (oc != null && oc.data != null && oc.data.Length > 0) { startCameraOffset = oc.data[0].pos; ResetMainCamera(); } PrepareAssets(Module_Battle.BuildPlayerSimplePreloadAssets(), r => { if (!r) { return; } master = moduleHome.CreatePlayer(); originMasterPos = master.position_; if (modulePVP.opType != OpenWhichPvP.None) { moduleMatch.DispatchModuleEvent(Module_Match.EventComeBackHomeScence); } }); CreateFightingPet(modulePet.FightingPet); }
private void CreatEnemyCreature(PMatchInfo info) { //创建敌人 ShowCreatureInfo showInfo = ConfigManager.Get <ShowCreatureInfo>(10); Vector3_ pos = new Vector3_(1.3, 0, 0); Vector3 rot = new Vector3(0, -110, 0); if (showInfo != null) { for (int i = 0; i < showInfo.forData.Length; i++) { if (showInfo.forData[i].index == info.roleProto) { pos = showInfo.forData[i].data[0].pos; rot = showInfo.forData[i].data[0].rotation; break; } } } var weaponInfo = ConfigManager.Get <PropItemInfo>(info.fashion.weapon); if (weaponInfo == null) { return; } moduleGlobal.LockUI("", 0.5f); Level.PrepareAssets(Module_Battle.BuildPlayerSimplePreloadAssets(info), (r) => { if (!r) { return; } enemy = moduleHome.CreatePlayer(info, pos, CreatureDirection.BACK); enemy.transform.localEulerAngles = rot; moduleGlobal.UnLockUI(); }); if (info.pet != null && info.pet.itemTypeId != 0) { var rPet = PetInfo.Create(info.pet); var assets = new List <string>(); Level.PrepareAssets(Module_Battle.BuildPetSimplePreloadAssets(rPet, assets, 2), b => { 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); enemyPet = moduleHome.CreatePet(rGradeInfo, pos + data.pos, data.rotation, Level.current.startPos, true, Module_Home.FIGHTING_PET_OBJECT_NAME + "_Enemy"); enemyPet.transform.localScale *= data.size; enemyPet.transform.localEulerAngles = data.rotation; }); } }
protected virtual List <string> OnBuildPreloadAssets(List <string> assets = null) { if (assets == null) { assets = new List <string>(); } Module_Battle.BuildPlayerPreloadAssets(assets); return(assets); }
protected override List <string> BuildPreloadAssets() { var asstes = base.BuildPreloadAssets(); if (!moduleNPCDating.isDebug) { asstes.AddRange(Module_NPCDating.GetDatingPreAssets(moduleNPCDating.enterSceneData.eventId)); } asstes.AddRange(Module_Battle.BuildPlayerSimplePreloadAssets());//Ô¤¼ÓÔØÖ÷½Ç×ÊÔ´ return(asstes); }
public void Create_Npc() { Module_Home.instance.HideOthers(uiName); CreateClickBox(); if (npc_creatrue || isCreating) { return; } //在创建一个NPC之前,先找有没有已经创建了这个NPC,避免重复创建 var npc = Module_Home.instance.FindChild(uiName); if (npc) { var behaviour = npc.GetComponent <SceneObjectBehaviour>(); npc_creatrue = behaviour?.sceneObject as Creature; if (npc_creatrue) { npc_creatrue.gameObject.SafeSetActive(false); SetCurNpc(); OnComplate(npc_creatrue); return; } Destroy(npc); } isCreating = true; Module_Global.instance.LockUI("", 0.2f); Level.PrepareAssets(Module_Battle.BuildNpcSimplePreloadAssets((int)npc_Type), r => { Module_Global.instance.UnLockUI(); if (!r) { return; } npc_creatrue = Module_Home.instance.CreateNpc((int)npc_Type, Vector3.zero, new Vector3(0, 180, 0), uiName); if (npc_creatrue) { SetCurNpc(); npc_creatrue.animator.enabled = false; npc_creatrue.gameObject.SafeSetActive(false); OnComplate(npc_creatrue); } isCreating = false; }); }
private void CreatTeamCreature(PMatchProcessInfo info, int index) { //创建敌人 var t = GetTransform(info, index); var pos = t.pos; var rot = t.rotation; var weaponInfo = ConfigManager.Get <PropItemInfo>(info.fashion.weapon); if (weaponInfo == null) { return; } moduleGlobal.LockUI("", 0.5f); m_memberLoadCoroutine = Level.PrepareAssets(Module_Battle.BuildPlayerSimplePreloadAssets(info), r => { if (!r) { return; } teamPlayer = moduleHome.CreatePlayer(info, pos, CreatureDirection.FORWARD); teamPlayer.uiName = Module_Home.TEAM_OBJECT_NAME; teamPlayer.gameObject.name = Module_Home.TEAM_OBJECT_NAME; teamPlayer.transform.localEulerAngles = rot; teamPlayer.transform.localScale = Vector3.one * t.size; moduleGlobal.UnLockUI(); }); if (info.pet != null && info.pet.itemTypeId != 0) { var rPet = PetInfo.Create(info.pet); var assets = new List <string>(); Level.PrepareAssets(Module_Battle.BuildPetSimplePreloadAssets(rPet, assets, 2), b => { 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); teamPlayerPet = moduleHome.CreatePet(rGradeInfo, pos + data.pos, data.rotation, Level.current.startPos, true, Module_Home.TEAM_PET_OBJECT_NAME); teamPlayerPet.transform.localScale *= data.size; teamPlayerPet.transform.localEulerAngles = data.rotation; }); } }
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); }
protected override List <string> BuildPreloadAssets() { var assets = base.BuildPreloadAssets(); for (var i = 0; i < moduleSelectRole.roleList?.Length; i++) { Module_Battle.BuildPlayerSimplePreloadAssets(moduleSelectRole.roleList[i], assets); } assets.Add(StoryConst.THEATRE_MASK_ASSET_NAME); assets.Add(GeneralConfigInfo.defaultConfig.roleSelectEffect.effect); assets.Add("ui_selectcharacter"); return(assets); }
public void CreateFightingPet(PetInfo rPet) { var rGradeInfo = rPet?.UpGradeInfo; if (rGradeInfo == null) { return; } if (fightingPet && fightingPet.weaponID == rGradeInfo.UIstateMachine) { return; } PrepareAssets(Module_Battle.BuildPetSimplePreloadAssets(rPet, null, 2), b => { var show = ConfigManager.Get <ShowCreatureInfo>(rPet.ID); if (show == null) { Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", rPet.ID); return; } if (fightingPet) { fightingPet.Destroy(); fightingPet = null; } var showData = show.GetDataByIndex(0); var data = showData.data.GetValue <ShowCreatureInfo.SizeAndPos>(0); fightingPet = moduleHome.CreatePet(rGradeInfo, data.pos, data.rotation, startPos, true, Module_Home.FIGHTING_PET_OBJECT_NAME); fightingPet.eulerAngles = data.rotation; fightingPet.position_ = fightingPet.localPosition = data.pos; fightingPet.transform.localScale *= data.size; originPetPos = fightingPet.position_; if (recordMasterPos != Vector3_.zero) { var offset = fightingPet.position_ - originMasterPos; fightingPet.position_ = (recordMasterPos + offset); } //切换主界面的宠物待机动作 fightingPet.stateMachine.TranslateTo("StateIdle"); }); }
protected override List <string> OnBuildPreloadAssets(List <string> assets = null) { if (assets == null) { assets = new List <string>(); } var players = LoadParam.players; foreach (var player in players) { Module_Battle.BuildPlayerPreloadAssets(player, assets); } 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); }
/// <summary> /// build random. /// </summary> /// <param name="rBehaviour"></param> /// <param name="bRebuild"></param> /// <returns></returns> public SRandomInfoConditon BuildRandom(int randomId, int maxValue, bool bRebuild = false) { var c = m_preBuildRandom.Find(item => item.randomId == randomId); if (c == null) { //最后的随机数需要加1,因为策划需要从1~maxValue int random = Module_Battle.Range(1, maxValue == 0 ? 2 : maxValue + 1); m_preBuildRandom.Add(new SRandomInfoConditon(randomId, random)); } else { if (bRebuild) { int random = Module_Battle.Range(1, maxValue == 0 ? 2 : maxValue + 1); c.value = random; } } return(c); }
protected override List <string> BuildPreloadAssets() { var assets = base.BuildPreloadAssets(); //收到角色信息后才预加载。否则采用动态加载 if (moduleEquip.weaponID != 0) { assets.AddRange(Module_Battle.BuildPlayerSimplePreloadAssets()); } assets.AddRange(Module_Battle.BuildPetSimplePreloadAssets(modulePet.FightingPet, null, 2)); //切换场景回到主城的时候,需要预加载未完成的资源 if (moduleGuide.currentGuide != null) { assets.AddRange(moduleGuide.GetPreLoadAssets(moduleGuide.currentGuide)); } assets.AddRange(FaceName.cachedAssets); return(assets); }
protected override List <string> BuildPreloadAssets() { var assets = base.BuildPreloadAssets(); assets.Add(Module_Bordlands.BORDLAND_MONSTER_ANIMATOR_NAME); assets.Add(headPanelName); assets.Add(GeneralConfigInfo.ssceneTextObject); assets.AddRange(Module_Battle.BuildPlayerPreloadAssets()); if (moduleLabyrinth.labyrinthInfo) { assets.Add(moduleLabyrinth.labyrinthInfo.activeEffect); assets.Add(moduleLabyrinth.labyrinthInfo.inactiveEffect); } var emjioList = ConfigManager.GetAll <FaceName>(); for (int i = 0; i < emjioList.Count; i++) { assets.Add(emjioList[i]?.head_icon); } return(assets); }
private void OnPostGmLockClass(Event_ e) { var mm = (bool)e.param1; if (!mm || !master) { CreatePlayer(); } else { moduleGlobal.LockUI("拼命加载中...", 1.0f, 5.0f); PrepareAssets(Module_Battle.BuildPlayerSimplePreloadAssets(), f => { moduleGlobal.UnLockUI(); if (!f || !master) { return; } master.UpdateWeapon(moduleEquip.weaponID, moduleEquip.weaponItemID); }); } }
protected override List <string> OnBuildPreloadAssets(List <string> assets = null) { if (assets == null) { assets = new List <string>(); } // Player shadow assets.Add(CombatConfig.sdefaultSelfShadow); // Player model var info = ConfigManager.Get <CreatureInfo>(TrainProtoID); if (info) { assets.AddRange(info.models); } // Player weapons Module_Battle.BuildWeaponPreloadAssets(TrainProtoID, info.gender, info.weaponID, info.weaponItemID, info.offWeaponID, info.offWeaponItemID, assets, true); assets.AddRange(OnBuildPVEAssets()); int loadedCount = 0; foreach (var item in m_unitSceneEvents) { assets.AddRange(item.allAssets); loadedCount++; if (loadedCount >= MAX_LOADED_UNIT_SCENE_COUNT) { break; } } return(assets); }
protected override List <string> OnBuildPreloadAssets(List <string> assets = null) { base.OnBuildPreloadAssets(assets); if (assets == null) { assets = new List <string>(); } var member = moduleTeam.members; if (member != null) { foreach (var m in member) { if (m.roleId == modulePlayer.id_) { continue; } Module_Battle.BuildPlayerPreloadAssets(m, assets); } } return(assets); }
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 OnHit(AttackCollider c, AttackInfo a, int t) { if (null == m_creature) { return; } var alive = !m_creature.isDead; var ts = t == byte.MaxValue ? AttackInfo.hitProtectTrans : a.targetStates[t]; var cc = c.creature; var ss = c.currentState; var passive = ss.info.ignoreTough || (!m_creature.tough || a.breakToughLevel > m_creature.toughLevel) || m_creature.weak && a.fromBullet; // can we enter passive state ? var toState = -1; if (passive) { var pt = 0L; var breakTough = m_creature.tough && (ss.info.ignoreTough || a.breakToughLevel > m_creature.toughLevel || cc.breakToughLevel > m_creature.toughLevel); var isCatch = ss.info.catchState > 0; if (isCatch) { pt = pt.BitMask(StateMachine.PASSIVE_CATCH, true); } if (breakTough) { pt = pt.BitMask(StateMachine.PASSIVE_TOUGH, true); } if (a.fromBullet && (m_creature.weak || c.creature.HawkEye)) { pt = pt.BitMask(StateMachine.PASSIVE_WEAK, true); } var opt = m_stateMachine.GetLong(StateMachineParam.forcePassive) >> 48 & 0xFFFF; if (opt == 0 || pt.BitMask(StateMachine.PASSIVE_CATCH) || !opt.BitMask(StateMachine.PASSIVE_CATCH) && pt.BitMask(StateMachine.PASSIVE_WEAK)) { var tid = breakTough && m_creature.HasState(ts.toToughStateID) ? ts.toToughStateID : ts.toStateID; toState = tid; var p = pt << 48 | (long)cc.id << 32 | (uint)tid; m_stateMachine.SetParam(StateMachineParam.forcePassive, p); if (pt.BitMask(StateMachine.PASSIVE_CATCH)) { m_creature.RemoveBuff(BuffInfo.EffectTypes.Freez); } if (c.type == AttackColliderTypes.Attack) { var mask = m_stateMachine.GetStateMask(toState); cc.stateMachine.SetParam(StateMachineParam.targetGroupMask, mask); cc.stateMachine.SetParam(StateMachineParam.targetHitGroupMask, m_stateMachine.GetLong(StateMachineParam.groupMask)); cc.stateMachine.SetParam(StateMachineParam.targetConfigID, m_creature.configID); if (isCatch && !mask.BitMasks(ss.info.ignoreCatchPosGroups) && m_creature.HasState(toState)) { if (ss.info.catchState == 1) { m_creature.position_ = cc.position_; } else { cc.position_ = m_creature.position_; } } } } else { passive = false; } } if (c.type == AttackColliderTypes.Attack) { cc.stateMachine.SetParam(StateMachineParam.hit, true); } m_stateMachine.SetParam(StateMachineParam.hited, cc.id); cc.DispatchAttackEvent(m_creature, a); if (!m_creature.isDead) { cc.rage += a.selfRageReward * (1 + cc.attackRageMul); // ignore rage reward if target is dead } m_creature.DispatchEvent(CreatureEvents.ATTACKED, Event_.Pop(cc, a)); if (a.fromBullet) { m_creature.DispatchEvent(CreatureEvents.SHOOTED, Event_.Pop(m_creature, a)); } if (!m_creature.isDead) // ignore rage reward if target is dead { m_creature.rage += a.targetRageReward * (1 + m_creature.attackedRageMul); m_creature.TakeDamage(cc, cc.CalculateDamage(a, m_creature, ss.damageMul)); } else if (!alive) { UpdateDeadCombo(); } if (a.freezTime > 0) { m_stateMachine.Pending(a.freezTime, passive, alive && m_creature.isDead); if (!a.fromEffect) { c.stateMachine.Pending(a.freezTime); } } if (passive) { if (a.preventTurn == 0) { if (a.fromBullet) { m_creature.FaceTo(cc); } else { var direction = CalculateHitDirection(c, a, m_creature.x); if (direction != 0) { m_creature.direction = direction < 0 ? CreatureDirection.BACK : CreatureDirection.FORWARD; } } } if (a.acttackSlide != 0) { m_creature.Knockback(m_creature.isForward ? -a.acttackSlide * 0.1 : a.acttackSlide * 0.1); } } var s = a.soundEffect.SelectSound(m_creature.roleProto, m_creature.gender); if (!s.isEmpty) { AudioManager.PlayAudio(s.sound, a.soundEffect.isVoice || s.isVoice ? AudioTypes.Voice : AudioTypes.Sound, false, a.soundEffect.overrideType); } if (c.type == AttackColliderTypes.Attack && !a.ignoreHitEffect) { behaviour.effects.PlayEffect(c.hitEff); } if (!m_creature.isDead) // do not trigger buffs if target is dead { var level = 1; if (cc is PetCreature) { level = ((PetCreature)cc).petInfo.AdditiveLevel; } var b = a.selfBuff; if (b.intValue0 != 0 && (b.doubleValue0 == 0 || Module_Battle.Range() <= b.doubleValue0)) { Buff.Create(b.intValue0, cc, null, b.intValue1, -1, level); } b = a.targetBuff; if (b.intValue0 != 0 && (b.doubleValue0 == 0 || Module_Battle.Range() <= b.doubleValue0)) { Buff.Create(b.intValue0, m_creature, cc, b.intValue1, -1, level); } } #region Debug log #if DEVELOPMENT_BUILD || UNITY_EDITOR Logger.LogInfo("[{3}:{4}-{5}], [{0}] hited by attackInfo [{1}], translate to state [{2}]", m_creature.gameObject.name, a.ID, toState == ts.toStateID ? ts.toState : toState == ts.toToughStateID ? ts.toToughState : string.Empty, Level.levelTime, creature.frameTime, creature.frameCount); #endif #if AI_LOG Module_AI.LogBattleMsg(m_creature, "[m_creature.tough = {0},currentState is {1} ss.info.ignoreTough = {2} attackinfo.breaktoughLevel = {3} m_creature.toughLevel = {4} cc.breakToughLevel = {5}", m_creature.tough, m_creature.stateMachine.currentState.name, ss.info.ignoreTough, a.breakToughLevel, m_creature.toughLevel, cc.breakToughLevel); Module_AI.LogBattleMsg(m_creature, "[[{0}] hited by attackInfo [{1}], translate to state [{2}]", m_creature.gameObject.name, a.ID, toState == ts.toStateID ? ts.toState : toState == ts.toToughStateID ? ts.toToughState : string.Empty); #endif #endregion }
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); } }); }
/// <summary> /// 针对不同的模式可能会加载不同的资源 /// </summary> /// <param name="plotId"></param> /// <param name="type">1代表剧场对话,2代表战斗对话</param> /// <returns></returns> public static List <string> GetPerStoryPreAssets(int plotId, EnumStoryType type) { List <string> list = new List <string>(); switch (type) { case EnumStoryType.TheatreStory: case EnumStoryType.NpcTheatreStory: list.Add(StoryConst.THEATRE_STORY_ASSET_NAME); list.Add(StoryConst.THEATRE_MASK_ASSET_NAME); list.Add(StoryConst.THEATRE_GM_ASSET_NAME); //list.Add(StoryConst.DEFALUT_CONTENT_BG); break; case EnumStoryType.FreeBattleStory: case EnumStoryType.PauseBattleStory: list.Add(StoryConst.BATTLE_STORY_ASSET_NAME); break; } StoryInfo story = ConfigManager.Get <StoryInfo>(plotId); if (story) { //if (type == EnumStoryType.TheatreStory) list.Add("character_render_camera"); //load StoryInfo.StoryItem item = null; for (int i = 0; i < story.storyItems.Length; i++) { if (i > GeneralConfigInfo.sstoryPreLoadNum && GeneralConfigInfo.sstoryPreLoadNum > 0) { break; } item = story.storyItems[i]; #region theatre story if (type == EnumStoryType.TheatreStory || type == EnumStoryType.NpcTheatreStory) { //npc assets for (int j = 0; j < item.talkingRoles.Length; j++) { NpcInfo npc = ConfigManager.Get <NpcInfo>(item.talkingRoles[j].roleId); if (npc == null) { continue; } var npcAssets = Module_Battle.BuildNpcSimplePreloadAssets(npc.ID); for (int m = 0; m < npcAssets.Count; m++) { list.Add(npcAssets[m]); } } //texture assets list.Add(item.background); list.Add(item.contentBg); if (!item.playerIconDetail.Equals("PlayerIcon")) { list.Add(item.playerIconDetail); } //model assets if (item.models != null && item.models.Length > 0) { for (int ii = 0; ii < item.models.Length; ii++) { list.Add(item.models[ii].model); } } } #endregion #region common data list.Add(item.effect); if (item.effect.Equals(StoryConst.EYE_CLIP_EFFECT)) { list.Add(StoryConst.EYE_GAUSS_MATERIAL_ASSET); } //music assets if (item.musicData.validMusic && !item.musicData.musicName.Equals(StoryConst.STOP_CURRENT_MUSIC_FLAG) && !item.musicData.musicName.Equals(StoryConst.RESET_CURRENT_MUSIC_FLAG) && !item.musicData.musicName.Equals(StoryConst.RESET_LAST_MUSIC_FLAG)) { list.Add(item.musicData.musicName); } //voice assets list.Add(item.voiceName); //sound effect assets for (int j = 0; j < item.soundEffect.Length; j++) { list.Add(item.soundEffect[j].soundName); } #endregion } } return(list); }
public static List <string> GetPerStoryPreAssets(int plotId, EnumStoryType type, int index) { List <string> list = new List <string>(); StoryInfo story = ConfigManager.Get <StoryInfo>(plotId); index += GeneralConfigInfo.sstoryPreLoadNum; if (story) { if (story.storyItems.Length - 1 < index || index < 0) { return(null); } StoryInfo.StoryItem item = story.storyItems[index]; #region theatre story if (type == EnumStoryType.TheatreStory || type == EnumStoryType.NpcTheatreStory) { //npc assets for (int j = 0; j < item.talkingRoles.Length; j++) { NpcInfo npc = ConfigManager.Get <NpcInfo>(item.talkingRoles[j].roleId); if (npc == null) { continue; } var npcAssets = Module_Battle.BuildNpcSimplePreloadAssets(npc.ID); for (int m = 0; m < npcAssets.Count; m++) { list.Add(npcAssets[m]); } } //texture assets list.Add(item.background); list.Add(item.contentBg); if (!item.playerIconDetail.Equals("PlayerIcon")) { list.Add(item.playerIconDetail); } //model assets if (item.models != null && item.models.Length > 0) { for (int ii = 0; ii < item.models.Length; ii++) { list.Add(item.models[ii].model); } } } #endregion #region common data //full screen effect list.Add(item.effect); if (item.effect.Equals(StoryConst.EYE_CLIP_EFFECT)) { list.Add(StoryConst.EYE_GAUSS_MATERIAL_ASSET); } //music assets if (item.musicData.validMusic && !item.musicData.musicName.Equals(StoryConst.STOP_CURRENT_MUSIC_FLAG) && !item.musicData.musicName.Equals(StoryConst.RESET_CURRENT_MUSIC_FLAG) && !item.musicData.musicName.Equals(StoryConst.RESET_LAST_MUSIC_FLAG) ) { list.Add(item.musicData.musicName); } //voice assets list.Add(item.voiceName); //sound effect assets for (int j = 0; j < item.soundEffect.Length; j++) { list.Add(item.soundEffect[j].soundName); } #endregion } return(list); }
private void HandleFrameEvent() { var creature = stateMachine.creature; if (m_currentFrame == info.processes.x) { stateMachine.SetParam(StateMachineParam.exit, true); stateMachine.SetParam(StateMachineParam.process, 1); } if (m_currentFrame == info.processes.y) { m_waitToResetKey = true; // Clear key input next update } if (info.ignoreInput.y > 0 && info.ignoreInput.x != info.ignoreInput.y) { if (m_currentFrame == info.ignoreInput.x) { m_acceptInput = false; } else if (m_currentFrame == info.ignoreInput.y) { m_acceptInput = true; } } if (m_currentFrame == info.landingFrame && !creature.onGround) { m_falling = true; if (m_motionIndex > 1) { var velocity = (m_motion.points[m_motionIndex] - m_motion.points[m_motionIndex - 1]) * 0.3; if (velocity.magnitude == 0) { velocity = defaultFallSpeed; } else { velocity = new Vector3_(!stateMachine.creature.isForward ? -velocity.z : velocity.z, velocity.y >= 0 ? defaultFallSpeed.y : velocity.y, -velocity.x); } #region Debug log #if DEVELOPMENT_BUILD || UNITY_EDITOR if (velocity.z != 0) { Logger.LogError("<color=#00DDFF><b>[{6}:{5}]</b></color>, state <color=#00DDFF><b>[{0}:{1}]</b></color> has invalid landing frame <color=#00DDFF><b>[{2}]</b></color>, fallSpeed has Z velocity <color=#00DDFF><b>[{3}]</b></color>, motion ID: <color=#00DDFF><b>[{4}]</b></color>, last frame: <color=#00DDFF><b>[{7}]</b></color>", ID, name, info.landingFrame, velocity.z, m_motion.ID, parent.ID, parent.GetType(), m_motion.points[m_motionIndex - 1]); } #endif #endregion velocity.z = 0; // @TODO: Fix velocity validation fallSpeed = velocity; } } if (m_curSectionIdx < info.sections.Length && info.sections[m_curSectionIdx].startFrame == m_currentFrame) { creature.behaviour.attackCollider.SetAttackBox(info.sections[m_curSectionIdx].attackBox, stateMachine.GetHitEffect(off), creature.isForward); ++m_curSectionIdx; stateMachine.SetParam(StateMachineParam.section, m_curSectionIdx); } if (m_curInvisibleIndex < info.invisibles.Length && info.invisibles[m_curInvisibleIndex].startFrame == m_currentFrame) { var invisible = info.invisibles[m_curInvisibleIndex].disable; creature.SetLayer(invisible ? Layers.INVISIBLE : -1, invisible); ++m_curInvisibleIndex; } if (m_curWeakIndex < info.weaks.Length && info.weaks[m_curWeakIndex].startFrame == m_currentFrame) { if (info.weaks[m_curWeakIndex].disable) { creature.weakCount++; weakCount++; } else if (weakCount > 0) { creature.weakCount--; weakCount--; } ++m_curWeakIndex; } if (m_curToughIdx < info.toughs.Length && info.toughs[m_curToughIdx].startFrame == m_currentFrame) { var idx = m_toughs.Count - 1; if (idx > -1) { creature.RemoveToughState(m_toughs[idx]); m_toughs.RemoveAt(idx); UpdateRimLightState(-1); } var tlvl = info.toughs[m_curToughIdx].intValue0; if (tlvl > 0) { m_toughs.Add(creature.AddToughState(tlvl)); UpdateRimLightState(1); } ++m_curToughIdx; } if (info.invincible.y > 0) { if (m_currentFrame == info.invincible.x) { creature.invincibleCount++; invincibleCount++; UpdateRimLightState(1); } if (m_currentFrame == info.invincible.y + 1) { creature.invincibleCount--; invincibleCount--; UpdateRimLightState(-1); } } if (info.hideHpSlider.y > 0) { if (m_currentFrame == info.hideHpSlider.x) { hideHpSliderCount++; creature.hpVisiableCount--; } if (m_currentFrame == info.hideHpSlider.y + 1) { hideHpSliderCount--; creature.hpVisiableCount++; } } if (info.ethereal.y > 0) { if (m_currentFrame == info.ethereal.x) { creature.etherealCount++; etherealCount++; } if (m_currentFrame == info.ethereal.y + 1) { creature.etherealCount--; etherealCount--; } } if (info.passiveEthereal.y > 0) { if (m_currentFrame == info.passiveEthereal.x) { creature.passiveEtherealCount++; passiveEtherealCount++; } if (m_currentFrame == info.passiveEthereal.y + 1) { creature.passiveEtherealCount--; passiveEtherealCount--; } } while (m_curBuffIndex < info.buffs.Length && info.buffs[m_curBuffIndex].startFrame == m_currentFrame) { var b = info.buffs[m_curBuffIndex]; if (b.doubleValue0 == 0 || Module_Battle.Range() < b.doubleValue0) { var pet = creature as PetCreature; if (pet && b.intValue0 <= 0) { var skill = pet.GetSkillByState(name); if (skill) { var count = skill.skillInfo.buffs.Length; for (int i = 0; i < count; i++) { Buff.Create(skill.skillInfo.buffs[i], creature, creature, 0, -1, pet.petInfo.AdditiveLevel); } } } else { Buff.Create(b.intValue0, creature, null, b.intValue1); } } ++m_curBuffIndex; } var effects = info.effects; while (m_curEffectIdx < effects.Length && effects[m_curEffectIdx].startFrame == m_currentFrame) { if (m_inheritEffectsFrame.Contains(m_curEffectIdx)) { ++m_curEffectIdx; continue; } if (!creature.isPlayer && effects[m_curEffectIdx].self) { ++m_curEffectIdx; continue; } var eff = creature.behaviour.effects.PlayEffect(effects[m_curEffectIdx]); if (eff) { eff.localTimeScale = animationSpeed; if (eff.name == "effect_ringring" && info.fatalRadius > 0) { eff.lifeTime = -1; eff.localScale = Vector3.one * (float)info.fatalRadius; } } if (effects[m_curEffectIdx].inherit) { m_inheritEffectsFrame.Add(m_curEffectIdx); m_inheritEffects.Add(eff); } ++m_curEffectIdx; } while (m_curFlyingEffectIdx < info.flyingEffects.Length && info.flyingEffects[m_curFlyingEffectIdx].startFrame == m_currentFrame) { creature.behaviour.effects.PlayEffect(info.flyingEffects[m_curFlyingEffectIdx], stateMachine.GetHitEffect(off)); ++m_curFlyingEffectIdx; } while (m_curSoundEffectIdx < info.soundEffects.Length && info.soundEffects[m_curSoundEffectIdx].startFrame == m_currentFrame) { var se = info.soundEffects[m_curSoundEffectIdx]; ++m_curSoundEffectIdx; if (se.isEmpty || !se.global && !creature.isPlayer || UnityEngine.Random.Range(0, 1.0f) > se.rate) { continue; } var s = se.SelectSound(creature.roleProto, creature.gender); if (!s.isEmpty) { if (!se.interrupt) { AudioManager.PlayAudio(s.sound, se.isVoice || s.isVoice ? AudioTypes.Voice : AudioTypes.Sound, false, se.overrideType); } else { AudioManager.PlayAudio(s.sound, se.isVoice || s.isVoice ? AudioTypes.Voice : AudioTypes.Sound, false, se.overrideType, h => { if (h) { m_audios.Add(h.id); } }); } } } if (m_curDarkIndex < info.darkScreens.Length && info.darkScreens[m_curDarkIndex].startFrame == m_currentFrame) { var alpha = (float)info.darkScreens[m_curDarkIndex].doubleValue0; var draw = alpha > 0; darkCount += draw ? 1 : -1; Camera_Combat.Dark(draw ? 1 : -1, alpha); ++m_curDarkIndex; } if (m_curRimIndex < info.rimLights.Length && info.rimLights[m_curRimIndex].startFrame == m_currentFrame) { m_rimLight = !info.rimLights[m_curRimIndex].disable; UpdateRimLightState(); ++m_curRimIndex; } if (m_curShakeIdx < info.cameraShakes.Length && info.cameraShakes[m_curShakeIdx].startFrame == m_currentFrame) { var shake = ConfigManager.Get <CameraShakeInfo>(info.cameraShakes[m_curShakeIdx].intValue0); if (shake) { Camera_Combat.Shake(shake.intensity, shake.duration * 0.001f, shake.range, creature); } ++m_curShakeIdx; } if (m_curHideIdx < info.hideWeapons.Length && info.hideWeapons[m_curHideIdx].startFrame == m_currentFrame) { var hide = info.hideWeapons[m_curHideIdx].disable; creature.behaviour.SetWeaponVisibility(-1, !hide, false); ++m_curHideIdx; } if (m_curHideOffIdx < info.hideOffWeapons.Length && info.hideOffWeapons[m_curHideOffIdx].startFrame == m_currentFrame) { var hide = info.hideOffWeapons[m_curHideOffIdx].disable; creature.behaviour.SetWeaponVisibility(-1, m_showOffWeapon && !hide, true); ++m_curHideOffIdx; } if (m_curHidePetIdx < info.hidePets.Length && info.hidePets[m_curHidePetIdx].startFrame == m_currentFrame) { if (creature.pet) { var hidePet = info.hidePets[m_curHidePetIdx].disable; creature.pet.enabledAndVisible = !hidePet; } ++m_curHidePetIdx; } if (m_curActorIdx < info.sceneActors.Length && info.sceneActors[m_curActorIdx].frame == m_currentFrame) { var a = info.sceneActors[m_curActorIdx]; var actor = (Level.current as Level_Battle)?.CreateSceneActor( a.actorID, creature.position_ + a.offset * (creature.direction == CreatureDirection.FORWARD ? 1 :-1), creature.direction, a.groupID, a.level); ++m_curActorIdx; if (actor == null) { return; } actor.SetCreatureCamp(creature.creatureCamp); BuffContext c = new BuffContext { id = 444, level = 1, owner = actor, delay = a.lifeTime }; Buff.Create(c); } }