コード例 #1
0
    public void LoadLevel(int level)
    {
        if (GameJoltAPI.Instance != null)
        {
            RemoteSettingsHolder rsh = GameJoltAPI.Instance.GetComponent <RemoteSettingsHolder>();
            if (rsh != null)
            {
                playlist.LoadPlaylist(rsh.Playlist);
            }
        }

        if (level <= currentLevel.RuntimeValue)
        {
            SceneManager.LoadScene(playlist.NextLevel(level));
        }
        if (level < 1)
        {
            SceneManager.LoadScene(1);
        }
    }
コード例 #2
0
    // level complete
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            ColorLayer color = GetComponent <ColorLayer>();

            if (skip_goal)
            {
                AnalyticsEvent.Custom("level_skipped", new Dictionary <string, object>
                {
                    { "build_index", currentLevel.RuntimeValue },
                    { "scene_name", currentScene.name },
                    { "deaths", deaths },
                    { "pallet", color.pallet.name },
                    { "time_to_clear", Time.timeSinceLevelLoad }
                });
            }
            else
            {
                AnalyticsEvent.Custom("goal_reached", new Dictionary <string, object>
                {
                    { "build_index", currentLevel.RuntimeValue },
                    { "scene_name", currentScene.name },
                    { "deaths", deaths },
                    { "pallet", color.pallet.name },
                    { "time_to_clear", Time.timeSinceLevelLoad }
                });
            }
            level.average_cleartime = (level.average_cleartime + Time.timeSinceLevelLoad) / 2;
            level.average_deaths    = (level.average_deaths + deaths) / 2;

            if (currentScene.buildIndex + 1 < SceneManager.sceneCountInBuildSettings)
            {
                SceneManager.LoadScene(playlist.NextLevel(currentLevel.RuntimeValue + 1));
            }
            else
            {
                SceneManager.LoadScene(0);
            }
        }
    }