修改
This commit is contained in:
parent
f3cad5d509
commit
2b93b14699
@ -68,7 +68,8 @@ public class Attack : MonoBehaviour
|
||||
{
|
||||
direction = (targetRole.transform.position - BulletStartPos.position).normalized;
|
||||
}
|
||||
animator.SetInteger("State", 1);
|
||||
//animator.SetInteger("State", 1);
|
||||
animator.SetTrigger("Attack");
|
||||
lastAttackTime = Time.time; // 更新上次攻击时间
|
||||
|
||||
}
|
||||
@ -85,7 +86,7 @@ public class Attack : MonoBehaviour
|
||||
|
||||
if (animator != null)
|
||||
{
|
||||
animator.SetInteger("State", 0);
|
||||
//animator.SetInteger("State", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
28
Role/Role.cs
28
Role/Role.cs
@ -40,8 +40,10 @@ public class Role : Fun
|
||||
private float maxHp;
|
||||
[Header(("死亡动画编号"))] public int dieIndex=-1;
|
||||
|
||||
[Header("hpÌî³ä")] public Image Hpfiil;
|
||||
[Header("hp填充直接扣")] public Image Hpfiil;
|
||||
[Header("hp填充慢慢扣")] public Image HpfiilYello;
|
||||
[Header("扣血填充")] public GameObject HpTextPrefab;
|
||||
|
||||
[Header("自己的画布")]public Canvas _Canvas;
|
||||
[Header("自己的图片")] public SpriteRenderer spriteRenderers; // 存储所有的SpriteRenderer组件
|
||||
|
||||
@ -53,26 +55,30 @@ public class Role : Fun
|
||||
float temp = hp;
|
||||
hp = value;
|
||||
|
||||
if (Hpfiil!=null)
|
||||
// 更新血条显示
|
||||
if (Hpfiil != null)
|
||||
{
|
||||
Hpfiil.fillAmount = hp / maxHp;
|
||||
|
||||
|
||||
// 使用 DOTween 动画平滑过渡血条填充
|
||||
DOTween.To(() => HpfiilYello.fillAmount, x => HpfiilYello.fillAmount = x, hp / maxHp, 0.8f) // 0.5f 为过渡时间
|
||||
.SetEase(Ease.InOutQuad); // 使用缓动效果,使血条变化更加平滑
|
||||
}
|
||||
|
||||
if (HpTextPrefab != null&& hp<maxHp)
|
||||
// 更新血量文本效果
|
||||
if (HpTextPrefab != null && hp < maxHp)
|
||||
{
|
||||
GameObject go = GameObject.Instantiate(HpTextPrefab, _Canvas.transform);
|
||||
|
||||
go.GetComponent<Text>().text= (temp - hp).ToString();
|
||||
FlashRedEffect();
|
||||
StopDoTween(0.2f);
|
||||
|
||||
go.GetComponent<Text>().text = (temp - hp).ToString(); // 显示伤害值
|
||||
FlashRedEffect(); // 血量减少时的红色闪烁效果
|
||||
StopDoTween(0.2f); // 停止任何进行中的 DoTween 动画,0.2s为示例值
|
||||
}
|
||||
|
||||
// 判断角色是否死亡
|
||||
if (hp <= 0)
|
||||
{
|
||||
die();
|
||||
die(); // 执行死亡处理
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
[Header("掉落")] public float gold = 10f;
|
||||
|
@ -13,13 +13,16 @@ public class waypoints
|
||||
public class SimplePathfindingDoTween : Fun
|
||||
{
|
||||
public waypoints waypoints = new waypoints();// 预设的路径点
|
||||
public float moveSpeed = 1f; // 控制移动速度的参数(更高值表示更快的速度)
|
||||
|
||||
public float moveSpeed; // 控制移动速度的参数(更高值表示更快的速度)
|
||||
|
||||
private int currentWaypointIndex = 0; // 当前路径点的索引
|
||||
Vector3 Vector3 = new Vector3();
|
||||
|
||||
|
||||
|
||||
[Header("旋转的动画")]public GameObject obj;
|
||||
public void MoveToNextWaypoint(GameObject gameObject)
|
||||
public void MoveToNextWaypoint(GameObject gameObject,float moveSpeed)
|
||||
{
|
||||
if (currentWaypointIndex < waypoints._waypoints.Count)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user