void Start() { initialPosition = transform.position; dropTable = new DropTable(); dropTable.loot = new List <LootDrop>() { new LootDrop("Sword_01", 45), new LootDrop("Staff_01", 30), new LootDrop("Potion", 20) }; Experience = 20 * ExpModifier; ID = 0; navMeshAgent = GetComponent <NavMeshAgent>(); characterStats = new CharacterStats(5, 10, 2); healthbarUI = GetComponent <HealthbarUI>(); currentHealth = maxHealth; healthbarUI.UpdateHealthBar(gameObject, currentHealth, maxHealth); woundedSound = GetComponent <AudioSource>(); woundSpotSystem = gameObject.transform.Find("WoundSpot").GetComponent <ParticleSystem>(); }
public void takeDamage(int amount) { woundSpotSystem.Play(); woundedSound.Play(); currentHealth -= amount; healthbarUI.UpdateHealthBar(gameObject, currentHealth, maxHealth); if (currentHealth <= 0) { Invoke("Die", .5f); } Debug.Log("Taken damage"); Debug.Log("IsInvoking(ChasePlayer)?: " + !IsInvoking("ChasePlayer")); if (!IsInvoking("ChasePlayer")) { Debug.Log("Going to player pos"); navMeshAgent.SetDestination(GameObject.Find("Player").transform.position); } }