Example #1
0
    //GUI STUFF:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    void SetSaveButtonListener()
    {
        saveButton.GetComponent <Button>().onClick.AddListener(delegate {
            int levelID             = 0;
            int categoryID          = 0;
            bool isLevelReadable    = int.TryParse(levelIDInput.GetComponent <Text>().text, out levelID);
            bool isCategoryReadable = int.TryParse(worldIDInput.GetComponent <Text>().text, out categoryID);
            if (!isLevelReadable || !isCategoryReadable)
            {
                onSaveErrorText.GetComponent <Text>().text = "ERROR ON CATEGORY/LEVEL INPUT";
                return;
            }
            //Check if level or world already exists and give proper message
            if (LevelDesignInfo.DoesLevelDesignExists(categoryID, levelID))
            {
                onSaveErrorText.GetComponent <Text>().text = "ALREADY EXISTS";
                return;
            }
            else if (start_line == null || end_line == null)
            {
                onSaveErrorText.GetComponent <Text>().text = "START OR END LINE MISSING";
                return;
            }
            else
            {
                onSaveErrorText.GetComponent <Text>().text = "SUSCESSFULLY CHECKED";
            }
            //set-up all info that will be written in JSON file and save it
            List <PlatformMovableInfo> movableInfo         = GetMovablePlatInfoFromInput();
            List <PlatformEnvironmentInfo> environmentInfo = GetEnvironmentPlatInfo();

            double startX = start_line.transform.position.x;
            double startY = start_line.transform.position.y;
            double endX   = end_line.transform.position.x;
            double endY   = end_line.transform.position.y;

            //apply info to object that is used for JSON and save it
            LevelDesignInfo levelDesign = new LevelDesignInfo(categoryID, levelID, 777, startX, startY, endX, endY, environmentInfo, movableInfo);
            LevelDesignInfo.SaveLevelDesign(levelDesign);
        });
    }
Example #2
0
    public static void SetTimeChangesOnLevelComplete(int _completedCat, int __completedLvl, float _time)
    {
        //set medal for this level
        LevelDesignInfo thisInfo = LevelDesignInfo.LoadLevelDesign(_completedCat, __completedLvl);

        if (_time < thisInfo.time && _time >= 0 && _time <= 15)
        {
            thisInfo.time = _time;
        }

        //unlock next level if it's not already unlocked
        int nextLevel = __completedLvl;
        int nextWorld = _completedCat;

        if (__completedLvl != 16)
        {
            nextLevel++;
        }
        else if (__completedLvl == 16 && _completedCat != GlobalSettings.WORLD_COUNT)
        {
            nextLevel = 1;
            nextWorld++;
        }

        if (nextWorld != GlobalSettings.WORLD_COUNT && nextLevel != GlobalSettings.LEVEL_COUNT)
        {
            LevelDesignInfo nextInfo = LevelDesignInfo.LoadLevelDesign(nextWorld, nextLevel);
            if (nextInfo.time == 777.0f)
            {
                nextInfo.time = 888.0f;
            }

            LevelDesignInfo.Save2LevelDesigns(thisInfo, nextInfo);
        }
        else
        {
            LevelDesignInfo.SaveLevelDesign(thisInfo);
        }
    }