Esempio n. 1
0
    private static bool ValidateSquadCost(PlayerNo playerNo)
    {
        bool result = true;

        int squadCost = 0;

        foreach (var shipConfig in Global.ShipConfigurations)
        {
            if (shipConfig.PlayerNo == playerNo)
            {
                Ship.GenericShip shipContainer = (Ship.GenericShip)System.Activator.CreateInstance(System.Type.GetType(shipConfig.PilotName));
                squadCost += shipContainer.Cost;

                foreach (var upgrade in shipConfig.Upgrades)
                {
                    Upgrade.GenericUpgrade upgradeContainer = (Upgrade.GenericUpgrade)System.Activator.CreateInstance(System.Type.GetType(upgrade));
                    squadCost += upgradeContainer.Cost;
                }
            }
        }

        if (squadCost > 100)
        {
            Messages.ShowError("Cost of squadron cannot be more than 100");
            result = false;
        }

        return(result);
    }
Esempio n. 2
0
    private static bool ValidateUniqueCards(PlayerNo playerNo)
    {
        bool result = true;

        List <string> uniqueCards = new List <string>();

        foreach (var shipConfig in Global.ShipConfigurations)
        {
            if (shipConfig.PlayerNo == playerNo)
            {
                Ship.GenericShip shipContainer = (Ship.GenericShip)System.Activator.CreateInstance(System.Type.GetType(shipConfig.PilotName));

                if (shipContainer.IsUnique)
                {
                    if (CheckDuplicate(uniqueCards, shipContainer.PilotName))
                    {
                        return(false);
                    }
                }

                foreach (var upgrade in shipConfig.Upgrades)
                {
                    Upgrade.GenericUpgrade upgradeContainer = (Upgrade.GenericUpgrade)System.Activator.CreateInstance(System.Type.GetType(upgrade));
                    if (upgradeContainer.isUnique)
                    {
                        if (CheckDuplicate(uniqueCards, upgradeContainer.Name))
                        {
                            return(false);
                        }
                    }
                }
            }
        }
        return(result);
    }
Esempio n. 3
0
    private static List <string> GetUpgrades(Upgrade.UpgradeSlot slot)
    {
        List <string> results = new List <string>();

        List <Type> typelist = Assembly.GetExecutingAssembly().GetTypes()
                               .Where(t => String.Equals(t.Namespace, "UpgradesList", StringComparison.Ordinal))
                               .ToList();

        foreach (var type in typelist)
        {
            Upgrade.GenericUpgrade newUpgrade = (Upgrade.GenericUpgrade)System.Activator.CreateInstance(type);
            if (!newUpgrade.IsHidden)
            {
                if (newUpgrade.Type == slot)
                {
                    string upgradeKey = newUpgrade.Name + " (" + newUpgrade.Cost + ")";
                    if (!AllUpgrades.ContainsKey(upgradeKey))
                    {
                        AllUpgrades.Add(upgradeKey, type.ToString());
                    }
                    results.Add(upgradeKey);
                }
            }
        }

        return(results);
    }
Esempio n. 4
0
    private static string GetUpgradeTooltipImage(GameObject panel)
    {
        string upgradeKey = panel.GetComponent <Dropdown>().captionText.text;

        if (AllUpgrades.ContainsKey(upgradeKey))
        {
            Upgrade.GenericUpgrade upgrade = (Upgrade.GenericUpgrade)Activator.CreateInstance(Type.GetType(AllUpgrades[upgradeKey]));
            return(upgrade.ImageUrl);
        }
        return(null);
    }
Esempio n. 5
0
    // Update Costs

    private static void UpdateShipCost(PlayerNo playerNo, GameObject panel)
    {
        int totalShipCost = 0;

        string pilotKey = panel.transform.Find("GroupShip/DropdownPilot").GetComponent <Dropdown>().captionText.text;

        Ship.GenericShip shipContainer = (Ship.GenericShip)Activator.CreateInstance(Type.GetType(AllPilots[pilotKey]));
        totalShipCost += shipContainer.Cost;

        foreach (Transform upgradePanel in panel.transform.Find("GroupUpgrades"))
        {
            string upgradeName = upgradePanel.transform.GetComponent <Dropdown>().captionText.text;

            if (AllUpgrades.ContainsKey(upgradeName))
            {
                Upgrade.GenericUpgrade upgradeContainer = (Upgrade.GenericUpgrade)Activator.CreateInstance(System.Type.GetType(AllUpgrades[upgradeName]));
                totalShipCost += upgradeContainer.Cost;
            }
        }

        panel.transform.Find("Panel/CostPanel").GetComponentInChildren <Text>().text = totalShipCost.ToString();
        UpdateSquadCost(playerNo);
    }
Esempio n. 6
0
        // FLIP FACEUP

        public void TryFlipFaceUp(Action callBack)
        {
            CurrentUpgrade = this;
            HostShip.CallFlipFaceUpUpgrade(() => AfterTriedFlipFaceUp(callBack));
        }
Esempio n. 7
0
        // DISCARD

        public void TryDiscard(Action callBack)
        {
            CurrentUpgrade = this;
            HostShip.CallDiscardUpgrade(delegate { AfterTriedDiscard(callBack); });
        }
Esempio n. 8
0
        public void TryInstallUpgrade(string upgradeName)
        {
            GenericUpgrade upgrade = (GenericUpgrade)System.Activator.CreateInstance(System.Type.GetType(upgradeName));

            TryInstallUpgrade(upgrade);
        }
Esempio n. 9
0
        private bool CheckRequirements(GenericUpgrade upgrade)
        {
            bool result = true;

            return(result);
        }
Esempio n. 10
0
 public void PreInstallUpgrade(GenericUpgrade upgrade, Ship.GenericShip host)
 {
     InstalledUpgrade = upgrade;
     InstalledUpgrade.PreAttachToShip(host);
 }
Esempio n. 11
0
 public static string GetImageUrl(Upgrade.GenericUpgrade upgrade, string filename = null)
 {
     return(GetImageUrl(UpgradesPath + upgrade.Type.ToString(), upgrade.Name, filename));
 }