From ae322dfa9a0dc0f7321c46a5a657b5e972651558 Mon Sep 17 00:00:00 2001 From: Lorenzo Balugani Date: Sun, 28 Apr 2019 17:30:43 +0200 Subject: [PATCH] Add poisoned Heart object --- Assets/Scripts/EntityItemPoisonHeart.cs | 27 ++++++++++++++++++++ Assets/Scripts/EntityItemPoisonHeart.cs.meta | 11 ++++++++ 2 files changed, 38 insertions(+) create mode 100644 Assets/Scripts/EntityItemPoisonHeart.cs create mode 100644 Assets/Scripts/EntityItemPoisonHeart.cs.meta diff --git a/Assets/Scripts/EntityItemPoisonHeart.cs b/Assets/Scripts/EntityItemPoisonHeart.cs new file mode 100644 index 0000000..e571073 --- /dev/null +++ b/Assets/Scripts/EntityItemPoisonHeart.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EntityItemPoisonHeart : EntityItem +{ + public int damage; + protected EntityPlayer player; + public override string Name { + get { + return "Poisonous 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-=damage; + if (player.hp <= 0) player.Die(); + Destroy(gameObject); + } +} \ No newline at end of file diff --git a/Assets/Scripts/EntityItemPoisonHeart.cs.meta b/Assets/Scripts/EntityItemPoisonHeart.cs.meta new file mode 100644 index 0000000..1a63426 --- /dev/null +++ b/Assets/Scripts/EntityItemPoisonHeart.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6effa3f71be846844844432d38652a57 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: