diff --git a/Role/Bullet.cs b/Role/Bullet.cs index 8402e5e..825e64e 100644 --- a/Role/Bullet.cs +++ b/Role/Bullet.cs @@ -85,7 +85,7 @@ public class Bullet : MonoBehaviour [Header("子弹动画")] public Animator animator; [Header("子弹移动参数")] public bool IsMove=true; [Header("子弹碰撞体")] public Collider2D Collider2D; - [Header("子弹特效预制体")] public GameObject effectPre; + [Header("子弹特效预制体")] public List effectPres=new List(); private float timer = 0; private void Update() { @@ -159,20 +159,23 @@ public class Bullet : MonoBehaviour if (bulletAttributes==BulletAttributes.Fire) { - if (effectPre!=null) - { - GameObject go = Instantiate(effectPre, collision.transform); + + if (effectPres.Count==1) + { + GameObject go = Instantiate(effectPres[0], collision.transform); go.transform.position = new Vector2(collision.transform.position.x, collision.transform.position.y + 0.2f); go.GetComponent().bullet = this; - + Debug.Log("创建火焰"); + } + } } if (bulletAttributes == BulletAttributes.Water) { - if (effectPre != null) + if (effectPres.Count > 1) { - GameObject go = Instantiate(effectPre, collision.transform); + GameObject go = Instantiate(effectPres[Random.Range(0,effectPres.Count-1)], collision.transform); go.transform.position = new Vector2(collision.transform.position.x, collision.transform.position.y-0.2f); collision.transform.GetComponent().SlowDown(0.2f, 3f); @@ -182,7 +185,7 @@ public class Bullet : MonoBehaviour } } - } + } private float lastDamageTime = 0f; private void OnTriggerStay2D(Collider2D collision) diff --git a/Role/move/2D/SimplePathfindingDoTween.cs b/Role/move/2D/SimplePathfindingDoTween.cs index 0fbd8fd..462ad7a 100644 --- a/Role/move/2D/SimplePathfindingDoTween.cs +++ b/Role/move/2D/SimplePathfindingDoTween.cs @@ -55,7 +55,7 @@ public class SimplePathfindingDoTween : Fun .OnUpdate(() => { - pathTween.timeScale = speedFactor; + //pathTween.timeScale = speedFactor; RotateTowardsTarget(); } @@ -78,14 +78,15 @@ public class SimplePathfindingDoTween : Fun // 控制DoTween的速度,接受一个新的速度因子和一个恢复时间 public void ChangeSpeed(float newSpeedFactor, float restoreTime) { - // 改变路径动画的速度因子 - pathTween.timeScale = newSpeedFactor; + // 当前的时间缩放因子 + float currentSpeedFactor = pathTween.timeScale; - // 设置一个延迟恢复原始速度的功能 - DOTween.To(() => 0f, x => { }, 0f, restoreTime).OnKill(() => - { - Debug.Log("设置减速+++++++++++++++++"); - // 在延迟结束后恢复原来的速度 + // 使用Tween来平滑地调整速度因子 + DOTween.To(() => currentSpeedFactor, x => pathTween.timeScale = x, newSpeedFactor, restoreTime) + .OnKill(() => + { + Debug.Log("设置减速+++++++++++++++++"); + // 在延迟结束后恢复原速度 pathTween.timeScale = 1f; // 恢复原速度 }); }