diff --git a/Assets/Scripts/CoinMessage.cs b/Assets/Scripts/CoinMessage.cs deleted file mode 100644 index e69de29..0000000 diff --git a/Assets/Scripts/DestroySelfAfterSomeTime.cs b/Assets/Scripts/DestroySelfAfterSomeTime.cs new file mode 100644 index 0000000..07a332e --- /dev/null +++ b/Assets/Scripts/DestroySelfAfterSomeTime.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class DestroySelfAfterSomeTime : MonoBehaviour { + [BeforeStartAttribute] + public float time = 1f; + + protected void Start() { + Invoke(DestroySelf, time); + } + + protected void DestroySelf() { + Destroy(gameObject); + } +} \ No newline at end of file diff --git a/Assets/Scripts/EntityItem.cs b/Assets/Scripts/EntityItem.cs index 1d62286..e8e2016 100644 --- a/Assets/Scripts/EntityItem.cs +++ b/Assets/Scripts/EntityItem.cs @@ -17,7 +17,6 @@ public class EntityItem : Entity } public virtual void OnPickup(EntityPlayer player) { - Debug.LogWarning("OnPickup not overridden"); messageBar.Write("Picked up: " + Name, Color.yellow); Destroy(gameObject); } diff --git a/Assets/Scripts/EntityItemHeart.cs b/Assets/Scripts/EntityItemHeart.cs index fcd4d43..11b48a4 100644 --- a/Assets/Scripts/EntityItemHeart.cs +++ b/Assets/Scripts/EntityItemHeart.cs @@ -13,7 +13,7 @@ public class EntityItemHeart : EntityItem } public override void OnPickup(EntityPlayer player) { - messageBar.Write("You used: " + Name, Color.yellow); + messageBar.Write("Picked up: " + Name, Color.lime); player.hp += regen; if (player.hp > player.hpMax) player.hp = player.hpMax; Destroy(gameObject); diff --git a/Assets/Scripts/EntityItemPoisonHeart.cs b/Assets/Scripts/EntityItemPoisonHeart.cs index d14469b..e1715fc 100644 --- a/Assets/Scripts/EntityItemPoisonHeart.cs +++ b/Assets/Scripts/EntityItemPoisonHeart.cs @@ -13,7 +13,7 @@ public class EntityItemPoisonHeart : EntityItem } public override void OnPickup(EntityPlayer player) { - messageBar.Write("You used: " + Name, Color.yellow); + messageBar.Write("Picked up: " + Name, Color.orange); player.hp -= damage; Destroy(gameObject); } diff --git a/Assets/Scripts/EntityItemShop.cs b/Assets/Scripts/EntityItemShop.cs new file mode 100644 index 0000000..3ca9fc1 --- /dev/null +++ b/Assets/Scripts/EntityItemShop.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EntityItemShop : EntityItem { + public float hpChange = -1f; + public float maxHpChange = -1f; + + protected EntityPlayer player; + + protected override void Start() { + base.Start(); + player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + } + + protected virtual void OnPurchase() { + Debug.LogWarning("OnPurchase not overridden"); + } + + public override void OnPickup() { + player.hp += hpChange; + player.maxHpChange += maxHpChange; + OnPurchase(); + messageBar.Write("Bought: " + Name, Color.yellow); + Destroy(gameObject); + } +} \ No newline at end of file diff --git a/Assets/Scripts/EntityItemShopSword.cs b/Assets/Scripts/EntityItemShopSword.cs new file mode 100644 index 0000000..bb8ef83 --- /dev/null +++ b/Assets/Scripts/EntityItemShopSword.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EntityItemShopSword : EntityItemShop { + + public float damage = 3f; + + public override string Name { + get { + return "Sword (" + damage.ToString() + " dmg)"; + } + } + + protected override void OnPurchase() { + Destroy(player.GetComponent()); + player.AddComponent(PlayerAttackMelee); + PlayerAttackMelee pam = player.GetComponent(); + pam.damage = this.damage; + } +} \ No newline at end of file diff --git a/Assets/Scripts/EntityMonster.cs b/Assets/Scripts/EntityMonster.cs index 1a130b5..b1a458c 100644 --- a/Assets/Scripts/EntityMonster.cs +++ b/Assets/Scripts/EntityMonster.cs @@ -9,7 +9,7 @@ public class EntityMonster : Entity Debug.LogWarning("No name given to a monster"); return ""; } - } + } public virtual void OnTurn(){ Debug.LogWarning("OnTurn() not overridden"); diff --git a/Assets/Scripts/EntityMonsterMage.cs b/Assets/Scripts/EntityMonsterMage.cs index 945faf1..72a8209 100644 --- a/Assets/Scripts/EntityMonsterMage.cs +++ b/Assets/Scripts/EntityMonsterMage.cs @@ -12,6 +12,7 @@ public class EntityMonsterMage : EntityMonster public float moveChance = 0.5f; public float visionRange = 7f; + public GameObject attackAnimation; protected EntityPlayer player; protected new void Start() { diff --git a/Assets/Scripts/EntityMonsterSkeletonArcher.cs b/Assets/Scripts/EntityMonsterSkeletonArcher.cs index 7da72b1..a165085 100644 --- a/Assets/Scripts/EntityMonsterSkeletonArcher.cs +++ b/Assets/Scripts/EntityMonsterSkeletonArcher.cs @@ -12,6 +12,7 @@ public class EntityMonsterSkeletonArcher : EntityMonster public float moveChance = 0f; public float visionRange = 5f; + public GameObject attackAnimation; protected EntityPlayer player; protected new void Start() { diff --git a/Assets/Scripts/EntityMonsterSkeletonSwordsman.cs b/Assets/Scripts/EntityMonsterSkeletonSwordsman.cs index 16d6c36..078da7e 100644 --- a/Assets/Scripts/EntityMonsterSkeletonSwordsman.cs +++ b/Assets/Scripts/EntityMonsterSkeletonSwordsman.cs @@ -12,6 +12,7 @@ public class EntityMonsterSkeletonSwordsman : EntityMonster public float moveChance = 0f; public float visionRange = 4f; + public GameObject attackAnimation; protected EntityPlayer player; protected new void Start() { diff --git a/Assets/Scripts/EntityMonsterSlime.cs b/Assets/Scripts/EntityMonsterSlime.cs index 570f87f..b412426 100644 --- a/Assets/Scripts/EntityMonsterSlime.cs +++ b/Assets/Scripts/EntityMonsterSlime.cs @@ -12,6 +12,7 @@ public class EntityMonsterSlime : EntityMonster public float moveChance = 0.5f; public float visionRange = 4f; + public GameObject attackAnimation; protected EntityPlayer player; protected new void Start() { diff --git a/Assets/Scripts/EntityMonsterWatcher.cs b/Assets/Scripts/EntityMonsterWatcher.cs index 14a0619..6e2d4ca 100644 --- a/Assets/Scripts/EntityMonsterWatcher.cs +++ b/Assets/Scripts/EntityMonsterWatcher.cs @@ -12,6 +12,7 @@ public class EntityMonsterWatcher : EntityMonster public float moveChance = 0f; public float visionRange = 12f; + public GameObject attackAnimation; protected EntityPlayer player; protected new void Start() { diff --git a/Assets/Scripts/Map.cs b/Assets/Scripts/Map.cs index a5f6c3d..9775f3a 100644 --- a/Assets/Scripts/Map.cs +++ b/Assets/Scripts/Map.cs @@ -245,9 +245,16 @@ public class Map : MonoBehaviour } private void PlacePlayer() { + //Check for an existing player MapRoom room = rooms[Random.Range(0, rooms.Count)]; Vector2Int point = room.RandomPoint(); - GameObject playerObject = Instantiate(playerPrefab, turnHandler.transform); + GameObject playerObject = GameObject.FindGameObjectWithTag("Player"); + if(playerObject == null) { + playerObject = Instantiate(playerPrefab, turnHandler.transform); + } + else { + playerObject.transform.parent = turnHandler.transform; + } playerObject.name = "Player"; playerObject.transform.position = new Vector3(point.x, point.y, 0); } diff --git a/Assets/Scripts/NextLevel.cs b/Assets/Scripts/NextLevel.cs new file mode 100644 index 0000000..c72849a --- /dev/null +++ b/Assets/Scripts/NextLevel.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NextLevel : MonoBehaviour { + //TODO +} \ No newline at end of file