you really gotta calm down, marisa...
This commit is contained in:
parent
13bb58ea03
commit
b9fb490dce
68 changed files with 990 additions and 44 deletions
58
Assets/Scripts/Entities/Entity.cs
Normal file
58
Assets/Scripts/Entities/Entity.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Entity : MonoBehaviour
|
||||
{
|
||||
[Header("Identification")]
|
||||
public string entityName;
|
||||
public SpriteRenderer sprite;
|
||||
[Header("Flags")]
|
||||
public bool stalled;
|
||||
public bool invincible;
|
||||
[Header("Stats")]
|
||||
public float health;
|
||||
public float maxHealth;
|
||||
[Header("Movement")]
|
||||
[SerializeField] private bool isFacingRight;
|
||||
[SerializeField] protected Rigidbody2D rb;
|
||||
protected Vector2 moveDirection;
|
||||
public float speed;
|
||||
|
||||
protected void FlipSprite(Vector2 lookDirection)
|
||||
{
|
||||
if (lookDirection.x < 0f && isFacingRight)
|
||||
{
|
||||
sprite.flipX = true;
|
||||
isFacingRight = !isFacingRight;
|
||||
}
|
||||
else if (lookDirection.x > 0f && !isFacingRight)
|
||||
{
|
||||
sprite.flipX = false;
|
||||
isFacingRight = !isFacingRight;
|
||||
}
|
||||
}
|
||||
protected virtual void FixedUpdate()
|
||||
{
|
||||
if (!stalled)
|
||||
{
|
||||
rb.linearVelocity = moveDirection * speed;
|
||||
}
|
||||
}
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
health -= damage;
|
||||
if (health < 0)
|
||||
{
|
||||
OnKillEffects();
|
||||
}
|
||||
}
|
||||
public void Heal(float healingAmount)
|
||||
{
|
||||
health += healingAmount;
|
||||
health = Mathf.Clamp(health, 0, maxHealth);
|
||||
}
|
||||
|
||||
protected virtual void OnKillEffects()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue