125 【战斗】战斗系统 移动速度 & 子弹速度支持(去除原本使用时间的设定)
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: 2025年9月2日
|
| | | // [ Date ]: 2025年9月12日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | |
| | | public int[][] DamageDivide;
|
| | | public int BulletEffectId;
|
| | | public int BulletPath;
|
| | | public float BulletFlyTime;
|
| | | public float BulletFlySpeed;
|
| | | public int Scattering;
|
| | | public int ExplosionEffectId;
|
| | | public int ExplosionEffect2;
|
| | |
| | | public int EffectId;
|
| | | public int EffectId2;
|
| | | public int MStartEffectId;
|
| | | public int BuffEffect;
|
| | | public int TriggerEffect;
|
| | |
|
| | | public override int LoadKey(string _key)
|
| | |
| | |
|
| | | int.TryParse(tables[29],out BulletPath);
|
| | |
|
| | | float.TryParse(tables[30],out BulletFlyTime); |
| | | float.TryParse(tables[30],out BulletFlySpeed); |
| | |
|
| | | int.TryParse(tables[31],out Scattering);
|
| | |
|
| | |
| | |
|
| | | int.TryParse(tables[37],out MStartEffectId);
|
| | |
|
| | | int.TryParse(tables[38],out TriggerEffect); |
| | | int.TryParse(tables[38],out BuffEffect); |
| | |
|
| | | int.TryParse(tables[39],out TriggerEffect); |
| | | }
|
| | | catch (Exception exception)
|
| | | {
|
| | |
| | | BattleObject caster = battleField.battleObjMgr.GetBattleObjectByIndex(BattleCamp.Red, selfIndex); |
| | | BattleDebug.LogError("Move to target , target is " + target.name); |
| | | caster.motionBase.PlayAnimation(MotionName.run, true); |
| | | var tweener = BattleUtility.MoveToTarget(caster.heroRectTrans, target, offset, duration, () => |
| | | var tweener = BattleUtility.MoveToTarget(caster.heroRectTrans, target, offset, () => |
| | | { |
| | | caster.motionBase.PlayAnimation(MotionName.idle, true); |
| | | onComplete?.Invoke(); |
| | |
| | | |
| | | |
| | | public static TweenerCore<Vector2, Vector2, DG.Tweening.Plugins.Options.VectorOptions> MoveToTarget( |
| | | RectTransform transform, RectTransform target, Vector2 offset, float duration, Action onComplete = null) |
| | | RectTransform transform, RectTransform target, Vector2 offset, Action onComplete = null, float speed = 450f) |
| | | { |
| | | |
| | | // 获取目标节点的世界坐标(中心点) |
| | |
| | | out localPoint); |
| | | |
| | | // 创建RawImage |
| | | float distance = Vector2.Distance(transform.anchoredPosition, localPoint); |
| | | |
| | | float duration = distance / speed; // 假设速度为1000单位/秒,可以根据需要调整 |
| | | |
| | | var tween = transform.DOAnchorPos(localPoint, duration).SetEase(Ease.Linear); |
| | | tween.onComplete += () => |
| | |
| | | // battleField.battleTweenMgr.OnPlayTween(tweener); |
| | | } |
| | | |
| | | protected void MoveToTarget(RectTransform target, Vector2 offset, float duration, Action onComplete = null) |
| | | protected void MoveToTarget(RectTransform target, Vector2 offset, Action onComplete = null) |
| | | { |
| | | // 原地释放 |
| | | if (skillConfig.CastDistance >= 9999) |
| | |
| | | } |
| | | |
| | | caster.motionBase.PlayAnimation(MotionName.run, true); |
| | | var tweener = BattleUtility.MoveToTarget(caster.heroRectTrans, target, offset, duration, () => |
| | | var tweener = BattleUtility.MoveToTarget(caster.heroRectTrans, target, offset, () => |
| | | { |
| | | caster.motionBase.PlayAnimation(MotionName.idle, true); |
| | | onComplete?.Invoke(); |
| | |
| | | |
| | | RectTransform target = battleField.GetTeamNode(caster.GetEnemyCamp(), skillConfig); |
| | | |
| | | MoveToTarget(target, new Vector2(skillConfig.CastDistance, 0), moveTime, () => |
| | | MoveToTarget(target, new Vector2(skillConfig.CastDistance, 0), () => |
| | | { |
| | | // 到位置转身(不一定非要转身 但是流程要写) |
| | | TurnBack(() => |
| | |
| | | () => |
| | | { |
| | | // 回到原来的位置 |
| | | MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum), Vector2.zero, moveTime, |
| | | MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum), Vector2.zero, |
| | | OnAttackFinish); |
| | | } |
| | | , -1f); |
| | |
| | | |
| | | RectTransform targetTrans = battleField.GetTeamNode(battleCamp, mainTargetPosNum); |
| | | |
| | | MoveToTarget(targetTrans, new Vector2(skillConfig.CastDistance, 0), moveTime, () => |
| | | MoveToTarget(targetTrans, new Vector2(skillConfig.CastDistance, 0), () => |
| | | { |
| | | // 到位置转身(不一定非要转身 但是流程要写) |
| | | TurnBack(() => |
| | |
| | | () => |
| | | { |
| | | // 回到原来的位置 |
| | | MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum), Vector2.zero, moveTime, |
| | | MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum), Vector2.zero, |
| | | OnAttackFinish); |
| | | } |
| | | , -1f); |
| | |
| | | { |
| | | RectTransform target = battleField.GetTeamNode(caster.Camp, skillConfig); |
| | | |
| | | MoveToTarget(target, new Vector2(skillConfig.CastDistance, 0), moveTime, () => |
| | | MoveToTarget(target, new Vector2(skillConfig.CastDistance, 0), () => |
| | | { |
| | | // 到位置转身(不一定非要转身 但是流程要写) |
| | | TurnBack(() => |
| | |
| | | { |
| | | // 回到原来的位置 |
| | | MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum), |
| | | Vector2.zero, moveTime, OnAttackFinish); |
| | | Vector2.zero, OnAttackFinish); |
| | | } |
| | | , -1f); |
| | | }); |
| | |
| | | base.Reset(); |
| | | start = WorldToLocalAnchoredPosition(bulletTrans.position); |
| | | end = WorldToLocalAnchoredPosition(target.position); |
| | | duration = Vector2.Distance(start, end) / skillConfig.BulletFlySpeed; |
| | | control = (start + end) / 2 + Vector2.up * 100f; |
| | | } |
| | | |
| | |
| | | { |
| | | start = WorldToLocalAnchoredPosition(bulletTrans.position); |
| | | end = WorldToLocalAnchoredPosition(target.position); |
| | | duration = Vector2.Distance(start, end) / skillConfig.BulletFlySpeed; |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | finished = false; |
| | | elapsed = 0f; |
| | | duration = skillConfig.BulletFlyTime; |
| | | } |
| | | |
| | | // 世界坐标转为bulletTrans父节点下的本地坐标 |
| | |
| | | hitTriggered = false; |
| | | start = WorldToLocalAnchoredPosition(bulletTrans.position); |
| | | end = WorldToLocalAnchoredPosition(target.position); |
| | | duration = Vector2.Distance(start, end) / skillConfig.BulletFlySpeed; |
| | | Vector2 dir = (end - start).normalized; |
| | | float extend = 500f; // 贯穿距离,可根据需求调整 |
| | | outPos = end + dir * extend; |
| | |
| | | base.Reset(); |
| | | start = WorldToLocalAnchoredPosition(bulletTrans.position); |
| | | end = WorldToLocalAnchoredPosition(target.position); |
| | | |
| | | duration = Vector2.Distance(start, end) / skillConfig.BulletFlySpeed; |
| | | // BattleUtility.MarkStartAndEnd(bulletTrans, target); |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | BattleUtility.MoveToTarget(sourceRect, targetRect, offset, duration, () => |
| | | BattleUtility.MoveToTarget(sourceRect, targetRect, offset, () => |
| | | { |
| | | Debug.Log("移动完成!"); |
| | | }); |