| | |
| | | using System; |
| | | using DG.Tweening; |
| | | using Spine; |
| | | using System.Linq; |
| | | using PlasticGui.WorkspaceWindow.BranchExplorer; |
| | | |
| | | |
| | | public class SkillBase |
| | | { |
| | | protected H0604_tagUseSkillAttack tagUseSkillAttack; |
| | | protected HB427_tagSCUseSkill tagUseSkillAttack; |
| | | |
| | | protected SkillConfig skillConfig; |
| | | |
| | |
| | | |
| | | protected List<GameNetPackBasic> packList; |
| | | |
| | | protected SkillBase otherSkill; |
| | | protected SkillRecordAction otherSkillAction; |
| | | |
| | | protected List<H0704_tagRolePackRefresh> dropPackList = new List<H0704_tagRolePackRefresh>(); |
| | | |
| | | protected List<HB405_tagMCAddExp> expPackList = new List<HB405_tagMCAddExp>(); |
| | | |
| | | public SkillBase(BattleObject _caster, SkillConfig _skillCfg, H0604_tagUseSkillAttack vNetData, List<GameNetPackBasic> _packList, BattleField _battleField = null) |
| | | public SkillBase(BattleObject _caster, SkillConfig _skillCfg, HB427_tagSCUseSkill vNetData, List<GameNetPackBasic> _packList, BattleField _battleField = null) |
| | | { |
| | | caster = _caster; |
| | | skillConfig = _skillCfg; |
| | |
| | | battleField = _battleField; |
| | | packList = _packList; |
| | | |
| | | } |
| | | } |
| | | |
| | | public virtual void Run() |
| | | { |
| | |
| | | { |
| | | curFrame++; |
| | | } |
| | | |
| | | if (otherSkillAction != null) |
| | | { |
| | | if (otherSkillAction.IsFinished()) |
| | | { |
| | | otherSkillAction = null; |
| | | OnSkillFinished(); |
| | | } |
| | | else |
| | | { |
| | | otherSkillAction.Run(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | protected virtual void OnActiveSkillFrame() |
| | | { |
| | | |
| | | } |
| | | |
| | | protected virtual void OnStartSkillFrame() |
| | | { |
| | | |
| | | } |
| | | |
| | | protected virtual void OnEndSkillFrame() |
| | | { |
| | | |
| | | } |
| | | |
| | | public void Pause() |
| | | { |
| | |
| | | break; |
| | | case SkillCastMode.Target: |
| | | // 目标是敌方主目标 |
| | | BattleObject mainTarget = battleField.battleObjMgr.GetBattleObject((int)tagUseSkillAttack.AttackID); |
| | | if (tagUseSkillAttack.HurtCount <= 0) |
| | | { |
| | | Debug.LogError("技能攻击包没有目标 HurtCount <= 0"); |
| | | OnSkillFinished(); |
| | | return; |
| | | } |
| | | |
| | | var mainHurt = tagUseSkillAttack.HurtList[0]; |
| | | |
| | | BattleObject mainTarget = battleField.battleObjMgr.GetBattleObject((int)mainHurt.ObjID); |
| | | if (mainTarget == null) |
| | | { |
| | | Debug.LogError("目标为空 mainTarget == null AttackID : " + tagUseSkillAttack.AttackID); |
| | | Debug.LogError("目标为空 mainTarget == null ObjID : " + mainHurt.ObjID); |
| | | OnSkillFinished(); |
| | | return; |
| | | } |
| | |
| | | // DashToTarget(() => BackToOrigin(OnSkillFinished)); |
| | | // break; |
| | | default: |
| | | Debug.LogError("暂时不支持其他的方式释放 有需求请联系策划"); |
| | | Debug.LogError("暂时不支持其他的方式释放 有需求请联系策划" + skillConfig.SkillID); |
| | | OnSkillFinished(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // 冲刺的技能 动作 跟移动 是同时进行的 移动到目标的一瞬间就要进行技能逻辑 |
| | | // protected void DashToTarget(Action _onComplete) |
| | | // { |
| | | // TrackEntry entry = PlayCastAnimation(); |
| | | // BattleObject mainTarget = battleField.battleObjMgr.GetBattleObject((int)tagUseSkillAttack.AttackID); |
| | | // if (mainTarget == null) |
| | | // { |
| | | // Debug.LogError("目标为空 mainTarget == null AttackID : " + tagUseSkillAttack.AttackID); |
| | | // _onComplete?.Invoke(); |
| | | // return; |
| | | // } |
| | | |
| | | // // 做一个微微的提前 |
| | | // MoveToTarget(mainTarget.Camp, mainTarget.teamHero.positionNum, entry.AnimationEnd - 0.05f, () => DoSkillLogic(_onComplete)); |
| | | // } |
| | | |
| | | // 这里其实是技能后摇结束的地方 |
| | | protected virtual void DoSkillLogic(Action _onComplete = null) |
| | | { |
| | | |
| | | |
| | | } |
| | | |
| | | protected TrackEntry PlayCastAnimation(Action onComplete = null) |
| | |
| | | // 高亮所有目标 |
| | | HashSet<BattleObject> highlightList = new HashSet<BattleObject>(battleField.battleObjMgr.GetBattleObjList(tagUseSkillAttack)); |
| | | highlightList.Add(caster); |
| | | |
| | | |
| | | |
| | | // 把这些BO全高亮 或者说把除了这些的都放在遮罩后面 |
| | | // YYL TODO |
| | | } |
| | | |
| | | // 命中目标后的回调 正常是以各技能的方式来处理的 |
| | | protected virtual void OnHitTargets(int _hitIndex, List<H0604_tagUseSkillAttack.tagSkillHurtObj> hitList) |
| | | protected virtual void OnHitTargets(int _hitIndex, List<HB427_tagSCUseSkill.tagSCUseSkillHurt> hitList) |
| | | { |
| | | for (int i = 0; i < hitList.Count; i++) |
| | | { |
| | | H0604_tagUseSkillAttack.tagSkillHurtObj hurt = hitList[i]; |
| | | HB427_tagSCUseSkill.tagSCUseSkillHurt hurt = hitList[i]; |
| | | |
| | | BattleObject target = caster.battleField.battleObjMgr.GetBattleObject((int)hurt.ObjID); |
| | | if (target == null) |
| | |
| | | |
| | | OnHitEachTarget(target, totalDamage, damageList, ref hurt); |
| | | } |
| | | } |
| | | |
| | | HandleDead(); |
| | | } |
| | | |
| | | protected void HandleDead() |
| | | { |
| | | var deadPackList = FindDeadPack(); |
| | | CheckAfterDeadhPack(); |
| | | |
| | | // 处理掉落包 提前distribute之后 PackManager才有掉落物 所以不跟assignexp一样distribute |
| | | foreach (var _dropPack in dropPackList) |
| | | { |
| | | PackageRegedit.Distribute(_dropPack); |
| | | packList.Remove(_dropPack); |
| | | } |
| | | |
| | | // 获取掉落物品 |
| | | var dropPack = PackManager.Instance.GetSinglePack(PackType.DropItem); |
| | | var itemDict = dropPack.GetAllItems(); |
| | | List<ItemModel> itemList = new List<ItemModel>( |
| | | from item in itemDict.Values |
| | | where item != null && item.isAuction |
| | | select item); |
| | | |
| | | int deadCount = deadPackList.Count; |
| | | |
| | | // 分配掉落和经验 |
| | | var dropAssign = AssignDrops(itemList, deadCount); |
| | | var expAssign = AssignExp(expPackList, deadCount); |
| | | |
| | | // 构造 BattleDrops 并分配 |
| | | for (int i = 0; i < deadCount; i++) |
| | | { |
| | | BattleObject deadTarget = battleField.battleObjMgr.GetBattleObject((int)deadPackList[i].ObjID); |
| | | List<ItemModel> itemModelDrops = dropAssign[i]; |
| | | List<int> itemModelDropsIndexList = new List<int>( |
| | | from item in itemModelDrops select item.gridIndex); |
| | | BattleDrops battleDrops = new BattleDrops() |
| | | { |
| | | rectTransform = deadTarget.heroRectTrans, |
| | | dropItemPackIndex = itemModelDropsIndexList, |
| | | expDrops = expAssign[i] |
| | | }; |
| | | deadTarget.PushDropItems(battleDrops); |
| | | } |
| | | |
| | | // 分发死亡包 |
| | | foreach (var deadPack in deadPackList) |
| | | { |
| | | PackageRegedit.Distribute(deadPack); |
| | | packList.Remove(deadPack); |
| | | } |
| | | deadPackList.Clear(); |
| | | } |
| | | |
| | | |
| | | // 分配掉落 |
| | | protected List<List<ItemModel>> AssignDrops(List<ItemModel> itemList, int deadCount) |
| | | { |
| | | var dropAssign = new List<List<ItemModel>>(deadCount); |
| | | for (int i = 0; i < deadCount; i++) |
| | | dropAssign.Add(new List<ItemModel>()); |
| | | for (int i = 0; i < itemList.Count; i++) |
| | | dropAssign[i % deadCount].Add(itemList[i]); |
| | | return dropAssign; |
| | | } |
| | | |
| | | // 分配经验:每个原始包都平均分配到每个死亡对象 |
| | | protected List<List<HB405_tagMCAddExp>> AssignExp(List<HB405_tagMCAddExp> expList, int deadCount) |
| | | { |
| | | var expAssign = new List<List<HB405_tagMCAddExp>>(deadCount); |
| | | for (int i = 0; i < deadCount; i++) |
| | | expAssign.Add(new List<HB405_tagMCAddExp>()); |
| | | |
| | | foreach (var expPack in expList) |
| | | { |
| | | long totalExp = GeneralDefine.GetFactValue(expPack.Exp, expPack.ExpPoint); |
| | | long avgExp = totalExp / deadCount; |
| | | long remain = totalExp % deadCount; |
| | | |
| | | for (int i = 0; i < deadCount; i++) |
| | | { |
| | | long assignExp = avgExp + (i < remain ? 1 : 0); |
| | | long expPoint = assignExp / 100000000; |
| | | long exp = assignExp % 100000000; |
| | | var newPack = new HB405_tagMCAddExp |
| | | { |
| | | Exp = (uint)exp, |
| | | ExpPoint = (uint)expPoint, |
| | | Source = expPack.Source // 保持原包来源 |
| | | }; |
| | | expAssign[i].Add(newPack); |
| | | } |
| | | packList.Remove(expPack); |
| | | } |
| | | return expAssign; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 保证所有分配项加起来等于totalDamage,避免因整除导致的误差 |
| | |
| | | return fixedDamageList; |
| | | } |
| | | |
| | | protected virtual void OnHitEachTarget(BattleObject target, long totalDamage, List<long> damageList, ref H0604_tagUseSkillAttack.tagSkillHurtObj hurt) |
| | | protected virtual void OnHitEachTarget(BattleObject target, long totalDamage, List<long> damageList, ref HB427_tagSCUseSkill.tagSCUseSkillHurt hurt) |
| | | { |
| | | target.Hurt(damageList, totalDamage, hurt.AttackType); |
| | | target.Hurt(damageList, totalDamage, hurt.AttackTypes); |
| | | |
| | | // 击中目标的时候,不管近战远程 都确认一下是否有爆炸特效 然后播放 |
| | | if (skillConfig.ExplosionEffectId > 0) |
| | |
| | | skillConfig.ExplosionEffectId, |
| | | target.heroGo.transform |
| | | ); |
| | | } |
| | | |
| | | // 受伤之后辨别死亡状态 死亡包其实前后帧会多次触发 应该要即时remove其他的包来保证不重复 |
| | | if (target.IsDead()) |
| | | { |
| | | // SkillRecordAction里的drop事件前移到dead之后 |
| | | HB422_tagMCTurnFightObjDead deadPack = FindDeadPack(target); |
| | | CheckAfterDeadhPack(target, deadPack); |
| | | if (deadPack != null) |
| | | { |
| | | // 处理掉落包 |
| | | for (int i = 0; i < dropPackList.Count; i++) |
| | | { |
| | | PackageRegedit.Distribute(dropPackList[i]); |
| | | } |
| | | |
| | | dropPackList.Clear(); |
| | | |
| | | target.PushExpPackList(new List<HB405_tagMCAddExp>(expPackList)); |
| | | |
| | | expPackList.Clear(); |
| | | |
| | | // 处理死亡包 |
| | | PackageRegedit.Distribute(deadPack); |
| | | packList.Remove(deadPack); |
| | | } |
| | | |
| | | // 复活包暂时不管 可能是技能的包 |
| | | // HB423_tagMCTurnFightObjReborn rebornPack = FindRebornPack(target); |
| | | // if (rebornPack != null) |
| | | // { |
| | | // // 处理复活包 |
| | | // PackageRegedit.Distribute(rebornPack); |
| | | // packList.Remove(rebornPack); |
| | | // } |
| | | } |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | protected HB422_tagMCTurnFightObjDead FindDeadPack(BattleObject target) |
| | | protected List<HB422_tagMCTurnFightObjDead> FindDeadPack() |
| | | { |
| | | HB422_tagMCTurnFightObjDead deadPack = null; |
| | | List<HB422_tagMCTurnFightObjDead> deadPacks = new List<HB422_tagMCTurnFightObjDead>(); |
| | | for (int i = 0; i < packList.Count; i++) |
| | | { |
| | | var pack = packList[i]; |
| | | // 寻找死亡包 找到死亡包之后要找掉落包 不能超过技能包 |
| | | if (pack is HB422_tagMCTurnFightObjDead) |
| | | { |
| | | deadPack = pack as HB422_tagMCTurnFightObjDead; |
| | | if (deadPack.ObjID == target.ObjID) |
| | | { |
| | | return deadPack; |
| | | } |
| | | var deadPack = pack as HB422_tagMCTurnFightObjDead; |
| | | deadPacks.Add(deadPack); |
| | | } |
| | | else if (pack is CustomHB426CombinePack) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | return deadPacks; |
| | | } |
| | | |
| | | protected void CheckAfterDeadhPack(BattleObject target, HB422_tagMCTurnFightObjDead deadPack) |
| | | protected void CheckAfterDeadhPack() |
| | | { |
| | | if (null == deadPack) |
| | | { |
| | | return; |
| | | } |
| | | var deadPackIndex = packList.IndexOf(deadPack); |
| | | if (deadPackIndex < 0) |
| | | { |
| | | return; |
| | | } |
| | | List<int> removeIndexList = new List<int>(); |
| | | for (int i = deadPackIndex + 1; i < packList.Count; i++) |
| | | for (int i = 0; i < packList.Count; i++) |
| | | { |
| | | var pack = packList[i]; |
| | | |
| | |
| | | |
| | | public void OnSkillFinished() |
| | | { |
| | | while (packList.Count > 0) |
| | | { |
| | | var pack = packList[0]; |
| | | packList.RemoveAt(0); |
| | | |
| | | if (pack is CustomHB426CombinePack) |
| | | { |
| | | var combinePack = pack as CustomHB426CombinePack; |
| | | if (combinePack.startTag.Tag.StartsWith("Skill_")) |
| | | { |
| | | otherSkillAction = combinePack.CreateSkillAction(); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | PackageRegedit.Distribute(pack); |
| | | } |
| | | |
| | | isFinished = true; |
| | | } |
| | | |
| | | |
| | | protected virtual void OnActiveSkillFrame() |
| | | { |
| | | |
| | | } |
| | | |
| | | protected virtual void OnStartSkillFrame() |
| | | { |
| | | |
| | | } |
| | | |
| | | protected virtual void OnEndSkillFrame() |
| | | { |
| | | |
| | | } |
| | | } |