Beispiel #1
0
        public override string Compile()
        {
            string        output    = "";
            WeaponInfo    oldWeapon = null;
            WeaponInfo    newWeapon = null;
            BuildableInfo entity    = null;


            if (ApplicationType == ApplicationTypes.ApplyToEntity)
            {
                if (this.Parent.Parent is BuildableInfo)
                {
                    entity = ((BuildableInfo)Parent.Parent);
                }
            }
            else
            {
                entity = DataDumper.Units[Target] as BuildableInfo;
            }
            try
            {
                if (entity != null)
                {
                    WeaponHardPointInfo whpInfo = entity.WeaponHardPoints[HardPoint] as WeaponHardPointInfo;
                    oldWeapon = (WeaponInfo)whpInfo.Weapons[whpInfo.UpgradeValue];
                    whpInfo.UpgradeValue++;
                    newWeapon = (WeaponInfo)whpInfo.Weapons[whpInfo.UpgradeValue];
                    if (!oldWeapon.IsDummyWeapon())
                    {
                        if (ApplicationType == ApplicationTypes.ApplyToEntityType)
                        {
                            output += "Upgrades " + entity.Name + "'s " + Translation.Translate(oldWeapon.Name) + " to " + Translation.Translate(newWeapon.Name);
                        }
                        else if (ApplicationType == ApplicationTypes.ApplyToEntity)
                        {
                            output += "Upgrades " + Translation.Translate(oldWeapon.Name) + " to " + Translation.Translate(newWeapon.Name);
                        }
                    }
                    else
                    {
                        output += "Equips " + entity.Name + " with " + Translation.Translate(newWeapon.Name);
                    }
                }
            }
            catch {  }
            return(output);
        }
Beispiel #2
0
        public override string Compile()
        {
            string   output = "";
            string   Weapon = "";
            UnitInfo unit   = null;

            if (Target != null)
            {
                unit = DataDumper.Units[Target] as UnitInfo;
            }
            if (ApplicationType == ApplicationTypes.ApplyToEntity)
            {
                if (Parent is UnitInfo)
                {
                    unit = Parent as UnitInfo;
                }
                else if (this.Parent.Parent is UnitInfo)
                {
                    unit = this.Parent.Parent as UnitInfo;
                }
            }
            try
            {
                if (unit != null)
                {
                    WeaponHardPointInfo whpInfo = unit.WeaponHardPoints[HardPoint] as WeaponHardPointInfo;

                    Weapon = ((WeaponInfo)whpInfo.Weapons[0]).Name;

                    output += (Amount == -1) ? "Disables " : "Enables ";

                    if (ApplicationType != ApplicationTypes.ApplyToEntity)
                    {
                        output += unit.Name + "'s ";
                    }
                    output += Translation.Translate(Weapon);
                }
                else
                {
                    output += (Amount == -1) ? "Disables " : "Enables ";
                    output += "the main weapon.";
                }
            }
            catch { }
            return(output);
        }
        public static WeaponInfo GetWeapon(BuildableInfo info, int hardpoint, int index)
        {
            WeaponHardPointInfo whp = null;

            whp = info.WeaponHardPoints[hardpoint] as WeaponHardPointInfo;
            if (whp == null)
            {
                return(null);
            }
            foreach (WeaponInfo wpInfo in whp.Weapons)
            {
                if (wpInfo.WeaponIndex == index)
                {
                    return(wpInfo);
                }
            }
            return(null);
        }