internal void Damage(int damage) { MechLocation damageLocation = BattleTechTables.Instance.LookupHitLocation(); AssignDamage(damageLocation, damage); status.UpdateDamage(this); }
private void AssignDamage(MechLocation location, int damage) { if (Destroyed) { return; } if (damage <= armor[location]) { armor[location] -= damage; BattleTechSim.Instance.streamBuffer += mechType + " takes " + damage + " damage to the " + location.ToString() + ". "; if (armor[location] == 0) { BattleTechSim.Instance.streamBuffer += location.ToString() + " armor depleted. "; } return; } else // extra damage transfers inward { if (armor[location] > 0) { damage -= armor[location]; armor[location] = 0; BattleTechSim.Instance.streamBuffer += location.ToString() + " armor depleted. "; } } if (damage < structure[location]) { structure[location] -= damage; BattleTechSim.Instance.streamBuffer += mechType + " takes " + damage + " internal damage to the " + location.ToString() + ". "; return; } else { if (structure[location] > 0) { damage -= structure[location]; structure[location] = 0; BattleTechSim.Instance.streamBuffer += location.ToString() + " destroyed. "; DestroyWeapons(location); } // Check if mech destroyed if (location == MechLocation.Head || location == MechLocation.CenterTorso) { Destroyed = true; BattleTechSim.Instance.streamBuffer += mechType + " is destroyed. "; return; } if (damage > 0) { MechLocation transferLocation = BattleTechTables.Instance.LookupDamageTransferLocation(location); AssignDamage(transferLocation, damage); } } }
private void BuildArmorStructure() { structure.Clear(); armor.Clear(); foreach (ArmorValues a in armorValues) { MechLocation loc = (MechLocation)Enum.Parse(typeof(MechLocation), a.location); structure[loc] = a.structure; armor[loc] = a.armor; } }
private void DestroyWeapons(MechLocation location) { Weapon wp = null; bool found = false; foreach (Weapon weapon in weapons) { if (weapon.Location == location) { wp = weapon; found = true; break; } } if (found) { disabledWeapons.Add(wp); weapons.Remove(wp); BattleTechSim.Instance.streamBuffer += "The " + wp.type + " has been destroyed. "; } }
internal MechLocation LookupDamageTransferLocation(MechLocation location) { return(damageTransferTable[location]); }
internal int GetPartStructure(MechLocation location) { return(structure[location]); }
internal int GetPartArmor(MechLocation location) { return(armor[location]); }