public void UpdateHealth(ZombieCollider collider) { //Update health values switch (collider) { case ZombieCollider.HEAD: health -= MAX_ZOMBIE_HEALTH; break; case ZombieCollider.SPINE_02: health -= 60; break; default: health -= 30; break; } healthPercent = health / maxHealth; Vector3 scale = healthBar.transform.localScale; scale.x = healthPercent * originalScale; healthBar.transform.localScale = scale; }
//IScorable methods public int CollisionScore(ZombieCollider collider) { switch (collider) { case ZombieCollider.SPINE_02: return(50); default: return(25); } }
/* * Score to add to players score */ public int EnemyDeathScore(ZombieCollider collider) { switch (collider) { case ZombieCollider.HEAD: return(100); case ZombieCollider.SPINE_02: return(50); default: return(25); } }
void TestZombieCollision(GameObject other, ParticleCollisionEvent collision) { if (other.name.Contains("ZombieLowQuality")) { ZombieController zombie = other.GetComponent <ZombieController>(); ZombieCollider collider = zombie.GetZombieCollider(collision.colliderComponent.name); zombie.UpdateHealth(collider); if (zombie.GetHealth() <= 0) { Statics.ScoreController.Score += zombie.EnemyDeathScore(collider); objectPooler.ReleaseToPool(other, "Zombie"); enemyGenerator.numberOfZombies--; } else { Statics.ScoreController.Score += zombie.CollisionScore(collider); } } }