Esempio n. 1
0
    private void showShips()
    {
        SquadBuilderUtil.resetScrollView(shipsScroll);

        int shipIndex = 0;

        foreach (Ship ship in ships.Ship)
        {
            if (ship.Size.Equals(LocalDataWrapper.getPlayer().getChosenSize()))
            {
                Transform     shipPanelPrefab = Resources.Load <Transform>(SquadBuilderConstants.PREFABS_FOLDER_NAME + "/" + SquadBuilderConstants.SHIP_NAME_PANEL);
                RectTransform rt = (RectTransform)shipPanelPrefab;
                float         shipPanelHeight = rt.rect.height;

                Transform shipPanel = (Transform)GameObject.Instantiate(
                    shipPanelPrefab,
                    new Vector3(SquadBuilderConstants.SHIP_PANEL_X_OFFSET, (shipIndex * shipPanelHeight * -1) + SquadBuilderConstants.SHIP_PANEL_Y_OFFSET, SquadBuilderConstants.SHIP_PANEL_Z_OFFSET),
                    Quaternion.identity
                    );

                shipPanel.transform.SetParent(shipsScroll.transform, false);
                shipPanel.transform.Find("ShipName").gameObject.GetComponent <UnityEngine.UI.Text>().text = ship.ShipName.ToLower();

                SquadBuilderShipPanelEvents shipPanelUIEvent = shipPanel.transform.GetComponent <SquadBuilderShipPanelEvents>();
                shipPanelUIEvent.setShip(ship);

                shipIndex++;
            }
        }
    }
Esempio n. 2
0
    private void showPilots()
    {
        SquadBuilderUtil.resetScrollView(pilotsScroll);

        int pilotIndex = 0;

        foreach (PilotsXMLCSharp.Pilot pilot in pilots.Pilot)
        {
            if (pilot.ShipId.Equals(LocalDataWrapper.getPlayer().getSelectedEmptyShip().ShipId))
            {
                //By default, load the first pilot as it would be selected...
                if (pilotIndex == 0)
                {
                    LocalDataWrapper.getPlayer().setSelectedPilot(pilot);
                }

                Transform     pilotPanelPrefab = Resources.Load <Transform>(SquadBuilderConstants.PREFABS_FOLDER_NAME + "/" + SquadBuilderConstants.PILOT_NAME_PANEL);
                RectTransform rt = (RectTransform)pilotPanelPrefab;
                float         pilotPanelHeight = rt.rect.height;

                Transform pilotPanel = (Transform)GameObject.Instantiate(
                    pilotPanelPrefab,
                    new Vector3(SquadBuilderConstants.PILOT_PANEL_X_OFFSET, (pilotIndex * pilotPanelHeight * -1) + SquadBuilderConstants.PILOT_PANEL_Y_OFFSET, SquadBuilderConstants.PILOT_PANEL_Z_OFFSET),
                    Quaternion.identity
                    );

                pilotPanel.transform.SetParent(pilotsScroll.transform, false);
                pilotPanel.transform.Find("PilotName").gameObject.GetComponent <UnityEngine.UI.Text>().text = pilot.Name.ToLower();

                SquadBuilderPilotPanelEvents pilotPanelUIEvent = pilotPanel.transform.GetComponent <SquadBuilderPilotPanelEvents>();
                pilotPanelUIEvent.setShip(pilot);

                pilotIndex++;
            }
        }
    }
Esempio n. 3
0
    public static void hideFileExplorer(GameObject fileExplorer)
    {
        SquadBuilderUtil.resetScrollView(fileExplorer.transform.Find("Scroll View/Viewport/Content").gameObject);

        fileExplorer.SetActive(false);
    }
Esempio n. 4
0
 private void closeUpgradesPopup()
 {
     UpgradesPopup.SetActive(false);
     SquadBuilderUtil.resetScrollView(UpgradesPopup.transform.Find("Scroll View/Viewport/Content").gameObject);
 }
Esempio n. 5
0
    private void showSquadron()
    {
        SquadBuilderUtil.resetScrollView(SquadronHolderContent);

        int shipPanelIndex = 0;

        foreach (LoadedShip loadedShip in LocalDataWrapper.getPlayer().getSquadron())
        {
            Transform     shipPanelPrefab = Resources.Load <Transform>(SquadBuilderConstants.PREFABS_FOLDER_NAME + "/" + SquadBuilderConstants.SQUADRON_SHIP_HOLDER);
            RectTransform rt = (RectTransform)shipPanelPrefab;
            float         shipPanelHeight = rt.rect.height;

            Transform shipPanel = (Transform)GameObject.Instantiate(
                shipPanelPrefab,
                new Vector3(SquadBuilderConstants.SQUADRON_SHIP_PANEL_X_OFFSET, (shipPanelIndex * shipPanelHeight * -1) + SquadBuilderConstants.SQUADRON_SHIP_PANEL_Y_OFFSET, SquadBuilderConstants.SQUADRON_SHIP_PANEL_Z_OFFSET),
                Quaternion.identity
                );

            shipPanel.transform.SetParent(SquadronHolderContent.transform, false);

            PilotRemoveEvents pilotRemoveEvent = shipPanel.transform.Find("DeleteButton").gameObject.GetComponent <PilotRemoveEvents>();
            pilotRemoveEvent.setPilot(loadedShip.getPilot());
            pilotRemoveEvent.setPilotId(loadedShip.getPilotId());

            Sprite sprite = Resources.Load <Sprite>(SquadBuilderConstants.IMAGE_FOLDER_NAME + "/" + loadedShip.getShip().ShipId);
            shipPanel.transform.Find("ShipImage").gameObject.GetComponent <Image>().sprite = sprite;
            Image image = shipPanel.transform.Find("ShipImage").gameObject.GetComponent <Image>();
            image.color = new Color(image.color.r, image.color.g, image.color.b, 1.0f);

            shipPanel.transform.Find("ShipImage/PilotLevel").gameObject.GetComponent <UnityEngine.UI.Text>().text = loadedShip.getPilot().Level.ToString();
            shipPanel.transform.Find("ShipImage/PilotCost").gameObject.GetComponent <UnityEngine.UI.Text>().text  = loadedShip.getPilot().Cost.ToString();
            shipPanel.transform.Find("AttackPower").gameObject.GetComponent <UnityEngine.UI.Text>().text          = loadedShip.getShip().Weapon.ToString();
            shipPanel.transform.Find("Agility").gameObject.GetComponent <UnityEngine.UI.Text>().text          = loadedShip.getShip().Agility.ToString();
            shipPanel.transform.Find("Shield").gameObject.GetComponent <UnityEngine.UI.Text>().text           = loadedShip.getShip().Shield.ToString();
            shipPanel.transform.Find("Hull").gameObject.GetComponent <UnityEngine.UI.Text>().text             = loadedShip.getShip().Hull.ToString();
            shipPanel.transform.Find("PilotName").gameObject.GetComponent <UnityEngine.UI.Text>().text        = loadedShip.getPilot().Name.ToLower();
            shipPanel.transform.Find("PilotDescription").gameObject.GetComponent <UnityEngine.UI.Text>().text = loadedShip.getPilot().Text;

            int upgradeSlotIndex = 0;

            foreach (UpgradeSlot upgrade in loadedShip.getPilot().UpgradeSlots.UpgradeSlot)
            {
                upgrade.upgradeSlotId = upgradeSlotIndex + 1;

                Transform upgradeSlotPrefab = Resources.Load <Transform>(SquadBuilderConstants.PREFABS_FOLDER_NAME + "/" + SquadBuilderConstants.UPGRADE_SLOT);
                rt = (RectTransform)upgradeSlotPrefab;
                float upgradeSlotWidth = rt.rect.width;

                Transform upgradeSlot = (Transform)GameObject.Instantiate(
                    upgradeSlotPrefab,
                    new Vector3((upgradeSlotIndex * upgradeSlotWidth) + SquadBuilderConstants.UPGRADE_SLOT_X_OFFSET, SquadBuilderConstants.UPGRADE_SLOT_Y_OFFSET, SquadBuilderConstants.UPGRADE_SLOT_Z_OFFSET),
                    Quaternion.identity
                    );

                upgradeSlot.transform.SetParent(shipPanel.transform, false);

                sprite = Resources.Load <Sprite>(SquadBuilderConstants.IMAGE_FOLDER_NAME + "/" + upgrade.Type);
                upgradeSlot.transform.Find("Image").gameObject.GetComponent <Image>().sprite = sprite;
                image       = upgradeSlot.transform.Find("Image").gameObject.GetComponent <Image>();
                image.color = new Color(image.color.r, image.color.g, image.color.b, 1.0f);

                UpgradeSlotEvents upgradeSlotEvents = upgradeSlot.transform.GetComponent <UpgradeSlotEvents>();
                upgradeSlotEvents.setUpgradeType(upgrade.Type);
                upgradeSlotEvents.setShip(loadedShip);
                upgradeSlotEvents.setSlotId(upgrade.upgradeSlotId);

                if (upgrade.upgrade == null)
                {
                    upgradeSlot.transform.Find("Cost").gameObject.GetComponent <UnityEngine.UI.Text>().text = "";
                    upgradeSlot.transform.Find("UpgradeDescription/Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = "EMPTY";
                }
                else
                {
                    upgradeSlot.transform.Find("Cost").gameObject.GetComponent <UnityEngine.UI.Text>().text = upgrade.upgrade.Cost.ToString();
                    upgradeSlot.transform.Find("UpgradeDescription/Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = upgrade.upgrade.Description;

                    // TODO If upgrade has attack power (and range), show them as well...
                }

                upgradeSlotIndex++;
            }

            shipPanelIndex++;
        }
    }