public void IncreaseHealth(float recovery) { CurrentHealth += recovery; // If we later have some sort of healing make sure that it cannot go over its initial full health. CurrentHealth = Mathf.Clamp(CurrentHealth, 0, MaxHealth); //if (this.currentHealth >= this.health) { this.currentHealth = this.health; } UnitGameObject.UpdateHealthText(); }
public void OnDeath() { GameObject loot = ((GameObject)GameObject.Instantiate(Resources.Load <GameObject>(FileLocations.lootPrefab))); UnitGameObject.Tile.Loot = loot.GetComponent <Loot>(); UnitGameObject.Tile.Loot.SetLoot(CurrentLoot); loot.GetComponent <Loot>().Tile = UnitGameObject.Tile; loot.transform.position = UnitGameObject.Tile.gameObject.transform.position; UnitGameObject.DestroyUnit(); }
public Unit(UnitGameObject game, bool isHero, int attackRange, int moveRange, bool canAttackAfterMove, float maxHealth, float damage, int cost, int fowLos, float baseLoot, Dictionary <UnitTypes, float> modifiers) { UnitGameObject = game; IsHero = isHero; HasMoved = false; HasAttacked = false; AttackRange = attackRange; MoveRange = moveRange; CanAttackAfterMove = canAttackAfterMove; CurrentHealth = maxHealth; MaxHealth = maxHealth; Damage = damage; Cost = cost; FowLineOfSightRange = fowLos; BaseLoot = baseLoot; CurrentLoot = baseLoot; Modifiers = modifiers; }
public void DecreaseHealth(float damage) { CurrentHealth -= damage; UnitGameObject.UpdateHealthText(); }