void Initialize()
    {
        DontDestroyOnLoad(gameObject);

        Application.targetFrameRate = targetFrameRate;

        RestartSessionMetrics();

        // soomla store stuff
        StoreEvents.OnItemPurchased += onItemPurchased;
        StoreEvents.OnRestoreTransactionsFinished += onRestoreTransactionsFinished;
        if (!SoomlaStore.Initialized)
        {
            SoomlaStore.Initialize(new SoomlaStoreAssets());
        }

        gameDataBlob = new GameDataBlob();
        gameDataBlob.Init(saveDataFormatVersion);

        // create generic game service class
#if UNITY_IOS
        gameService = new AppleGameCenterAPI();
        gameService.Initialize();
#endif
#if UNITY_ANDROID
        gameService = new GooglePlayAPI();
#endif
#if UNITY_EDITOR
        gameService = new GameServiceMock();
#endif
        gameService.Initialize();

        // callback is managed in gameService API
        pendingCloudSaveOperation = 1;
    }
Exemple #2
0
    public static void CloudSaveToLocalSave(GameDataBlob blob)
    {
        if (blob == null)
        {
            Debug.LogWarning("Incoming save data is null or unreadable. Save update aborting.");
            return;
        }
        else if (blob.saveDataFormatVersion != GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>().saveDataFormatVersion)
        {
            Debug.LogWarning(
                "Incoming save data is from an old version ("
                + blob.saveDataFormatVersion
                + ","
                + GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>().saveDataFormatVersion
                + "). Save update aborting.");
            return;
        }

        // update upgraded status if it's not already
        if (blob.hasUnlockedFullGame && !GetHasUpgraded())
        {
            SetHasUpgraded(true);
        }

        // update instruction status if it's less
        for (int i = 0; i < blob.seenInstructions.Length; i++)
        {
            if (GetSeenInstruction(i) == false && blob.seenInstructions[i] == true)
            {
                SetSeenInstruction(i, true);
            }
        }

        // update appointment time
        if (blob.totalAppointmentTime > GetTotalAppointmentTime())
        {
            SetTotalAppointmentTime(blob.totalAppointmentTime);
        }

        // update star statuses
        for (int i = 0; i < blob.starCountDay.GetLength(0); i++)
        {
            for (int j = 0; j < blob.starCountDay.GetLength(1); j++)
            {
                SetRoundStarCount(i, j, blob.starCountDay[i, j]);
            }
        }
    }
Exemple #3
0
    public static void CloudSaveToLocalSave(GameDataBlob blob)
    {
        if (blob == null)
        {
            Debug.LogWarning("Incoming save data is null or unreadable. Save update aborting.");
            return;
        }
        else if(blob.saveDataFormatVersion != GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>().saveDataFormatVersion)
        {
            Debug.LogWarning(
                "Incoming save data is from an old version ("
                + blob.saveDataFormatVersion
                + ","
                + GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>().saveDataFormatVersion
                + "). Save update aborting.");
            return;
        }

        // update upgraded status if it's not already
        if (blob.hasUnlockedFullGame && !GetHasUpgraded())
        {
            SetHasUpgraded(true);
        }

        // update instruction status if it's less
        for (int i = 0; i < blob.seenInstructions.Length; i++)
        {
            if (GetSeenInstruction(i) == false && blob.seenInstructions[i] == true)
            {
                SetSeenInstruction(i, true);
            }
        }

        // update appointment time
        if (blob.totalAppointmentTime > GetTotalAppointmentTime())
        {
            SetTotalAppointmentTime(blob.totalAppointmentTime);
        }

        // update star statuses
        for (int i = 0; i < blob.starCountDay.GetLength(0); i++)
        {
            for (int j = 0; j < blob.starCountDay.GetLength(1); j++)
            {
                SetRoundStarCount(i, j, blob.starCountDay[i,j]);
            }
        }
    }
    public void callback_OnSavedGameDataRead(byte[] data)
    {
        if (data.Length == 0)
        {
            Debug.LogWarning("gameDataBlob from data is 0 length");
            return;
        }

        // read byte data
        gameDataBlob = FromByteArray(data) as GameDataBlob;

        if (gameDataBlob == null)
        {
            Debug.LogWarning("gameDataBlob from data is null");
            return;
        }

        print("gameDataBlob looks good, sending it to UpdateLocalSaveDataFromBlob()");
        UpdateLocalSaveDataFromBlob();
    }
    public void callback_OnSavedGameDataRead(byte[] data)
    {
        if (data.Length == 0)
        {
            Debug.LogWarning("gameDataBlob from data is 0 length");
            return;
        }

        // read byte data
        gameDataBlob = FromByteArray(data) as GameDataBlob;

        if (gameDataBlob == null)
        {
            Debug.LogWarning("gameDataBlob from data is null");
            return;
        }

        print("gameDataBlob looks good, sending it to UpdateLocalSaveDataFromBlob()");
        UpdateLocalSaveDataFromBlob();
    }
    void Initialize()
    {
        DontDestroyOnLoad(gameObject);

        Application.targetFrameRate = targetFrameRate;

        RestartSessionMetrics();

        // soomla store stuff
        StoreEvents.OnItemPurchased += onItemPurchased;
        StoreEvents.OnRestoreTransactionsFinished += onRestoreTransactionsFinished;
        if (!SoomlaStore.Initialized)
        {
            SoomlaStore.Initialize(new SoomlaStoreAssets());
        }

        gameDataBlob = new GameDataBlob();
        gameDataBlob.Init(saveDataFormatVersion);

        // create generic game service class
        #if UNITY_IOS
        gameService = new AppleGameCenterAPI();
        gameService.Initialize();
        #endif
        #if UNITY_ANDROID
        gameService = new GooglePlayAPI();
        #endif
        #if UNITY_EDITOR
        gameService = new GameServiceMock();
        #endif
        gameService.Initialize();

        // callback is managed in gameService API
        pendingCloudSaveOperation = 1;
    }