diff --git a/Role/Attack.cs b/Role/Attack.cs index 62058fd..3b67420 100644 --- a/Role/Attack.cs +++ b/Role/Attack.cs @@ -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 { diff --git a/Role/Role.cs b/Role/Role.cs index 3452ab0..5ae5354 100644 --- a/Role/Role.cs +++ b/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().text= (temp - hp).ToString(); - FlashRedEffect(); - StopDoTween(0.2f); - + go.GetComponent().text = (temp - hp).ToString(); // ÏÔʾÉ˺¦Öµ + FlashRedEffect(); // ѪÁ¿¼õÉÙʱµÄºìÉ«ÉÁ˸Ч¹û + StopDoTween(0.2f); // Í£Ö¹ÈκνøÐÐÖÐµÄ DoTween ¶¯»­£¬0.2sΪʾÀýÖµ } - + // ÅжϽÇÉ«ÊÇ·ñËÀÍö if (hp <= 0) { - die(); + die(); // Ö´ÐÐËÀÍö´¦Àí } + } } [Header("µôÂä")] public float gold = 10f; diff --git a/Role/move/2D/SimplePathfindingDoTween.cs b/Role/move/2D/SimplePathfindingDoTween.cs index 8c8e48d..802f6a0 100644 --- a/Role/move/2D/SimplePathfindingDoTween.cs +++ b/Role/move/2D/SimplePathfindingDoTween.cs @@ -13,13 +13,16 @@ public class waypoints public class SimplePathfindingDoTween : Fun { public waypoints waypoints = new waypoints();// Ô¤ÉèµÄ·¾¶µã - public float moveSpeed = 1f; // ¿ØÖÆÒƶ¯ËٶȵIJÎÊý£¨¸ü¸ßÖµ±íʾ¸ü¿ìµÄËٶȣ© + + public float moveSpeed; // ¿ØÖÆÒƶ¯ËٶȵIJÎÊý£¨¸ü¸ßÖµ±íʾ¸ü¿ìµÄËٶȣ© 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) {