public void AddCurrency(FixedCurrencyCost[] _cost, long _amount)
        {
            foreach (FixedCurrencyCost cost in _cost)
            {
                int index = syncCurrencies.FindIndex(x => x.template == cost.template);

                if (index != -1)
                {
                    CurrencySyncStruct entry = syncCurrencies[index];
                    entry.amount         += cost.amount * _amount;
                    syncCurrencies[index] = entry;
                }
                else
                {
                    index = GetFreeSlot();
                    if (index != -1)
                    {
                        AddEntry(index, cost.template, Constants.STATE_NONE, 0, cost.amount * _amount);
                    }
                }
            }
        }
        public void SaveData_Currency(GameObject player)
        {
            connection.Execute("DELETE FROM c2w_currency WHERE owner=?", player.name);

            CurrencyManager manager = player.GetComponent <CurrencyManager>();

            List <CurrencySyncStruct> list = manager.GetEntries(false);

            for (int i = 0; i < list.Count; i++)
            {
                CurrencySyncStruct entry = list[i];

                connection.InsertOrReplace(new c2w_currency {
                    owner     = player.name,
                    name      = entry.name,
                    slot      = entry.slot,
                    amount    = entry.amount,
                    state     = entry.state,
                    timeStamp = entry.timeStamp
                });
            }
        }
示例#3
0
        // -------------------------------------------------------------------------------
        protected override void ThrottledUpdate()
        {
            windowPanel.SetActive(localPlayer != null);

            if (localPlayer == null)
            {
                return;
            }

            if (manager == null)
            {
                manager = localPlayer.GetComponent <CurrencyManager>();
            }

            for (int i = 0; i < contentGroup.childCount; i++)
            {
                GameObject.Destroy(contentGroup.GetChild(i).gameObject);
            }

            int count = 0;

            foreach (CurrencySyncStruct _entry in manager.GetEntries(true, SortOrder.Priority))
            {
                CurrencySyncStruct entry = _entry;

                GameObject go = GameObject.Instantiate(slotPrefab.gameObject);
                go.transform.SetParent(contentGroup, false);

                go.GetComponent <UICurrencySlotHorizontal>().Init(localPlayer, ref entry);

                count++;

                if (count > maxEntries)
                {
                    break;
                }
            }
        }
        public void AddEntry(int _slot, CurrencyTemplate _template, byte _state, long _timeStamp, long _amount)
        {
            CurrencySyncStruct syncStruct = new CurrencySyncStruct(_slot, _template, _state, _timeStamp, _amount);

            syncCurrencies.Add(syncStruct);
        }