1
Fork 0
slime-blood-and-pain/Assets/Scripts/Entity.cs

45 lines
1.2 KiB
C#
Raw Normal View History

2019-04-27 20:19:35 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Entity : MonoBehaviour
{
2019-04-28 12:41:28 +00:00
public float hpMax;
2019-04-28 12:11:21 +00:00
public bool overlappable = false;
2019-04-27 20:19:35 +00:00
[AfterStartAttribute]
2019-04-28 12:41:28 +00:00
public float hp;
2019-04-27 20:19:35 +00:00
[BeforeStartAttribute]
public Sprite sprite;
public Vector2Int MapPosition {
get {
return new Vector2Int((int)transform.position.x, (int)transform.position.y);
}
}
protected GameObject gameController;
protected SpriteRenderer spriteRenderer;
protected TurnHandler turnHandler;
protected Map map;
2019-04-28 14:28:31 +00:00
protected MessageBar messageBar;
2019-04-27 20:19:35 +00:00
2019-04-28 13:29:17 +00:00
protected virtual void Start()
2019-04-27 20:19:35 +00:00
{
spriteRenderer = GetComponent<SpriteRenderer>();
spriteRenderer.sprite = sprite;
gameController = GameObject.FindGameObjectWithTag("GameController");
turnHandler = gameController.GetComponentInChildren<TurnHandler>();
map = gameController.GetComponentInChildren<Map>();
2019-04-28 14:28:31 +00:00
GameObject canvas = GameObject.FindGameObjectWithTag("Canvas");
messageBar = canvas.GetComponentInChildren<MessageBar>();
2019-04-27 20:19:35 +00:00
hp = hpMax;
}
2019-04-28 14:28:31 +00:00
public virtual void Die() {
Debug.LogWarning("Die not overridden");
Destroy(gameObject);
}
2019-04-27 20:19:35 +00:00
}