// Function to be called by projectile controller // Takes in damage value of projectile and changes enemy health accordingly public void AttackEnemy(int amount, TowerController.towerTypes type, float potency) { if (cools <= 0) { switch (type) { case (TowerController.towerTypes.standard): //Debug.Log("Standard Attack"); currentHealth = Mathf.Clamp(currentHealth - CalculateDamage(amount), 0, maxHealth); //Debug.Log(currentHealth); SetHealth(currentHealth); GameCtrl.AddMoney(1f); if (currentHealth <= 0) { Die(); } break; case (TowerController.towerTypes.poison): //Debug.Log("Poison Attack"); currentHealth = Mathf.Clamp(currentHealth - CalculateDamage(amount), 0, maxHealth); SetHealth(currentHealth); GameCtrl.AddMoney(1f); if (currentHealth <= 0) { Die(); } curPoison += potency; if (curPoison >= poisonResistance && poisonCools <= 0) { poisonDmgCools = timeBetweenPoisonDamage; poisonCools = poisonTime; } break; case (TowerController.towerTypes.burn): //Debug.Log("Burn Attack"); currentHealth = Mathf.Clamp(currentHealth - CalculateDamage(amount), 0, maxHealth); SetHealth(currentHealth); GameCtrl.AddMoney(1f); if (currentHealth <= 0) { Die(); } curBurn += potency; if (curBurn >= burnResistance && burnCools <= 0) { burnDmgCools = timeBetweenBurnDamage; burnCools = burnTime; } break; case (TowerController.towerTypes.freeze): //Debug.Log("Freeze Attack"); currentHealth = Mathf.Clamp(currentHealth - CalculateDamage(amount), 0, maxHealth); SetHealth(currentHealth); GameCtrl.AddMoney(1f); if (currentHealth <= 0) { Die(); } curFreeze += potency; //Debug.Log(curFreeze); if (curFreeze >= freezeResistance && freezeCools <= 0) { freezeCools = freezeTime; } break; case (TowerController.towerTypes.slow): //Debug.Log("Slow Attack"); currentHealth = Mathf.Clamp(currentHealth - CalculateDamage(amount), 0, maxHealth); SetHealth(currentHealth); GameCtrl.AddMoney(1f); if (currentHealth <= 0) { Die(); } curSlow += potency; if (curSlow >= slowResistance && slowCools <= 0) { slowCools = slowTime; } break; } cools = iframes; anim.SetBool("flash", true); Invoke("ResetFlash", 0.01f); } }
//Sends targets, attack type, and attack damage from towers to projectiles public void ReceiveTarget(Transform turretTarget, int d, TowerController.towerTypes towerType) { projectileTarget = turretTarget; type = towerType; }