Ejemplo n.º 1
0
        private void Start()
        {
            // - Initialize must always be called before working with any game foundation code.
            // - GameFoundation requires an IDataAccessLayer object that will provide and persist
            //   the data required for the various services (Inventory, Wallet, ...).
            // - For this sample we don't need to persist any data so we use the MemoryDataLayer
            //   that will store GameFoundation's data only for the play session.
            m_DataLayer = new PersistenceDataLayer(
                new LocalPersistence("DataPersistence", new JsonDataSerializer()));
            if (!GameFoundation.IsInitialized)
            {
                GameFoundation.Initialize(m_DataLayer, OnGameFoundationInitialized, OnInitFailed);
            }

            m_softCurrencyDefinition = GameFoundation.catalogs.currencyCatalog.FindItem("coin");
            m_hardCurrencyDefinition = GameFoundation.catalogs.currencyCatalog.FindItem("gem");

            // Here we bind a listener that will set a walletChanged flag to callbacks on the Wallet Manager.
            // These callbacks will automatically be invoked anytime a currency balance is changed.
            // This prevents us from having to manually invoke RefreshUI every time we perform one of these actions.
            WalletManager.balanceChanged += OnCoinBalanceChanged;

            // We'll initialize our WalletManager's coin balance with 50 coins.
            // This will set the balance to 50 no matter what it's current balance is.
            WalletManager.GetBalance(m_softCurrencyDefinition);
            WalletManager.GetBalance(m_hardCurrencyDefinition);

            RefreshAllCurrencies();
        }
Ejemplo n.º 2
0
        private IEnumerator Start()
        {
            PersistenceDataLayer dataLayer = new PersistenceDataLayer(
                new LocalPersistence(
                    localPersistenceFilename,
                    new JsonDataSerializer()
                    ),
                currentCatalog
                );

            // Asynchronous
            using (Deferred initialization = GameFoundationSdk.Initialize(dataLayer))
            {
                if (!initialization.isDone)
                {
                    yield return(initialization.Wait());
                }

                if (!initialization.isFulfilled)
                {
                    Debug.LogError(initialization.error);

                    yield break;
                }
            }
        }
        /// <summary>
        /// Standard starting point for Unity scripts.
        /// </summary>
        private void Start()
        {
            // The database has been properly setup.
            m_WrongDatabase = !SamplesHelper.VerifyDatabase();
            if (m_WrongDatabase)
            {
                wrongDatabasePanel.SetActive(true);
                return;
            }

            // - Initialize must always be called before working with any game foundation code.
            // - GameFoundation requires an IDataAccessLayer object that will provide and persist
            //   the data required for the various services (Inventory, Wallet, ...).
            // - For this sample we will persist GameFoundation's data using a PersistenceDataLayer.
            //   We create it with a LocalPersistence setup to save/load these data in a JSON file
            //   named "DataPersistenceSampleV2" stored on the device.  Note: 'V2' appended
            //   to the filename to ensure old persistence from previous version of Game Foundation
            //   isn't used, causing Sample to throw at initialization.  This is only needed during
            //   the 'preview' phase of Game Foundation while the structure of persistent data is
            //   changing.
            m_DataLayer = new PersistenceDataLayer(
                new LocalPersistence("DataPersistenceSampleV2", new JsonDataSerializer()));

            GameFoundation.Initialize(m_DataLayer, OnGameFoundationInitialized, Debug.LogError);
        }
Ejemplo n.º 4
0
    private IEnumerator Start()
    {
        _persistenceDataLayer = new PersistenceDataLayer(
            new LocalPersistence("DataPersistencePaperPlane", new JsonDataSerializer()));

        // Initialize Game Foundation.
        yield return(InitializeGameFoundation());
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Standard starting point for Unity scripts.
        /// </summary>
        private IEnumerator Start()
        {
            _persistenceDataLayer = new PersistenceDataLayer(
                new LocalPersistence("DataPersistence", new JsonDataSerializer()));
            // The database is NOT correct, show message and abort.
            if (!SamplesHelper.VerifyDatabase())
            {
                wrongDatabasePanel.SetActive(true);
                yield break;
            }

            // Initialize Game Foundation.
            yield return(InitializeGameFoundation());
        }
        /// <summary>
        /// Initialize Game Foundation.
        /// Called at startup as well as when reinitializing.
        /// </summary>
        private void InitializeGameFoundation()
        {
            // Disable all buttons for initialization.
            addAppleButton.interactable              = false;
            addOrangeButton.interactable             = false;
            removeAppleButton.interactable           = false;
            removeOrangeButton.interactable          = false;
            removeAllButton.interactable             = false;
            deleteAndReinitializeButton.interactable = false;

            // - Initialize must always be called before working with any game foundation code.
            // - GameFoundation requires an IDataAccessLayer object that will provide and persist
            //   the data required for the various services (Inventory, Wallet, ...).
            m_LocalPersistence = new LocalPersistence("GF_Sample10_DataPersistence", new JsonDataSerializer());
            m_DataLayer        = new PersistenceDataLayer(m_LocalPersistence);

            // Initialize Game Foundation, calls OnGameFoundationInitialized callback when complete.
            GameFoundation.Initialize(m_DataLayer, OnGameFoundationInitialized, Debug.LogError);
        }
        public void Initialize()
        {
            var serializer  = new JsonDataSerializer();
            var persistence = new PlayFabPersistence(_key, serializer);

            _dataLayer = new PersistenceDataLayer(persistence);

            Deferred def = GameFoundationSdk.Initialize(_dataLayer);

            if (def.isDone)
            {
                if (def.isFulfilled)
                {
                    _onInitOrLoadComplete?.Invoke();
                    OnInitOrLoadComplete?.Invoke();
                }
                else
                {
                    Debug.LogError(def.error.Message);
                    _onInitOrLoadFail?.Invoke();
                }
            }
            else
            {
                IEnumerator Routine(Deferred aDef)
                {
                    yield return(aDef.Wait());

                    if (aDef.isFulfilled)
                    {
                        _onInitOrLoadComplete?.Invoke();
                        OnInitOrLoadComplete?.Invoke();
                    }
                    else
                    {
                        Debug.LogError(aDef.error.Message);
                        _onInitOrLoadFail?.Invoke();
                    }
                }

                StartCoroutine(Routine(def));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Standard starting point for Unity scripts.
        /// </summary>
        void Start()
        {
            // The database has been properly setup.
            m_WrongDatabase = !SamplesHelper.VerifyDatabase();
            if (m_WrongDatabase)
            {
                wrongDatabasePanel.SetActive(true);
                return;
            }

            // - Initialize must always be called before working with any game foundation code.
            // - GameFoundation requires an IDataAccessLayer object that will provide and persist
            //   the data required for the various services (Inventory, Stats, ...).
            // - For this sample we will persist GameFoundation's data using a PersistenceDataLayer.
            //   We create it with a LocalPersistence setup to save/load these data in a JSON file
            //   named "DataPersistenceSample" stored on the device.
            m_DataLayer = new PersistenceDataLayer(
                new LocalPersistence("DataPersistenceSample", new JsonDataSerializer()));

            GameFoundation.Initialize(m_DataLayer, OnGameFoundationInitialized, Debug.LogError);
        }
Ejemplo n.º 9
0
 void InitGameFoundation()
 {
     mDataLayer = new PersistenceDataLayer(new LocalPersistence(PERSISTENCE_SAVE_NAME, new JsonDataSerializer()));
     GameFoundation.Initialize(mDataLayer, OnGameFoundationInit, Debug.LogError);
 }