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());

                squadList.SetPlayerSquadFromImportedJson(squadJsonFixed);

                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 = SquadJsonHelper.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 { Global.SquadBuilder.View.LoadSavedSquadAndReturn(squadJsonFixed); });
            }

            OrganizePanels(contentTransform, FREE_SPACE);
        }
Exemple #2
0
 public void SaveSquadronToFile(string squadName)
 {
     SquadJsonHelper.SaveSquadronToFile(this, squadName);
 }
Exemple #3
0
 public void CreateSquadFromImportedJson(string squadString)
 {
     SquadJsonHelper.CreateSquadFromImportedJson(this, squadString);
 }
Exemple #4
0
 public JSONObject GetSquadInJson()
 {
     return(SquadJsonHelper.GetSquadInJson(this));
 }
Exemple #5
0
 public void SetPlayerSquadFromImportedJson(JSONObject squadJson)
 {
     ClearAll();
     SquadJsonHelper.SetPlayerSquadFromImportedJson(this, squadJson);
 }