Ejemplo n.º 1
0
        public void ShowAvailablePilots(Faction faction, string shipName)
        {
            PilotPanelSquadBuilder.WaitingToLoad = 0;

            ShipRecord shipRecord = Global.SquadBuilder.Database.AllShips.Find(n => n.ShipName == shipName);

            List <PilotRecord> AllPilotsFiltered = Global.SquadBuilder.Database.AllPilots
                                                   .Where(n =>
                                                          n.Ship == shipRecord &&
                                                          n.PilotFaction == faction &&
                                                          n.Instance.GetType().ToString().Contains(Edition.Current.NameShort) &&
                                                          !n.Instance.IsHiddenSquadbuilderOnly
                                                          )
                                                   .OrderByDescending(n => n.PilotSkill).
                                                   OrderByDescending(n => n.Instance.PilotInfo.Cost).
                                                   ToList();
            int pilotsCount = AllPilotsFiltered.Count();

            Transform contentTransform = GameObject.Find("UI/Panels/SelectPilotPanel/Panel/Scroll View/Viewport/Content").transform;

            SquadBuilderView.DestroyChildren(contentTransform);
            contentTransform.localPosition = new Vector3(0, contentTransform.localPosition.y, contentTransform.localPosition.z);
            contentTransform.GetComponent <RectTransform>().sizeDelta = new Vector2(pilotsCount * (SquadBuilderView.PILOT_CARD_WIDTH + SquadBuilderView.DISTANCE_MEDIUM) + 2 * SquadBuilderView.DISTANCE_MEDIUM, 0);

            foreach (PilotRecord pilot in AllPilotsFiltered)
            {
                ShowAvailablePilot(pilot);
            }
        }
Ejemplo n.º 2
0
        public void ShowAvailableShips(Faction faction)
        {
            AvailableShipsCounter = 0;

            SquadBuilderView.DestroyChildren(GameObject.Find("UI/Panels/SelectShipPanel/Panel").transform);

            bool isAnyShipShown = false;

            ShipPanelSquadBuilder.WaitingToLoad = 0;

            foreach (ShipRecord ship in Global.SquadBuilder.Database.AllShips.OrderBy(s => s.Instance.ShipInfo.ShipName))
            {
                if (ship.Instance.ShipInfo.FactionsAll.Contains(faction) && !ship.Instance.IsHidden && HasPilots(ship, faction))
                {
                    if (ship.Instance.GetType().ToString().Contains(Edition.Current.NameShort))
                    {
                        ShowAvailableShip(ship, faction);
                        isAnyShipShown = true;
                    }
                }
            }

            if (!isAnyShipShown)
            {
                SquadBuilderView.ShowNoContentInfo("Ship");
            }
            else
            {
                ScaleSelectShipPanel(faction);
            }
        }
Ejemplo n.º 3
0
        public void ShowBrowseObstaclesPanel()
        {
            string     prefabPath = "Prefabs/SquadBuilder/ObstacleViewPanelSmall";
            GameObject prefab     = (GameObject)Resources.Load(prefabPath, typeof(GameObject));
            GameObject contentGO  = GameObject.Find("UI/Panels/BrowseObstaclesPanel/Content").gameObject;

            SquadBuilderView.DestroyChildren(contentGO.transform);
            SquadBuilderView.DestroyChildren(GameObject.Find("PreviewsHolder").transform);

            for (int i = 0; i < ObstaclesManager.Instance.AllPossibleObstacles.Count; i++)
            {
                GameObject      newObstacleViewPanel = GameObject.Instantiate(prefab, contentGO.transform);
                GenericObstacle obstacle             = ObstaclesManager.Instance.AllPossibleObstacles[i];
                newObstacleViewPanel.GetComponent <ObstacleViewPanelScript>().Initialize(
                    obstacle,
                    i,
                    delegate {
                    int index = Global.SquadBuilder.CurrentSquad.ChosenObstacles.IndexOf(CurrentObstacle);
                    Global.SquadBuilder.CurrentSquad.ChosenObstacles[index] = obstacle;
                    MainMenu.CurrentMainMenu.ChangePanel("ChosenObstaclesPanel");
                }
                    );
                if (Global.SquadBuilder.CurrentSquad.ChosenObstacles.Contains(obstacle) && obstacle != CurrentObstacle)
                {
                    newObstacleViewPanel.GetComponent <Button>().interactable = false;
                }
            }
        }
Ejemplo n.º 4
0
        public void ShowChosenObstaclesPanel()
        {
            string     prefabPath = "Prefabs/SquadBuilder/ObstacleViewPanel";
            GameObject prefab     = (GameObject)Resources.Load(prefabPath, typeof(GameObject));
            GameObject contentGO  = GameObject.Find("UI/Panels/ChosenObstaclesPanel/Content/ObstaclesPanel").gameObject;

            SquadBuilderView.DestroyChildren(contentGO.transform);
            SquadBuilderView.DestroyChildren(GameObject.Find("PreviewsHolder").transform);

            for (int i = 0; i < 3; i++)
            {
                GameObject      newObstacleViewPanel = GameObject.Instantiate(prefab, contentGO.transform);
                GenericObstacle obstacle             = Global.SquadBuilder.CurrentSquad.ChosenObstacles[i];
                newObstacleViewPanel.GetComponent <ObstacleViewPanelScript>().Initialize(
                    obstacle,
                    i + 1,
                    delegate {
                    CurrentObstacle = obstacle;
                    MainMenu.CurrentMainMenu.ChangePanel("BrowseObstaclesPanel");
                }
                    );
            }

            MainMenu.ScalePanel(contentGO.transform);
        }
        public void GeneratePilotWithSlotsPanels()
        {
            Transform shipWithSlotsTransform = GameObject.Find("UI/Panels/ShipSlotsPanel/Panel/ShipWithSlotsHolderPanel").transform;

            SquadBuilderView.DestroyChildren(shipWithSlotsTransform);
            shipWithSlotsTransform.GetComponent <RectTransform>().sizeDelta = Vector2.zero;

            CreatePilotPanel();
            CreateSlotsPanels();

            OrganizeShipWithSlotsPanels();
        }
Ejemplo n.º 6
0
        public void ShowListOfSavedSquadrons(List <JSONObject> squadsJsonsList)
        {
            SetNoSavedSquadronsMessage(squadsJsonsList.Count == 0);

            float FREE_SPACE = 25;

            Transform contentTransform = GameObject.Find("UI/Panels/BrowseSavedSquadsPanel/Scroll View/Viewport/Content").transform;

            SquadBuilderView.DestroyChildren(contentTransform);

            GameObject prefab = (GameObject)Resources.Load("Prefabs/SquadBuilder/SavedSquadronPanel", typeof(GameObject));

            //RectTransform contentRectTransform = contentTransform.GetComponent<RectTransform>();
            //Vector3 currentPosition = new Vector3(0, -FREE_SPACE, contentTransform.localPosition.z);

            foreach (var squadList in squadsJsonsList)
            {
                GameObject SquadListRecord;

                SquadListRecord = MonoBehaviour.Instantiate(prefab, contentTransform);

                SquadListRecord.transform.Find("Name").GetComponent <Text>().text = squadList["name"].str;

                Text          descriptionText          = SquadListRecord.transform.Find("Description").GetComponent <Text>();
                RectTransform descriptionRectTransform = SquadListRecord.transform.Find("Description").GetComponent <RectTransform>();
                if (squadList.HasField("description"))
                {
                    descriptionText.text = squadList["description"].str.Replace("\\\"", "\"");
                }
                else
                {
                    descriptionText.text = "No description";
                }

                float descriptionPreferredHeight = descriptionText.preferredHeight;
                descriptionRectTransform.sizeDelta = new Vector2(descriptionRectTransform.sizeDelta.x, descriptionPreferredHeight);

                SquadListRecord.transform.Find("PointsValue").GetComponent <Text>().text = squadList["points"].i.ToString();

                SquadListRecord.GetComponent <RectTransform>().sizeDelta = new Vector2(
                    SquadListRecord.GetComponent <RectTransform>().sizeDelta.x,
                    15 + 70 + 10 + descriptionPreferredHeight + 10 + 55 + 10
                    );

                SquadListRecord.name = squadList["filename"].str;

                SquadListRecord.transform.Find("DeleteButton").GetComponent <Button>().onClick.AddListener(delegate { DeleteSavedSquadAndRefresh(SquadListRecord.name); });
                SquadListRecord.transform.Find("LoadButton").GetComponent <Button>().onClick.AddListener(delegate { LoadSavedSquadAndReturn(GetSavedSquadJson(SquadListRecord.name)); });
            }

            SquadBuilderView.OrganizePanels(contentTransform, FREE_SPACE);
        }
        public void ShowSkinsPanel()
        {
            string     prefabPath = "Prefabs/SquadBuilder/SkinSelectionPanel";
            GameObject prefab     = (GameObject)Resources.Load(prefabPath, typeof(GameObject));
            GameObject contentGO  = GameObject.Find("UI/Panels/SkinsPanel/Content/Scroll View/Viewport/Content").gameObject;

            int shipsCount = Global.SquadBuilder.CurrentSquad.Ships.Count;

            contentGO.GetComponent <RectTransform>().sizeDelta = new Vector2(shipsCount * 600 + ((shipsCount + 1) * 20), 0);

            SquadBuilderView.DestroyChildren(contentGO.transform);
            SquadBuilderView.DestroyChildren(GameObject.Find("PreviewsHolder").transform);
            int i = 0;

            foreach (SquadListShip ship in Global.SquadBuilder.CurrentSquad.Ships)
            {
                GameObject newSkinPanel = GameObject.Instantiate(prefab, contentGO.transform);
                newSkinPanel.GetComponent <SkinSelectionPanelScript>().Initialize(ship.Instance, i++);
            }
        }
Ejemplo n.º 8
0
 public SquadsManagement(SquadBuilderView squadBuilderView)
 {
     View = squadBuilderView;
 }
 private void Cleanup()
 {
     ShipWithUpgradesPanels = new List <ShipWithUpgradesPanelInfo>();
     SquadBuilderView.DestroyChildren(GameObject.Find("UI/Panels/SquadBuilderPanel/Panel/SquadListPanel").transform);
 }
 public SquadBuilderPilotWithSlotsView(SquadBuilderView view)
 {
     View = view;
 }
Ejemplo n.º 11
0
        public void ShowAvailableUpgrades(UpgradeSlot slot)
        {
            UpgradePanelSquadBuilder.WaitingToLoad = 0;

            List <UpgradeRecord> filteredUpgrades = null;

            if (slot.Type != UpgradeType.Omni)
            {
                filteredUpgrades = Global.SquadBuilder.Database.AllUpgrades.Where(n =>
                                                                                  n.Instance.HasType(slot.Type) &&
                                                                                  n.Instance.UpgradeInfo.Restrictions.IsAllowedForShip(Global.SquadBuilder.CurrentShip.Instance) &&
                                                                                  n.Instance.IsAllowedForShip(Global.SquadBuilder.CurrentShip.Instance) &&
                                                                                  n.Instance.HasEnoughSlotsInShip(Global.SquadBuilder.CurrentShip.Instance) &&
                                                                                  ShipDoesntHaveUpgradeWithSameName(Global.SquadBuilder.CurrentShip.Instance, n.Instance)
                                                                                  ).ToList();
            }
            else
            {
                filteredUpgrades = Global.SquadBuilder.Database.AllUpgrades;
            }

            int filteredUpgradesCount = filteredUpgrades.Count();

            //Clear search text
            GameObject.Find("UI/Panels/SelectUpgradePanel/TopPanel/InputField").GetComponent <InputField>().text = "";

            Transform contentTransform = GameObject.Find("UI/Panels/SelectUpgradePanel/Panel/Scroll View/Viewport/Content").transform;

            SquadBuilderView.DestroyChildren(contentTransform);

            if (filteredUpgradesCount > 0)
            {
                contentTransform.localPosition = new Vector3(0, contentTransform.localPosition.y, contentTransform.localPosition.z);
                contentTransform.GetComponent <RectTransform>().sizeDelta = new Vector2(filteredUpgradesCount * (Edition.Current.UpgradeCardSize.x * 1.5f + SquadBuilderView.DISTANCE_MEDIUM) + 2 * SquadBuilderView.DISTANCE_MEDIUM, 0);

                foreach (UpgradeRecord upgrade in filteredUpgrades)
                {
                    if (upgrade.Instance is IVariableCost && Edition.Current is SecondEdition)
                    {
                        (upgrade.Instance as IVariableCost).UpdateCost(Global.SquadBuilder.CurrentShip.Instance);
                        if (upgrade.Instance.UpgradeInfo.Cost == int.MaxValue)
                        {
                            upgrade.Instance.IsHidden = true;
                        }
                    }
                }

                filteredUpgrades = filteredUpgrades.OrderBy(n => n.Instance.UpgradeInfo.Cost).ToList();

                foreach (UpgradeRecord upgrade in filteredUpgrades)
                {
                    ShowAvailableUpgrade(upgrade);
                }

                GridLayoutGroup grid = GameObject.Find("UI/Panels/SelectUpgradePanel/Panel/Scroll View/Viewport/Content").GetComponent <GridLayoutGroup>();
                grid.cellSize = new Vector2(Edition.Current.UpgradeCardSize.x * 1.5f, Edition.Current.UpgradeCardSize.y * 1.5f);
            }
            else
            {
                SquadBuilderView.ShowNoContentInfo("Upgrade");
            }
        }