Ejemplo n.º 1
0
        public void Damage()
        {
            // Destroy random component
            int total = 0;

            foreach (Item itm in Installed)
            {
                total += itm.Amount;
            }
            if (total == 0)
            {
                return;
            }
            int idx = Constants.Random(total);

            for (int i = 0; i < Installed.Count; i++)
            {
                idx -= Installed[i].Amount;
                if (idx > 0)
                {
                    continue;
                }
                Installed.RemoveItems(Installed[i].Type, 1);
                break;
            }

            // If first components spent, collapse
            if (Installed.Count == 0 ||
                (Type.Materials.Count > 0 && Installed.GetByType(Type.Materials[0].Type) == null))
            {
                Collapse();
            }
        }
Ejemplo n.º 2
0
        public void TakeItem(Battle btl, Soldier s, ItemArrayList equipment, ItemType it)
        {
            Item itm = equipment.GetByType(it);

            if (itm == null)
            {
                return;
            }

            // Get weapon
            if (itm.Type.IsWeapon && Weapon == null)
            {
                // Check skill
                if (itm.Type.WeaponSkill == null)
                {
                    throw new Exception("Weapon should have WeaponSkill");
                }
                Skill sk = Person.Skills.GetByType(itm.Type.WeaponSkill);
                if (sk == null)
                {
                    return;
                }

                // Check ammo
                if (itm.Type.Ammo != null)
                {
                    Item ammo = s.Person.Items.GetByType(itm.Type.Ammo);
                    if (ammo != null)
                    {
                        Ammo = ammo.Amount;
                    }
                    if (Ammo == 0)
                    {
                        return;
                    }
                }

                // Get the weapon
                Weapon     = itm.Type;
                SkillLevel = sk.Level;
                if (itm.Type.Heavy && btl != null)
                {
                    if (btl.TakenHwpn[itm] == null)
                    {
                        btl.TakenHwpn[itm] = 1;
                    }
                    else
                    {
                        btl.TakenHwpn[itm] = (int)btl.TakenHwpn[itm] + 1;
                    }
                }
            }

            // Get armor
            if (itm.Type.IsArmor && Armor == null)
            {
                Armor = itm.Type;
            }
        }