Ejemplo n.º 1
0
    void Awake()
    {
        // Create the WebGL (or mock) object
#if UNITY_EDITOR
        ILOLSDK webGL = new LoLSDK.MockWebGL();
#elif UNITY_WEBGL
        ILOLSDK webGL = new LoLSDK.WebGL();
#endif

        // Initialize the object, passing in the WebGL
        LOLSDK.Init(webGL, "com.legends-of-learning.unity.sdk.v5.1.example-game");

        // Register event handlers
        LOLSDK.Instance.StartGameReceived += new StartGameReceivedHandler(this.HandleStartGame);
        LOLSDK.Instance.GameStateChanged  += new GameStateChangedHandler(this.HandleGameStateChange);
        //LOLSDK.Instance.QuestionsReceived += new QuestionListReceivedHandler (this.HandleQuestions);
        LOLSDK.Instance.LanguageDefsReceived += new LanguageDefsReceivedHandler(this.HandleLanguageDefs);

        // Mock the platform-to-game messages when in the Unity editor.
#if UNITY_EDITOR
        LoadMockData();
#endif

        // Then, tell the platform the game is ready.
        LOLSDK.Instance.GameIsReady();
    }
Ejemplo n.º 2
0
    public static void StartLoader()
    {
        // Create the WebGL (or mock) object
#if UNITY_EDITOR
        ILOLSDK webGL = new LoLSDK.MockWebGL();
#elif UNITY_WEBGL
        ILOLSDK webGL = new LoLSDK.WebGL();
#endif
        // Initialize the object, passing in the WebGL
        LOLSDK.Init(webGL, "com.Pansimula.Malfunction");
        // Register event handlers
        LOLSDK.Instance.StartGameReceived    += new StartGameReceivedHandler(HandleStartGame);
        LOLSDK.Instance.LanguageDefsReceived += new LanguageDefsReceivedHandler(HandleLanguageDefs);
        // Mock the platform-to-game messages when in the Unity editor.
#if UNITY_EDITOR
        LoadMockData();
                #endif

        // Then, tell the platform the game is ready.
        LOLSDK.Instance.GameIsReady();
    }
Ejemplo n.º 3
0
        void Start()
        {
            purchasePanButton.onClick.AddListener(AddPan);
            pantryButton.onClick.AddListener(AddFoodToPantry);

            // Create the WebGL (or mock) object
            // This will all change in SDK V6 to be simplified and streamlined.
#if UNITY_EDITOR
            ILOLSDK sdk = new LoLSDK.MockWebGL();
#elif UNITY_WEBGL
            ILOLSDK sdk = new LoLSDK.WebGL();
#elif UNITY_IOS || UNITY_ANDROID
            ILOLSDK sdk = null; // TODO COMING SOON IN V6
#endif

            LOLSDK.Init(sdk, "com.legends-of-learning.unity.sdk.v5.1.example-cooking-game");

            // Register event handlers
            LOLSDK.Instance.StartGameReceived    += new StartGameReceivedHandler(StartGame);
            LOLSDK.Instance.GameStateChanged     += new GameStateChangedHandler(gameState => Debug.Log(gameState));
            LOLSDK.Instance.QuestionsReceived    += new QuestionListReceivedHandler(questionList => Debug.Log(questionList));
            LOLSDK.Instance.LanguageDefsReceived += new LanguageDefsReceivedHandler(LanguageUpdate);

            // Used for player feedback. Not required by SDK.
            LOLSDK.Instance.SaveResultReceived += OnSaveResult;

            // Call GameIsReady before calling LoadState or using the helper method.
            LOLSDK.Instance.GameIsReady();

#if UNITY_EDITOR
            UnityEditor.EditorGUIUtility.PingObject(this);
            LoadMockData();
#endif

            // Helper method to hide and show the state buttons as needed.
            // Will call LoadState<T> for you.
            Helper.StateButtonInitialize <CookingData>(newGameButton, continueButton, OnLoad);
        }
Ejemplo n.º 4
0
        protected virtual IEnumerator Start()
        {
            mLangCode = "en";
            mIsReady  = false;

            mIsGameStartHandled = false;
            mIsLanguageHandled  = false;

            mIsFocus = Application.isFocused;

            //force run in background as requirement
            Application.runInBackground = false;

            // Create the WebGL (or mock) object
#if UNITY_EDITOR
            ILOLSDK webGL = new LoLSDK.MockWebGL();
#elif UNITY_WEBGL
            ILOLSDK webGL = new LoLSDK.WebGL();
#else
            ILOLSDK webGL = new LoLSDK.MockWebGL();
#endif

            // Initialize the object, passing in the WebGL
            LOLSDK.Init(webGL, _gameID);

            // Register event handlers
#if !UNITY_EDITOR
            LOLSDK.Instance.StartGameReceived    += new StartGameReceivedHandler(this.HandleStartGame);
            LOLSDK.Instance.QuestionsReceived    += new QuestionListReceivedHandler(this.HandleQuestions);
            LOLSDK.Instance.LanguageDefsReceived += new LanguageDefsReceivedHandler(this.HandleLanguageDefs);
#endif

            mCurProgress = 0;

            // Mock the platform-to-game messages when in the Unity editor.
#if UNITY_EDITOR
            LoadMockData();
#endif

            // Then, tell the platform the game is ready.
            LOLSDK.Instance.GameIsReady();

            //wait for start and language to be handled
            while (!(mIsGameStartHandled && mIsLanguageHandled))
            {
                yield return(null);
            }

            //parse start
            if (!string.IsNullOrEmpty(mGameStartJson))
            {
                ParseGameStart(mGameStartJson);
                mGameStartJson = null;
            }

            //parse language
            if (!string.IsNullOrEmpty(mLanguageJson))
            {
                ParseLanguage(mLanguageJson);
                mLanguageJson = null;
            }

            const float timeOutDelay = 20.0f;

            float lastTime = Time.time;

            //load user data
            if (_userData)
            {
                _userData.Load();
                while (!_userData.isLoaded)
                {
                    //time-out?
                    if (Time.time - lastTime >= timeOutDelay)
                    {
                        Debug.LogWarning("User Data loading timed-out.");
                        break;
                    }

                    yield return(null);
                }

                mCurScore    = _userData.score;
                mCurProgress = _userData.currentProgress;
            }

            lastTime = Time.time;

            //load settings data
            if (_settingsData && _settingsData != _userData)
            {
                _settingsData.Load();
                while (!_settingsData.isLoaded)
                {
                    //time-out?
                    if (Time.time - lastTime >= timeOutDelay)
                    {
                        Debug.LogWarning("Settings Data loading timed-out.");
                        break;
                    }

                    yield return(null);
                }
            }

            yield return(null);

            //initialize audio
            if (M8.MusicPlaylist.instance)
            {
                M8.MusicPlaylist.instance.SetupSourceProxy(musicPlaylistRootGO);
            }

            if (M8.SoundPlaylist.instance)
            {
                M8.SoundPlaylist.instance.SetupSourceRoot(soundPlaylistRootGO);
            }

            ApplySettings();

            mIsReady = true;
        }
Ejemplo n.º 5
0
    protected virtual IEnumerator Start()
    {
        mLangCode = "en";
        mIsReady  = false;

        mIsGameStartHandled = false;
        mIsLanguageHandled  = false;

        mIsFocus = Application.isFocused;

        //force run in background as requirement
        Application.runInBackground = false;

        // Create the WebGL (or mock) object
#if UNITY_EDITOR || UNITY_ANDROID
        ILOLSDK webGL = new LoLSDK.MockWebGL();
#elif UNITY_WEBGL
        ILOLSDK webGL = new LoLSDK.WebGL();
#endif

        // Initialize the object, passing in the WebGL
        LOLSDK.Init(webGL, _gameID);

        // Register event handlers
#if !UNITY_EDITOR
        LOLSDK.Instance.StartGameReceived += new StartGameReceivedHandler(this.HandleStartGame);
        //LOLSDK.Instance.GameStateChanged += new GameStateChangedHandler(this.HandleGameStateChange); //disabled until further notice
        LOLSDK.Instance.QuestionsReceived    += new QuestionListReceivedHandler(this.HandleQuestions);
        LOLSDK.Instance.LanguageDefsReceived += new LanguageDefsReceivedHandler(this.HandleLanguageDefs);
#endif

        mCurProgress = 0;

        // Mock the platform-to-game messages when in the Unity editor.
#if UNITY_EDITOR
        LoadMockData();
#endif

        // Then, tell the platform the game is ready.
        LOLSDK.Instance.GameIsReady();

        //wait for start and language to be handled
        while (!(mIsGameStartHandled && mIsLanguageHandled))
        {
            yield return(null);
        }

        //parse start
        if (!string.IsNullOrEmpty(mGameStartJson))
        {
            ParseGameStart(mGameStartJson);
            mGameStartJson = null;
        }

        //parse language
        if (!string.IsNullOrEmpty(mLanguageJson))
        {
            ParseLanguage(mLanguageJson);
            mLanguageJson = null;
        }

        yield return(new WaitForSeconds(0.5f));

        SetupVolumes();

        yield return(new WaitForSeconds(0.5f));

        mIsReady = true;
    }