예제 #1
0
        public static void ShowListOfArchetypesVariants()
        {
            GameObject prefab          = (GameObject)Resources.Load("Prefabs/SquadBuilder/SavedSquadronPanel", typeof(GameObject));
            GameObject archetypesPanel = GameObject.Find("UI/Panels").transform.Find("BrowsePopularSquadsVariantsPanel").Find("Scroll View/Viewport/Content").gameObject;

            RectTransform contentTransform = archetypesPanel.GetComponent <RectTransform>();

            foreach (Transform transform in contentTransform.transform)
            {
                GameObject.Destroy(transform.gameObject);
            }

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

            foreach (var squadJson in VariantsData.list)
            {
                SquadList squadList = new SquadList(Players.PlayerNo.PlayerNone);

                JSONObject squadJsonFixed = new JSONObject(squadJson["json"].str);
                if (existingLists.Contains(squadJsonFixed.ToString()))
                {
                    continue;
                }
                existingLists.Add(squadJsonFixed.ToString());

                SquadBuilder.SetPlayerSquadFromImportedJson(squadJsonFixed, squadList, delegate { });

                GameObject SquadListRecord;

                SquadListRecord = MonoBehaviour.Instantiate(prefab, contentTransform);

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

                Text          descriptionText          = SquadListRecord.transform.Find("Description").GetComponent <Text>();
                RectTransform descriptionRectTransform = SquadListRecord.transform.Find("Description").GetComponent <RectTransform>();
                if (squadJson.HasField("json"))
                {
                    descriptionText.text = SquadBuilder.GetDescriptionOfSquadJson(squadJsonFixed).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.ToString();

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

                SquadListRecord.transform.Find("DeleteButton").gameObject.SetActive(false);
                SquadListRecord.transform.Find("LoadButton").GetComponent <Button>().onClick.AddListener(delegate { SquadBuilder.LoadSavedSquadAndReturn(squadJsonFixed); });
            }

            OrganizePanels(contentTransform, FREE_SPACE);
        }
예제 #2
0
        public SquadBuilder()
        {
            Instance = this;

            Database   = new ContentDatabase(Edition.Current);
            SquadLists = new SquadLists();

            CurrentPlayer = PlayerNo.Player1;
        }
예제 #3
0
        public static void CheckAiButtonVisibility()
        {
            bool isAi = GetSquadList(CurrentPlayer).PlayerType.IsSubclassOf(typeof(GenericAiPlayer));

            GameObject.Find("UI/Panels/SquadBuilderPanel/Panel/SquadBuilderTop").transform.Find("AIButton").gameObject.SetActive(isAi);

            if (isAi)
            {
                SquadBuilder.SetAiType(Options.AiType);
            }
        }
예제 #4
0
        public SquadBuilderView(SquadBuilder model)
        {
            Model      = model;
            Model.View = this;

            RosterView          = GameObject.Find("UI/Panels/SquadBuilderPanel/Panel").GetComponent <SquadBuilderRosterView>();
            ShipsView           = new SquadBuilderShipsView();
            PilotsView          = new SquadBuilderPilotsView();
            UpgradesView        = new SquadBuilderUpgradesView();
            PilotWithSlotsView  = new SquadBuilderPilotWithSlotsView(this);
            ObstaclesView       = new SquadBuilderObstaclesView();
            ShipInformationView = new SquadBuilderShipInformationView();
            SkinsView           = new SquadBuilderSkinsView();
            SquadsManagement    = new SquadsManagement(this);
        }