Example #1
0
    public void SavePlayerData()
    {
        PlayerStats ps = GameManager.Instance.PlayerStats;

        foreach (KeyValuePair <ConsumableType, int> pair in ps.consumables)
        {
            ConsumablesContainer c = consumableList.Find(x => x.consumable == pair.Key);
            if (c != null)
            {
                c.value = pair.Value;
            }
            else
            {
                consumableList.Add(new ConsumablesContainer(pair.Key, pair.Value));
            }
        }

        expStock           = ps.ExpStock;
        itemFragments      = ps.ItemFragments;
        archetypeFragments = ps.ArchetypeFragments;

        stageClearInfo         = ps.stageClearInfo;
        worldUnlockInfo        = ps.worldUnlockInfo;
        lastPlayedWorld        = ps.lastPlayedWorld;
        hasSeenStartingMessage = ps.hasSeenStartingMessage;
        showDamageNumbers      = ps.showDamageNumbers;


        Array.Clear(heroTeamList, 0, PlayerStats.HERO_TEAM_MAX_NUM);
        for (int i = 0; i < PlayerStats.HERO_TEAM_MAX_NUM; i++)
        {
            heroTeamList[i] = new Guid[PlayerStats.HERO_TEAM_MAX_NUM];
            for (int j = 0; j < PlayerStats.HERO_TEAM_MAX_HEROES; j++)
            {
                if (ps.heroTeams[i][j] != null)
                {
                    heroTeamList[i][j] = ps.heroTeams[i][j].Id;
                }
                else
                {
                    heroTeamList[i][j] = Guid.Empty;
                }
            }
        }
    }
Example #2
0
    private void AmountChanged(ConsumablesContainer container, int change, int costChange)
    {
        if (_ignoreAmountChange)
        {
            return;
        }
        int tempMoney = _currentMoney + costChange;

        if (tempMoney > _money)
        {
            container.SetAmount(container.Amount - change);
        }
        else
        {
            ChangeCurrentMoney(tempMoney);
            UpdateContainersButtonsActivity();
        }
    }
Example #3
0
 protected override void Init()
 {
     base.Init();
     if (!_initProcessed)
     {
         _confirmButton.onClick.AddListener(() => OnConfirm());
         foreach (ConsumableData c in _allConsumablesData)
         {
             GameObject           instance = _consumablesPool.GetInstance();
             ConsumablesContainer cc       = instance.GetComponent <ConsumablesContainer>();
             if (cc != null)
             {
                 _containers.Add(cc);
                 cc.InitContainer(c.Name, c.Price);
                 cc.AddAmountChangedListener((int change, int costChange) => AmountChanged(cc, change, costChange));
             }
         }
         UpdateContainersButtonsActivity();
         _initProcessed = true;
     }
 }