private string SetupJson(EngineDoc doc, string docName)
        {
            var item = new Itemobject();

            item.name                     = docName;
            item.resourceId               = doc.Attributes.AppId;
            item.resourceType             = doc.Attributes.Resourcetype;
            item.description              = doc.Attributes.Description;
            item.resourceCustomAttributes = new Resourcecustomattributes();
            item.resourceCreatedAt        = doc.Attributes.CreatedDate;
            item.resourceCreatedBySubject = doc.Attributes.Owner;
            item.resourceAttributes       = new Resourceattributes
            {
                id               = doc.Attributes.AppId,
                description      = doc.Attributes.Description,
                thumbnail        = doc.Attributes.Thumbnail,
                lastReloadTime   = doc.Attributes.LastReloadTime,
                createdDate      = doc.Attributes.CreatedDate,
                modifiedDate     = doc.Attributes.ModifiedDate,
                owner            = doc.Attributes.Owner,
                ownerId          = doc.Attributes.OwnerId,
                dynamicColor     = doc.Attributes.DynamicColor,
                published        = doc.Attributes.Published,
                publishTime      = doc.Attributes.PublishTime,
                hasSectionAccess = doc.Attributes.HasSectionAccess,
                encrypted        = doc.Attributes.Encrypted,
                originAppId      = doc.Attributes.OriginAppId,
                _resourcetype    = doc.Attributes.Resourcetype
            };
            var json = JsonConvert.SerializeObject(item, IgnoreNullSetting());

            return(json);
        }
 void Start()
 {
     description.text = "";
     Itemname.text    = "";
     instance         = this;
     item             = null;
     InfoButton.SetActive(false);
     Usebutton.SetActive(false);
     deleteButton.SetActive(false);
 }
 public void RemoveItem(Itemobject _item)
 {
     for (int i = 0; i < inventory.Container.Count; i++)
     {
         if (inventory.Container[i].item.Itemname == _item.Itemname)
         {
             if (inventory.Container[i].amount == 0)
             {
                 inventory.Container.Remove(inventory.Container[i]);
             }
             else if (inventory.Container[i].amount > 0)
             {
                 inventory.Container[i].amount--;
             }
         }
     }
 }
    public void AddItem(Itemobject _item, int _amount)
    {
        bool hasItem = false;

        for (int i = 0; i < Container.Count; i++)
        {
            if (Container[i].item == _item)
            {
                Container[i].AddAmount(_amount);
                hasItem = true;
                break;
            }
        }
        if (!hasItem)
        {
            Container.Add(new InventorySlot(_item, _amount));
        }
    }
 public override void Use(Itemobject _item)
 {
     GameObject.FindGameObjectWithTag("Player").GetComponent <HealthSystem>().Health += Healthincrease;
     GameObject.FindGameObjectWithTag("Player").GetComponent <HungerSystem>().Hunger  = hungerDecrease;
     for (int i = 0; i < inventory.Container.Count; i++)
     {
         if (inventory.Container[i].item.type == _item.type)
         {
             if (inventory.Container[i].item.Itemname == _item.Itemname)
             {
                 inventory.Container[i].amount -= 1;
                 inventory.Container[i].amount  = Mathf.Clamp(inventory.Container[i].amount, 0, 100);
             }
         }
         else
         {
             return;
         }
     }
 }
示例#6
0
 public InventorySlot(Itemobject _item, int _amount)
 {
     item   = _item;
     amount = _amount;
 }
 public virtual void Use(Itemobject _item)
 {
     Debug.Log("Use");
 }
示例#8
0
 public void Selected(Itemobject item)
 {
     InventoryManager.instance.selected = true;
     InventoryManager.instance.item     = item;
 }