diff options
Diffstat (limited to 'Assets/Scripts/Actors/Actor.cs')
-rw-r--r-- | Assets/Scripts/Actors/Actor.cs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Assets/Scripts/Actors/Actor.cs b/Assets/Scripts/Actors/Actor.cs index f23f3c6..9a4b338 100644 --- a/Assets/Scripts/Actors/Actor.cs +++ b/Assets/Scripts/Actors/Actor.cs @@ -21,7 +21,6 @@ namespace MontanaJohns.Actors protected Animator _animator; protected Transform _transform; - protected Stats stats; protected Active activeItem; protected bool isGrappling; protected Vector2? grapplePoint = null; @@ -30,6 +29,7 @@ namespace MontanaJohns.Actors protected int jumpCount; protected Vector2 acceleration; + public Stats stats; public int health; protected virtual void Awake() @@ -68,7 +68,7 @@ namespace MontanaJohns.Actors _rigidBody.velocity = Vector2.SmoothDamp(_rigidBody.velocity, target, ref acceleration, .05f); _animator.SetBool("moving", Mathf.Abs(_rigidBody.velocity.x) > 1); - if (_rigidBody.velocity.x < -0.001) { + if (_rigidBody.velocity.x < -0.1) { _renderer.flipX = true; for (int i = 0; i < transform.childCount; i++) { var rot = transform.GetChild(i).rotation; @@ -76,7 +76,7 @@ namespace MontanaJohns.Actors transform.GetChild(i).rotation = rot; } } - else if (_rigidBody.velocity.x > 0.001) { + else if (_rigidBody.velocity.x > 0.1) { _renderer.flipX = false; for (int i = 0; i < transform.childCount; i++) { var rot = transform.GetChild(i).rotation; @@ -129,15 +129,23 @@ namespace MontanaJohns.Actors stats = baseStats + items.Select(i => i.stats).Sum(); } + public virtual void Grapple(float xInput, float yInput, Vector2 grapplePoint) + { + Move(xInput); + MoveY(yInput); + } + public virtual void TakeDamage(int damage) { health -= damage; + StartCoroutine(DamageAnimation()); } - public virtual void Grapple(float xInput, float yInput, Vector2 grapplePoint) + IEnumerator DamageAnimation() { - Move(xInput); - MoveY(yInput); + _renderer.color = Color.red; + yield return new WaitForSeconds(0.5f); + _renderer.color = Color.white; } IEnumerator Falling() |