コード例 #1
0
        public void PreInstallUpgrade(GenericUpgrade upgrade, Ship.GenericShip host)
        {
            InstalledUpgrade = upgrade;
            upgrade.Slot     = this;
            InstalledUpgrade.PreAttachToShip(host);

            // check if its a dual upgrade
            if (upgrade.Types.Count > 1)
            {
                // clone upgrade
                //GenericUpgrade newUpgrade = (GenericUpgrade)System.Activator.CreateInstance(upgrade.Types[0]);
                UpgradesList.EmptyUpgrade emptyUpgrade = new UpgradesList.EmptyUpgrade();
                emptyUpgrade.set(upgrade.Types, upgrade.Name, 0);

                int emptySlotsFilled = 0; // Fixes bug #708. TODO: Will need to revisit to support multi-type upgrades.
                // find another slot
                foreach (UpgradeSlot tempSlot in host.UpgradeBar.GetUpgradeSlots())
                {
                    if (emptySlotsFilled < emptyUpgrade.Types.Count && tempSlot.IsEmpty && upgrade.HasType(tempSlot.Type))
                    {
                        emptySlotsFilled += 1; // Fixes bug #708.
                        tempSlot.PreInstallUpgrade(emptyUpgrade, host);
                    }
                }
            }

            if (OnPreInstallUpgrade != null)
            {
                OnPreInstallUpgrade(upgrade);
            }
        }
コード例 #2
0
ファイル: UpgradeSlot.cs プロジェクト: vitreuz/FlyCasual
        public void PreInstallUpgrade(GenericUpgrade upgrade, GenericShip host)
        {
            HostShip         = host;
            InstalledUpgrade = upgrade;
            upgrade.Slot     = this;
            InstalledUpgrade.PreAttachToShip(host);

            if (upgrade.UpgradeInfo.UpgradeTypes.Count > 1)
            {
                List <UpgradeType> extraSlots = new List <UpgradeType>(upgrade.UpgradeInfo.UpgradeTypes);
                extraSlots.Remove(extraSlots.First(n => n == this.Type));

                foreach (UpgradeType upgradeType in extraSlots)
                {
                    // Clone upgrade to fill extra slots
                    UpgradesList.EmptyUpgrade emptyUpgrade = new UpgradesList.EmptyUpgrade();
                    emptyUpgrade.SetUpgradeInfo(upgradeType, upgrade.UpgradeInfo.Name, 0);

                    UpgradeSlot tempSlot = host.UpgradeBar.GetUpgradeSlots().First(n => n.IsEmpty && emptyUpgrade.HasType(n.Type));
                    tempSlot.PreInstallUpgrade(emptyUpgrade, host);
                }
            }

            if (DebugManager.FreeMode)
            {
                if (!host.UpgradeBar.HasFreeUpgradeSlot(new List <UpgradeType>()
                {
                    UpgradeType.Omni
                }))
                {
                    host.UpgradeBar.AddSlot(UpgradeType.Omni);
                }
            }

            OnPreInstallUpgrade?.Invoke(upgrade);
        }
コード例 #3
0
        public void PreInstallUpgrade(GenericUpgrade upgrade, Ship.GenericShip host)
        {
            InstalledUpgrade = upgrade;
            upgrade.Slot = this;
            InstalledUpgrade.PreAttachToShip(host);

            // check if its a dual upgrade
            if (upgrade.Types.Count > 1)
            {
                // clone upgrade
                //GenericUpgrade newUpgrade = (GenericUpgrade)System.Activator.CreateInstance(upgrade.Types[0]);
                UpgradesList.EmptyUpgrade emptyUpgrade = new UpgradesList.EmptyUpgrade();
                emptyUpgrade.set(upgrade.Types, upgrade.Name, 0);

                // find another slot
                foreach (UpgradeSlot tempSlot in host.UpgradeBar.GetUpgradeSlots())
                {
                    if (tempSlot.IsEmpty && upgrade.hasType(tempSlot.Type))
                    {
                        tempSlot.PreInstallUpgrade(emptyUpgrade, host);
                    }
                }
            }
        }