Esempio n. 1
0
 // Called when a Buyable's Data is loaded
 void OnBuyableDataLoaded(BuyableData data)
 {
     if (data == Data)
     {
         ContinueProcess();
     }
 }
Esempio n. 2
0
    // Draw up the prefab for the buyable on the screen
    void DisplayBuyable(BuyableData buyableData)
    {
        Buyable prefab = Instantiate(idlePrefab, prefabContainer);

        prefabs.Add(prefab);
        prefab.Init(buyableData);
    }
Esempio n. 3
0
 // Called when a buyable's data is loaded after the game begins
 void OnBuyableDataLoaded(BuyableData b)
 {
     if (b == buyable.Data)
     {
         UpdateUI();
     }
 }
Esempio n. 4
0
    public void Init(BuyableData buyableData)
    {
        // Set up the data
        Data = buyableData;
        Data.Init();

        // Add references and events
        moneyManager              = MoneyManager.Instance;
        BuyableData.onDataLoaded += OnBuyableDataLoaded;
    }
Esempio n. 5
0
        public void Load()
        {
            // do we already have a saved object?
            BuyableDto dto = SaveManager.Get(SaveKeys.BuyableDataKey, new BuyableDto()) as BuyableDto;

            if (dto == null)
            {
                return;
            }

            // no save data yet, initialize default
            if ((dto.BuyableData == null) || (dto.BuyableData.Count == 0))
            {
                foreach (ShopCategory category in _setup.Categories)
                {
                    foreach (BaseBuyable baseBuyable in category.ItemsInCategory)
                    {
                        baseBuyable.Bought   = false;
                        baseBuyable.Selected = false;
                    }
                }

                return;
            }

            // save data found - need to loop through all categories and see if we have save data for an object and if yes load the corresponding data
            foreach (ShopCategory category in _setup.Categories)
            {
                foreach (BaseBuyable baseBuyable in category.ItemsInCategory)
                {
                    // searches for the buyable data stored in the save game that has the same name as the current buyable from the category
                    BuyableData firstOrDefault = dto.BuyableData.FirstOrDefault(b => b.Name.Equals(baseBuyable.name));
                    // buyable found, assign its values from save
                    if (firstOrDefault != null)
                    {
                        baseBuyable.Bought   = firstOrDefault.Bought;
                        baseBuyable.Selected = firstOrDefault.Selected;
                    }
                    // new buyable that is not yet saved, assign default values
                    else
                    {
                        baseBuyable.Bought   = false;
                        baseBuyable.Selected = false;
                    }
                }
            }
        }
Esempio n. 6
0
    /* Event listeners (in order of execution where applicable) */

    // Called after the data for a buyable has been loaded once the game begins
    void OnBuyableDataLoaded(BuyableData b)
    {
        if (b == buyable.Data)
        {
        }
    }