Ejemplo n.º 1
0
        // -------------------------------------------------------------------------------
        protected override void ThrottledUpdate()
        {
            if (manager == null)
            {
                manager = localPlayer.GetComponent <ItemManager>();
            }

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

            foreach (ItemSyncStruct _entry in manager.GetEntries(true, SortOrder.None, category))
            {
                ItemSyncStruct entry  = _entry;
                GameObject     prefab = null;

                if (displayType == DisplayType.Horizontal)
                {
                    prefab = horizontalSlotPrefab.gameObject;
                }
                else if (displayType == DisplayType.Vertical)
                {
                    prefab = verticalSlotPrefab.gameObject;
                }
                else if (displayType == DisplayType.Grid)
                {
                    prefab = gridSlotPrefab.gameObject;
                }

                GameObject go = GameObject.Instantiate(prefab);
                go.transform.SetParent(contentGroup, false);
                go.GetComponent <UIPlayerListItemSlot>().Init(localPlayer, ref entry);
            }
        }
        protected override void SellEntry(int _index, long _amount)
        {
            ItemSyncStruct entry = syncItems[_index];

            entry.Remove(_amount);
            syncItems[_index] = entry;

            GetComponentInParent <CurrencyManager>().AddCurrency(entry.template.sellCost, _amount);
        }
Ejemplo n.º 3
0
        public void SaveData_Item(GameObject player)
        {
            connection.Execute("DELETE FROM c2w_item WHERE owner=?", player.name);

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

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

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

                connection.InsertOrReplace(new c2w_item {
                    owner  = player.name,
                    slot   = entry.slot,
                    name   = entry.name,
                    amount = entry.amount,
                    state  = entry.state,
                    timer  = entry.timer
                });
            }
        }
        public void AddEntry(int _slot, ItemTemplate _template, byte _state, double _timer, long _amount)
        {
            ItemSyncStruct syncStruct = new ItemSyncStruct(_slot, _template, _state, _timer, _amount);

            syncItems.Add(syncStruct);
        }