Compare commits

..

No commits in common. "4e76a266187677c46758ae25e9ee9d01dc3cfea8" and "a3b8d260f43197fe68070a94c62ad4bb490fd3d7" have entirely different histories.

2 changed files with 16 additions and 20 deletions

View File

@ -85,7 +85,7 @@ public class Bullet : MonoBehaviour
[Header("子弹动画")] public Animator animator; [Header("子弹动画")] public Animator animator;
[Header("子弹移动参数")] public bool IsMove=true; [Header("子弹移动参数")] public bool IsMove=true;
[Header("子弹碰撞体")] public Collider2D Collider2D; [Header("子弹碰撞体")] public Collider2D Collider2D;
[Header("×Óµ¯ÌØÐ§Ô¤ÖÆÌå")] public List<GameObject> effectPres=new List<GameObject>(); [Header("×Óµ¯ÌØÐ§Ô¤ÖÆÌå")] public GameObject effectPre;
private float timer = 0; private float timer = 0;
private void Update() private void Update()
{ {
@ -159,23 +159,20 @@ public class Bullet : MonoBehaviour
if (bulletAttributes==BulletAttributes.Fire) if (bulletAttributes==BulletAttributes.Fire)
{ {
if (effectPre!=null)
if (effectPres.Count==1) {
{ GameObject go = Instantiate(effectPre, collision.transform);
GameObject go = Instantiate(effectPres[0], collision.transform);
go.transform.position = new Vector2(collision.transform.position.x, collision.transform.position.y + 0.2f); go.transform.position = new Vector2(collision.transform.position.x, collision.transform.position.y + 0.2f);
go.GetComponent<Huo>().bullet = this; go.GetComponent<Huo>().bullet = this;
Debug.Log("创建火焰"); Debug.Log("创建火焰");
}
} }
} }
if (bulletAttributes == BulletAttributes.Water) if (bulletAttributes == BulletAttributes.Water)
{ {
if (effectPres.Count > 1) if (effectPre != null)
{ {
GameObject go = Instantiate(effectPres[Random.Range(0,effectPres.Count-1)], collision.transform); GameObject go = Instantiate(effectPre, collision.transform);
go.transform.position = new Vector2(collision.transform.position.x, collision.transform.position.y-0.2f); go.transform.position = new Vector2(collision.transform.position.x, collision.transform.position.y-0.2f);
collision.transform.GetComponent<enemy>().SlowDown(0.2f, 3f); collision.transform.GetComponent<enemy>().SlowDown(0.2f, 3f);
@ -185,7 +182,7 @@ public class Bullet : MonoBehaviour
} }
} }
}
} }
private float lastDamageTime = 0f; private float lastDamageTime = 0f;
private void OnTriggerStay2D(Collider2D collision) private void OnTriggerStay2D(Collider2D collision)

View File

@ -55,7 +55,7 @@ public class SimplePathfindingDoTween : Fun
.OnUpdate(() => { .OnUpdate(() => {
//pathTween.timeScale = speedFactor; pathTween.timeScale = speedFactor;
RotateTowardsTarget(); } RotateTowardsTarget(); }
@ -78,15 +78,14 @@ public class SimplePathfindingDoTween : Fun
// 控制DoTween的速度接受一个新的速度因子和一个恢复时间 // 控制DoTween的速度接受一个新的速度因子和一个恢复时间
public void ChangeSpeed(float newSpeedFactor, float restoreTime) public void ChangeSpeed(float newSpeedFactor, float restoreTime)
{ {
// 当前的时间缩放因子 // 改变路径动画的速度因子
float currentSpeedFactor = pathTween.timeScale; pathTween.timeScale = newSpeedFactor;
// 使用Tween来平滑地调整速度因子 // 设置一个延迟恢复原始速度的功能
DOTween.To(() => currentSpeedFactor, x => pathTween.timeScale = x, newSpeedFactor, restoreTime) DOTween.To(() => 0f, x => { }, 0f, restoreTime).OnKill(() =>
.OnKill(() => {
{ Debug.Log("设置减速+++++++++++++++++");
Debug.Log("设置减速+++++++++++++++++"); // 在延迟结束后恢复原来的速度
// 在延迟结束后恢复原速度
pathTween.timeScale = 1f; // 恢复原速度 pathTween.timeScale = 1f; // 恢复原速度
}); });
} }