コード例 #1
0
    public void LoadTable()
    {
        for (int i = 0; i < periods.Length; i++)
        {
            periods[i] = transform.GetChild(i).GetComponent <Period>();
        }
        TextAsset          asset    = Resources.Load <TextAsset>("JSON/data");
        List <ElementData> elements = ElementsData.FromJSON(asset.text).elements;

        foreach (Period item in periods)
        {
            item.PopulateList(elements);
        }
    }
コード例 #2
0
        public static void LoadElements(MainForm f)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                Mobs.Clear();
                Npcs.Clear();
                Mines.Clear();
                ElementsData el = new ElementsData(ofd.FileName, f);
                el.Read();
                // Mobs
                eList list = el.Elements.lists.Where(x => x.name.Contains("MONSTER_ESSENCE")).ToList().First();
                foreach (eItem item in list.items)
                {
                    Mobs.Add(item.ID, item.name);
                    int.TryParse(item.values[list.fields.IndexOf("common_strategy")].ToString(), out int ai);
                    string name = string.Format("{0}({1})", string.IsNullOrEmpty(item.name) ? "NoName" : item.name, item.ID);
                    if (Ai.ContainsKey(ai))
                    {
                        Ai[ai].Add(name);
                    }
                    else
                    {
                        Ai.Add(ai, new List <string>(new string[] { name }));
                    }
                }
                // Npc
                list = el.Elements.lists.Where(x => x.name.Contains("NPC_ESSENCE")).ToList().First();
                foreach (eItem item in list.items)
                {
                    Npcs.Add(item.ID, item.name);
                }
                // Mine
                list = el.Elements.lists.Where(x => x.name.Contains("MINE_ESSENCE")).ToList().First();
                foreach (eItem item in list.items)
                {
                    Mines.Add(item.ID, item.name);
                }
            }
        }
コード例 #3
0
    private static AssetModel GetExpectedDynamicAssetModel(string assetId = "01647205-c8c4-4b41-b524-1a98a7b12750")
    {
        var stronglyTyped = GetExpectedStronglyTypedAssetModel(assetId);

        return(new AssetModel
        {
            Id = stronglyTyped.Id,
            ExternalId = stronglyTyped.ExternalId,
            FileName = stronglyTyped.FileName,
            Title = stronglyTyped.Title,
            Size = stronglyTyped.Size,
            Type = stronglyTyped.Type,
            Url = stronglyTyped.Url,
            ImageWidth = stronglyTyped.ImageWidth,
            ImageHeight = stronglyTyped.ImageHeight,
            FileReference = stronglyTyped.FileReference,
            LastModified = stronglyTyped.LastModified,
            Descriptions = stronglyTyped.Descriptions,
            Elements = ElementsData.GetExpectedDynamicElements(),
        });
    }
コード例 #4
0
    void OnEnable()
    {
        if (Collection.transform.childCount > 0)
        {
            return;
        }

        Debug.Log("Creating arrangement");

        Dictionary <string, Material> typeMaterials = new Dictionary <string, Material>()
        {
            { "alkali metal", MatAlkaliMetal },
            { "alkaline earth metal", MatAlkalineEarthMetal },
            { "transition metal", MatTransitionMetal },
            { "metalloid", MatMetalloid },
            { "diatomic nonmetal", MatDiatomicNonmetal },
            { "polyatomic nonmetal", MatPolyatomicNonmetal },
            { "post-transition metal", MatPostTransitionMetal },
            { "noble gas", MatNobleGas },
            { "actinide", MatActinide },
            { "lanthanide", MatLanthanide },
        };

        // Parse the elements out of the json file
        TextAsset          asset    = Resources.Load <TextAsset>("JSON/PeriodicTableJSON");
        List <ElementData> elements = ElementsData.FromJSON(asset.text).elements;

        // Insantiate the element prefabs in their correct locations and with correct text
        foreach (ElementData element in elements)
        {
            GameObject newElement = Instantiate <GameObject>(ElementPrefab, Parent);
            newElement.GetComponentInChildren <Element>().SetFromElementData(element, typeMaterials);
            newElement.transform.localPosition = new Vector3(element.xpos * ElementSeperationDistance - ElementSeperationDistance * 18 / 2, ElementSeperationDistance * 9 - element.ypos * ElementSeperationDistance, Collection.Radius);
            newElement.transform.localRotation = Quaternion.identity;
        }

        // Store this configuration in the dynamic collection so we can retrieve it later
        Collection.GetComponent <ObjectCollectionDynamic>().StoreArrangement();
    }