Beispiel #1
0
    public bool SetHeldItem(IInventoryItem item)
    {
        if (item == null)
        {
            this.MakeEmpty();
            if (!this.fadingOut)
            {
                this.Opaque();
            }
            return(false);
        }
        this.hasItem = true;
        Texture texture = item.datablock.iconTex;

        ItemDataBlock.LoadIconOrUnknown <Texture>(item.datablock.icon, ref texture);
        this._icon.enabled = true;
        this._myMaterial.Set("_MainTex", texture);
        this._itemHolding = item;
        Vector3 vector3  = new Vector2();
        Vector3 vector31 = vector3;

        this.offsetPoint    = vector3;
        this.offsetVelocity = vector31;
        this.Opaque();
        return(true);
    }
Beispiel #2
0
    private void SetItem(IInventoryItem item)
    {
        if (item == null)
        {
            this.MakeEmpty();
            return;
        }
        this._myDisplayItem = item;
        if (!item.datablock.IsSplittable())
        {
            this._stackLabel.color = Color.yellow;
            this._stackLabel.text  = (item.datablock._maxUses <= item.datablock.GetMinUsesForDisplay() ? string.Empty : item.uses.ToString());
        }
        else
        {
            this._stackLabel.color = Color.white;
            if (item.uses <= 1)
            {
                this._stackLabel.text = string.Empty;
            }
            else
            {
                UILabel uILabel = this._stackLabel;
                int     num     = item.uses;
                uILabel.text = string.Concat("x", num.ToString());
            }
        }
        if (this._amountBackground)
        {
            if (this._stackLabel.text != string.Empty)
            {
                Vector2 vector2 = this._stackLabel.font.CalculatePrintedSize(this._stackLabel.text, true, UIFont.SymbolStyle.None);
                this._amountBackground.enabled = true;
                Transform vector3  = this._amountBackground.transform;
                float     single   = vector2.x;
                Vector3   vector31 = this._stackLabel.transform.localScale;
                vector3.localScale = new Vector3(single * vector31.x + 12f, 16f, 1f);
            }
            else
            {
                this._amountBackground.enabled = false;
            }
        }
        if (ItemDataBlock.LoadIconOrUnknown <Texture>(item.datablock.icon, ref item.datablock.iconTex))
        {
            Material material = TextureMaterial.GetMaterial(RPOSInventoryCell._myMaterial, item.datablock.iconTex);
            this._icon.material = (UIMaterial)material;
            this._icon.enabled  = true;
        }
        IHeldItem heldItem  = item as IHeldItem;
        IHeldItem heldItem1 = heldItem;
        int       num1      = (heldItem != null ? heldItem1.totalModSlots : 0);
        int       num2      = (num1 != 0 ? heldItem1.usedModSlots : 0);

        for (int i = 0; i < (int)this.modSprites.Length; i++)
        {
            if (i >= num1)
            {
                this.modSprites[i].enabled = false;
            }
            else
            {
                this.modSprites[i].enabled    = true;
                this.modSprites[i].sprite     = (i >= num2 ? this.mod_empty : this.mod_full);
                this.modSprites[i].spriteName = this.modSprites[i].sprite.name;
            }
        }
        if (item.IsBroken())
        {
            this._icon.color = Color.red;
        }
        else if (item.condition / item.maxcondition > 0.4f)
        {
            this._icon.color = Color.white;
        }
        else
        {
            this._icon.color = Color.yellow;
        }
    }
Beispiel #3
0
 private void SetItem(IInventoryItem item)
 {
     if (item == null)
     {
         this.MakeEmpty();
     }
     else
     {
         IHeldItem item2;
         this._myDisplayItem = item;
         if (item.datablock.IsSplittable())
         {
             this._stackLabel.color = Color.white;
             if (item.uses > 1)
             {
                 this._stackLabel.text = "x" + item.uses.ToString();
             }
             else
             {
                 this._stackLabel.text = string.Empty;
             }
         }
         else
         {
             this._stackLabel.color = Color.yellow;
             this._stackLabel.text  = (item.datablock._maxUses <= item.datablock.GetMinUsesForDisplay()) ? string.Empty : item.uses.ToString();
         }
         if (this._amountBackground != null)
         {
             if (this._stackLabel.text == string.Empty)
             {
                 this._amountBackground.enabled = false;
             }
             else
             {
                 Vector2 vector = this._stackLabel.font.CalculatePrintedSize(this._stackLabel.text, true, UIFont.SymbolStyle.None);
                 this._amountBackground.enabled = true;
                 this._amountBackground.transform.localScale = new Vector3((vector.x * this._stackLabel.transform.localScale.x) + 12f, 16f, 1f);
             }
         }
         if (ItemDataBlock.LoadIconOrUnknown <Texture>(item.datablock.icon, ref item.datablock.iconTex))
         {
             Material material = TextureMaterial.GetMaterial(_myMaterial, item.datablock.iconTex);
             this._icon.material = (UIMaterial)material;
             this._icon.enabled  = true;
         }
         int num  = ((item2 = item as IHeldItem) != null) ? item2.totalModSlots : 0;
         int num2 = (num != 0) ? item2.usedModSlots : 0;
         for (int i = 0; i < this.modSprites.Length; i++)
         {
             if (i < num)
             {
                 this.modSprites[i].enabled    = true;
                 this.modSprites[i].sprite     = (i >= num2) ? this.mod_empty : this.mod_full;
                 this.modSprites[i].spriteName = this.modSprites[i].sprite.name;
             }
             else
             {
                 this.modSprites[i].enabled = false;
             }
         }
         if (item.IsBroken())
         {
             this._icon.color = Color.red;
         }
         else if ((item.condition / item.maxcondition) <= 0.4f)
         {
             this._icon.color = Color.yellow;
         }
         else
         {
             this._icon.color = Color.white;
         }
     }
 }