Example #1
0
        // -------------------------------------------------------------------------------
        // Init
        // -------------------------------------------------------------------------------
        public void Init(GameObject _parent = null, int level = 1)
        {
            base.Init(_parent);

            syncEquipment.Clear();

            foreach (BaseItem equipment in defaultEquipment)
            {
                if (equipment.template != null)
                {
                    SItem sItem = new SItem(equipment.template.GetId, equipment.template.slot, equipment.template.amount, equipment.template.ammo, equipment.template.charges, equipment.template.level);
                    syncEquipment.Add(sItem);
                }
            }
        }
Example #2
0
        // -------------------------------------------------------------------------------
        // Init
        // -------------------------------------------------------------------------------
        public void Init(GameObject _parent = null, int level = 1)
        {
            base.Init(_parent);

            syncInventory.Clear();

            int i = 0;

            foreach (BaseItem item in defaultInventory)
            {
                if (item.template != null)
                {
                    SItem sItem = new SItem(item.template.GetId, i, item.template.amount, item.template.ammo, item.template.charges, item.template.level);
                    syncInventory.Add(sItem);
                    i++;
                }
            }
        }
Example #3
0
        // -------------------------------------------------------------------------------
        // Load
        // -------------------------------------------------------------------------------
        public override void Load(BaseDataTable data)
        {
            syncInventory.Clear();

            for (int i = 0; i < data.Rows.Count; ++i)
            {
                TemplateItem tmpl;

                if (DataManager.dictItem.TryGetValue(data.GetIdHash(i), out tmpl))
                {
                    SItem sItem = new SItem(tmpl.GetId, data.GetLongAsInt(DatabaseManager.fieldSlot, i), data.GetLongAsInt(DatabaseManager.fieldAmount, i), data.GetLongAsInt(DatabaseManager.fieldAmmo, i), data.GetLongAsInt(DatabaseManager.fieldCharges, i), data.GetLongAsInt(DatabaseManager.fieldLevel, i));
                    syncInventory.Add(sItem);
                }
                else
                {
                    Debug.LogWarning("Skipped template '" + data.GetString(DatabaseManager.fieldName) + "' as it was not found in Library.");
                }
            }

            data.Cleanup();
        }