コード例 #1
0
        /// <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);
        }
コード例 #2
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 don't need to persist any data so we use the MemoryDataLayer
            //   that will store GameFoundation's data only for the play session.
            GameFoundation.Initialize(new MemoryDataLayer());

            // Grab a reference to the main, wallet, and store inventories.
            m_Main   = Inventory.main;
            m_Wallet = InventoryManager.wallet;
            m_Store  = InventoryManager.GetInventory("store");

            // Here we bind our UI refresh method to callbacks on the inventory manager.
            // These callbacks will automatically be invoked anytime an inventory is added, or removed.
            // This prevents us from having to manually invoke RefreshUI every time we perform one of these actions.
            m_Wallet.onItemAdded           += RefreshUI;
            m_Wallet.onItemRemoved         += RefreshUI;
            m_Wallet.onItemQuantityChanged += RefreshUI;

            m_ApplePrice = Random.Range(5, 26);
            RefreshUI();
        }
コード例 #3
0
ファイル: StatsSample.cs プロジェクト: RebornMaster/Magi-FPS
        /// <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 don't need to persist any data so we use the MemoryDataLayer
            //   that will store GameFoundation's data only for the play session.
            GameFoundation.Initialize(new MemoryDataLayer());

            // Create a backpack inventory instance and keep the reference. Grab its sword reference as well.
            m_Backpack     = InventoryManager.CreateInventory("backpack", "MainBackpack", "Backpack");
            m_Sword        = m_Backpack.GetItem("sword");
            m_HealthPotion = m_Backpack.GetItem("healthPotion");

            // Setup our player stats instance.
            m_PlayerStats = new GameItem(CatalogManager.gameItemCatalog.GetGameItemDefinition("player"));

            // Here we bind our UI refresh method to callbacks on the inventory manager.
            // These callbacks will automatically be invoked anytime an inventory is added, or removed.
            // This prevents us from having to manually invoke RefreshUI every time we perform one of these actions.
            m_Backpack.onItemAdded           += RefreshUI;
            m_Backpack.onItemRemoved         += RefreshUI;
            m_Backpack.onItemQuantityChanged += RefreshUI;

            RefreshUI();
        }
コード例 #4
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.Initialize(new MemoryDataLayer());

            // Grab a reference to the shopping cart inventory.
            m_ShoppingCart = InventoryManager.GetInventory("shoppingCart");

            // Grab a reference to the smoothie purchasable detail.
            m_SmoothieTransaction = CatalogManager.inventoryCatalog.GetItemDefinition("smoothie").GetDetailDefinition <PurchasableDetailDefinition>();

            // Here we bind our UI refresh method to callbacks on the inventory manager.
            // These callbacks will automatically be invoked anytime an inventory is added, or removed.
            // This prevents us from having to manually invoke RefreshUI every time we perform one of these actions.
            // For this sample, we'll only refresh the UI when a smoothie gets added to the shopping cart.
            m_ShoppingCart.onItemAdded           += RefreshUI;
            m_ShoppingCart.onItemQuantityChanged += RefreshUI;

            RefreshUI();
        }
コード例 #5
0
        /// <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, Stats, ...).
            // - 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.
            GameFoundation.Initialize(new MemoryDataLayer());

            // Here we bind a listener that will set an inventoryChanged flag to callbacks on the Inventory Manager.
            // These callbacks will automatically be invoked anytime an item is added or removed.
            // This prevents us from having to manually invoke RefreshUI every time we perform one of these actions.
            InventoryManager.itemAdded   += OnInventoryItemChanged;
            InventoryManager.itemRemoved += OnInventoryItemChanged;

            // We'll call this to get our initial list of items to know the correct quantities for each aggregated item
            RefreshUniqueItems();
        }
コード例 #6
0
        /// <summary>
        /// Standard starting point for Unity scripts.
        /// </summary>
        void Awake()
        {
            // The database has been properly setup.
            m_WrongDatabase = !SamplesHelper.VerifyDatabase();
            if (m_WrongDatabase)
            {
                wrongDatabasePanel.SetActive(true);
                tutorialPanel.SetActive(false);
                return;
            }

            tutorialPanel.SetActive(true);

            // - 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.
            GameFoundation.Initialize(new MemoryDataLayer());

            m_NextButton         = GameObject.Find("Next Step").GetComponent <Button>();
            m_PreviousButton     = GameObject.Find("Previous Step").GetComponent <Button>();
            m_CurrentStepDisplay = GameObject.Find("Step Instructions").GetComponent <Text>();
            m_CurrentStepTitle   = GameObject.Find("Step Title").GetComponent <Text>();

            m_CurrentStepTitle.text   = m_TutorialTitles[m_CurrentStep];
            m_CurrentStepDisplay.text = m_TutorialSteps[m_CurrentStep];
            m_PreviousButton.enabled  = false;
        }
コード例 #7
0
ファイル: StatsSample.cs プロジェクト: gkmk/Dungeons2D
        /// <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, Stats, ...).
            // - 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.
            GameFoundation.Initialize(new MemoryDataLayer());

            // We will create the sword and health potion inventoryItems in the InventoryManager and
            // store their references to get us started.
            m_Sword        = InventoryManager.CreateItem("sword");
            m_HealthPotion = InventoryManager.CreateItem("healthPotion");

            // Here we bind our UI refresh method to callbacks on the inventory manager.
            // These callbacks will automatically be invoked anytime an inventory is added, or removed.
            // This prevents us from having to manually invoke RefreshUI every time we perform one of these actions.
            InventoryManager.itemAdded   += OnInventoryItemChanged;
            InventoryManager.itemRemoved += OnInventoryItemChanged;

            RefreshUI();
        }
コード例 #8
0
        /// <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 don't need to persist any data so we use the MemoryDataLayer
            //   that will store GameFoundation's data only for the play session.
            GameFoundation.Initialize(new MemoryDataLayer());

            m_CoinDefinition = GameFoundation.catalogs.currencyCatalog.FindItem("coin");

            // 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.SetBalance(m_CoinDefinition, 50);

            RefreshUI();
        }
コード例 #9
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 don't need to persist any data so we use the MemoryDataLayer
            //   that will store GameFoundation's data only for the play session.
            GameFoundation.Initialize(new MemoryDataLayer());

            // Here we bind our UI refresh method to callbacks on the inventory manager.
            // These callbacks will automatically be invoked anytime an inventory is added, or removed.
            // This prevents us from having to manually invoke RefreshUI every time we perform one of these actions.
            // If you want to have saving be done automatically, binding a Save method to these callbacks is a great way to accomplish this.
            InventoryManager.onInventoryAdded   += RefreshUI;
            InventoryManager.onInventoryRemoved += RefreshUI;

            RefreshUI();
        }
コード例 #10
0
        /// <summary>
        /// Standard starting point for Unity scripts.
        /// </summary>
        private IEnumerator Start()
        {
            // The database is NOT correct, show message and abort.
            if (!SamplesHelper.VerifyDatabase())
            {
                wrongDatabasePanel.SetActive(true);
                yield break;
            }

            // Initialize Game Foundation.
            yield return(InitializeGameFoundation());
        }
        /// <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;
            }

            InitializeGameFoundation();
        }
コード例 #12
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());
        }
コード例 #13
0
        /// <summary>
        /// Standard starting point for Unity scripts.
        /// </summary>
        void Awake()
        {
            // 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 don't need to persist any data so we use the MemoryDataLayer
            //   that will store GameFoundation's data only for the play session.
            GameFoundation.Initialize(new MemoryDataLayer());
        }
コード例 #14
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);
        }
コード例 #15
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.Initialize(new MemoryDataLayer());

            // Grab references to the transactions.
            m_AppleIngredientTransaction    = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("appleIngredient");
            m_OrangeIngredientTransaction   = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("orangeIngredient");
            m_BananaIngredientTransaction   = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("bananaIngredient");
            m_BroccoliIngredientTransaction = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("broccoliIngredient");
            m_CarrotIngredientTransaction   = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("carrotIngredient");
            m_FruitSmoothieTransaction      = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("fruitSmoothie");
            m_VeggieSmoothieTransaction     = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("veggieSmoothie");

            // Here we bind listeners that will set an inventoryChanged flag to callbacks on the Inventory Manager.
            // These callbacks will automatically be invoked anytime an inventory item is added or removed.
            // This prevents us from having to manually invoke RefreshUI every time we perform one of these actions.
            InventoryManager.itemAdded   += OnInventoryItemChanged;
            InventoryManager.itemRemoved += OnInventoryItemChanged;

            // Here we bind listeners to callbacks on the Transaction Manager.
            // These callbacks will automatically be invoked during the processing of a transaction.
            TransactionManager.transactionInitiated  += OnTransactionInitiated;
            TransactionManager.transactionProgressed += OnTransactionProgress;
            TransactionManager.transactionSucceeded  += OnTransactionSucceeded;
            TransactionManager.transactionFailed     += OnTransactionFailed;

            // We'll initialize our WalletManager with some coin for smoothie ingredient purchases.
            WalletManager.AddBalance("coin", 100);

            RefreshUI();
        }
コード例 #16
0
        /// <summary>
        /// Standard starting point for Unity scripts.
        /// </summary>
        private IEnumerator Start()
        {
            // The database is NOT correct, show message and abort.
            if (!SamplesHelper.VerifyDatabase())
            {
                wrongDatabasePanel.SetActive(true);
                yield break;
            }

            // Put all buttons into array for easy access to enable/disable as a group
            m_AllButtons = new Button[] {
                addAppleButton,
                addOrangeButton,
                removeAppleButton,
                removeOrangeButton,
                removeAllApplesButton,
                removeAllOrangesButton
            };

            // Initialize Game Foundation.
            yield return(InitializeGameFoundation());
        }
コード例 #17
0
        /// <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 don't need to persist any data so we use the MemoryDataLayer
            //   that will store GameFoundation's data only for the play session.
            GameFoundation.Initialize(new MemoryDataLayer());

            // For this sample, we're focusing on swords and health, so let's remove all others from the Inventory.
            // Note: this is helpful since we have an initial allocation of 2 apples and 1 orange.
            InventoryManager.RemoveAllItems();

            // We will create the sword and health potion inventoryItems in the InventoryManager and
            // store their references to get us started.
            m_Sword        = InventoryManager.CreateItem("sword");
            m_HealthPotion = InventoryManager.CreateItem("healthPotion");

            // Here we bind our UI refresh method to callbacks on the inventory manager.
            // These callbacks will automatically be invoked anytime an inventory item is added, or removed.
            // This allows us to refresh the UI as soon as the changes are applied.
            InventoryManager.itemAdded   += OnInventoryItemChanged;
            InventoryManager.itemRemoved += OnInventoryItemChanged;

            // These events will automatically be invoked when sword's or potion's properties are changed.
            m_Sword.propertyChanged        += OnItemPropertyChanged;
            m_HealthPotion.propertyChanged += OnItemPropertyChanged;

            RefreshUI();
        }
コード例 #18
0
ファイル: CategoriesSample.cs プロジェクト: gkmk/Dungeons2D
        /// <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, Stats, ...).
            // - 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.
            GameFoundation.Initialize(new MemoryDataLayer());

            // The Inventory Manager starts empty, so we will add a selection of items to the inventory.
            InitializeInventoryItems();

            NoCategoryFilter();
            RefreshUI();
        }
コード例 #19
0
ファイル: StoreSample.cs プロジェクト: gkmk/Dungeons2D
        /// <summary>
        /// Standard starting point for Unity scripts.
        /// </summary>
        void Awake()
        {
            // 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 don't need to persist any data so we use the MemoryDataLayer
            //   that will store GameFoundation's data only for the play session.
            GameFoundation.Initialize(new MemoryDataLayer(), () =>
            {
                // After GameFoundation's Initializing completed,
                // sets coins and gems to make sure that there is enough currency for this sample.
                WalletManager.SetBalance("coin", 500);
                WalletManager.SetBalance("gem", 50);
            });
        }
コード例 #20
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 don't need to persist any data so we use the MemoryDataLayer
            //   that will store GameFoundation's data only for the play session.
            GameFoundation.Initialize(new MemoryDataLayer());

            // Grab a reference to the shopping cart
            m_ShoppingCart = InventoryManager.GetInventory("shoppingCart");

            FruitCategory();
            RefreshUI();
        }