//-------------------------------------------------------------------------------------------------------- public void GainInjury(BodyHitLocation location) { InjuryData injury = injuryChart.GetRandomInjury(location); Injuries.Add(injury); Debug.Log(hostUnit.UnitData.DisplayName + ": New " + location + " injury gained: " + injury.Name + " (" + injury.Description + ")."); }
//-------------------------------------------------------------------------------------------------------- public void TakeDamage(BodyHitLocation location, int amount) { foreach (var region in regions.Where(region => region.HitLocation == location)) { region.CurrentHealth = Mathf.Max(region.CurrentHealth - amount, 0); Debug.Log(hostUnit.UnitData.DisplayName + ": " + amount + " damage taken to " + location); if (region.CurrentHealth == 0) { GainInjury(location); } // if we have 3 injuries, die if (Injuries.Count >= 3) { hostUnit.Die(); } } }
//---------------------------------------------------------------------------------------------- public InjuryData GetRandomInjury(BodyHitLocation hitLocation) { List <InjuryData> locInjuries = Injuries.Where(injury => injury.HitLocation == hitLocation).ToList(); return(locInjuries[Random.Range(0, locInjuries.Count - 1)]); }
//-------------------------------------------------------------------------------------------------------- public int GetMaxtHealth(BodyHitLocation location) { return(regions.Where(region => region.HitLocation == location).Select(region => region.MaxHealth).FirstOrDefault()); }
//-------------------------------------------------------------------------------------------------------- public void TakeDamage(int amount) { BodyHitLocation randomHitLoc = regions[Random.Range(0, regions.Count)].HitLocation; TakeDamage(randomHitLoc, amount); }