From d943add3eae1e6a8bcd787f44982f9a3a056ce8b Mon Sep 17 00:00:00 2001 From: Lorenzo Balugani Date: Sun, 28 Apr 2019 17:22:08 +0200 Subject: [PATCH] Add Heart Item --- Assets/Scripts/EntityItemHeart.cs | 27 ++++++++++++++++++++++++++ Assets/Scripts/EntityItemHeart.cs.meta | 11 +++++++++++ 2 files changed, 38 insertions(+) create mode 100644 Assets/Scripts/EntityItemHeart.cs create mode 100644 Assets/Scripts/EntityItemHeart.cs.meta diff --git a/Assets/Scripts/EntityItemHeart.cs b/Assets/Scripts/EntityItemHeart.cs new file mode 100644 index 0000000..00f3983 --- /dev/null +++ b/Assets/Scripts/EntityItemHeart.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EntityItemHeart : EntityItem +{ + public int regen; + protected EntityPlayer player; + public override string Name { + get { + return "Heart"; + } + } + // Start is called before the first frame update + protected new void Start() { + base.Start(); + player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + } + + // Update is called once per frame + public override void OnPickup(EntityPlayer player) { + messageBar.Write("You used: " + Name, Color.yellow); + player.hp+=regen; + if (player.hp > player.hpMax) player.hp = player.hpMax; + Destroy(gameObject); + } +} diff --git a/Assets/Scripts/EntityItemHeart.cs.meta b/Assets/Scripts/EntityItemHeart.cs.meta new file mode 100644 index 0000000..57e6a34 --- /dev/null +++ b/Assets/Scripts/EntityItemHeart.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c07fddfe35675304f92b18a213875e74 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: