Esempio n. 1
0
    private void Start()
    {
        for (int i = 0; i < mapData.nRow; i++)
        {
            MapListElement el = Instantiate(mleTemplate, mapListContent);
            SetMapElement(el, i);
        }

        Destroy(mapListContent.GetChild(0).gameObject);
    }
Esempio n. 2
0
    private void SetMapElement(MapListElement el, int i)
    {
        string scene   = mapData.GetValue(i, "Scene name");
        string title   = mapData.GetValue(i, "Title");
        string author  = mapData.GetValue(i, "Main author");
        string credits = mapData.GetValue(i, "Credits");
        string info    = mapData.GetValue(i, "Additional info");
        float  rating  = 0f;

        float.TryParse(mapData.GetValue(i, "Rating"), out rating);
        float difficulty = 0f;

        float.TryParse(mapData.GetValue(i, "Difficulty"), out difficulty);
        el.SetMap(scene, title, author, credits, info, rating, difficulty);

        string previewName = mapData.GetValue(i, "Preview image");
        string previewPath = "MapPreviews/" + previewName;
        Sprite preview     = Resources.Load <Sprite>(previewPath);

        el.previewImage.sprite = preview;

        bool foundMap = Global.levelLauncher.SceneIsAvailable(scene);

        string valid = mapData.GetValue(i, "Validated").ToLower();

        el.SetStatus(foundMap, valid);

        if (preview == null)
        {
            Debug.LogWarning("Map preview could not be found: " + previewName);
        }
        if (!foundMap)
        {
            Debug.LogWarning("Scene not added to build settings: " + scene);
        }

        Global.save.SetRecordText(scene, el.recordText);
    }