Ejemplo n.º 1
0
    internal void Damage(int damage)
    {
        MechLocation damageLocation = BattleTechTables.Instance.LookupHitLocation();

        AssignDamage(damageLocation, damage);
        status.UpdateDamage(this);
    }
Ejemplo n.º 2
0
    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);
            }
        }
    }
Ejemplo n.º 3
0
 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;
     }
 }
Ejemplo n.º 4
0
    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. ";
        }
    }
Ejemplo n.º 5
0
 internal MechLocation LookupDamageTransferLocation(MechLocation location)
 {
     return(damageTransferTable[location]);
 }
Ejemplo n.º 6
0
 internal int GetPartStructure(MechLocation location)
 {
     return(structure[location]);
 }
Ejemplo n.º 7
0
 internal int GetPartArmor(MechLocation location)
 {
     return(armor[location]);
 }