상속: MonoBehaviour
예제 #1
0
 // Token: 0x060000EA RID: 234 RVA: 0x00011DA4 File Offset: 0x0000FFA4
 private void Start()
 {
     if (this.template != null)
     {
         int    num    = 0;
         Bounds bounds = default(Bounds);
         for (int i = 0; i < this.maxRows; i++)
         {
             for (int j = 0; j < this.maxColumns; j++)
             {
                 GameObject gameObject = base.gameObject.AddChild(this.template);
                 gameObject.transform.localPosition = new Vector3((float)this.padding + ((float)j + 0.5f) * (float)this.spacing, (float)(-(float)this.padding) - ((float)i + 0.5f) * (float)this.spacing, 0f);
                 UIStorageSlot component = gameObject.GetComponent <UIStorageSlot>();
                 if (component != null)
                 {
                     component.storage = this;
                     component.slot    = num;
                 }
                 bounds.Encapsulate(new Vector3((float)this.padding * 2f + (float)((j + 1) * this.spacing), (float)(-(float)this.padding) * 2f - (float)((i + 1) * this.spacing), 0f));
                 if (++num >= this.maxItemCount)
                 {
                     if (this.background != null)
                     {
                         this.background.transform.localScale = bounds.size;
                     }
                     return;
                 }
             }
         }
         if (this.background != null)
         {
             this.background.transform.localScale = bounds.size;
         }
     }
 }
예제 #2
0
 private void Start()
 {
     if (this.template != null)
     {
         int    num    = 0;
         Bounds bounds = new Bounds();
         for (int i = 0; i < this.maxRows; i++)
         {
             for (int j = 0; j < this.maxColumns; j++)
             {
                 GameObject obj2 = NGUITools.AddChild(base.gameObject, this.template);
                 obj2.transform.localPosition = new Vector3(this.padding + ((j + 0.5f) * this.spacing), -this.padding - ((i + 0.5f) * this.spacing), 0f);
                 UIStorageSlot component = obj2.GetComponent <UIStorageSlot>();
                 if (component != null)
                 {
                     component.storage = this;
                     component.slot    = num;
                 }
                 bounds.Encapsulate(new Vector3((this.padding * 2f) + ((j + 1) * this.spacing), (-this.padding * 2f) - ((i + 1) * this.spacing), 0f));
                 if (++num >= this.maxItemCount)
                 {
                     if (this.background != null)
                     {
                         this.background.transform.localScale = bounds.size;
                     }
                     return;
                 }
             }
         }
         if (this.background != null)
         {
             this.background.transform.localScale = bounds.size;
         }
     }
 }
예제 #3
0
파일: UIStorage.cs 프로젝트: tuitutor/test1
    void Update()
    {
        GameObject player = Player.player;

        if (!player)
        {
            return;
        }

        PlayerInteraction interaction = player.GetComponent <PlayerInteraction>();

        if (interaction.current != null && ((MonoBehaviour)interaction.current).GetComponent <Storage>() != null)
        {
            panel.SetActive(true);

            Storage storage = ((MonoBehaviour)interaction.current).GetComponent <Storage>();

            // instantiate/destroy enough slots
            UIUtils.BalancePrefabs(slotPrefab.gameObject, storage.slots.Count, content);

            // refresh all items
            for (int i = 0; i < storage.slots.Count; ++i)
            {
                UIStorageSlot slot = content.GetChild(i).GetComponent <UIStorageSlot>();
                slot.dragAndDropable.name = i.ToString(); // drag and drop index
                ItemSlot itemSlot = storage.slots[i];

                if (itemSlot.amount > 0)
                {
                    // refresh valid item
                    slot.tooltip.enabled          = true;
                    slot.tooltip.text             = itemSlot.ToolTip();
                    slot.dragAndDropable.dragable = true;
                    slot.image.color  = Color.white;
                    slot.image.sprite = itemSlot.item.image;
                    slot.amountOverlay.SetActive(itemSlot.amount > 1);
                    slot.amountText.text = itemSlot.amount.ToString();
                }
                else
                {
                    // refresh invalid item
                    slot.tooltip.enabled          = false;
                    slot.dragAndDropable.dragable = false;
                    slot.image.color  = Color.clear;
                    slot.image.sprite = null;
                    slot.amountOverlay.SetActive(false);
                }
            }
        }
        else
        {
            panel.SetActive(false);
        }
    }
예제 #4
0
    /// <summary>
    /// Initialize the container and create an appropriate number of UI slots.
    /// </summary>

    void Start()
    {
        if (template != null)
        {
            Transform myTrans = transform;

            int    count = 0;
            Bounds b     = new Bounds();

            for (int y = 0; y < maxRows; ++y)
            {
                for (int x = 0; x < maxColumns; ++x)
                {
                    GameObject go = Instantiate(template) as GameObject;
                    Transform  t  = go.transform;
                    t.parent        = myTrans;
                    t.localPosition = new Vector3(padding + (x + 0.5f) * spacing, -padding - (y + 0.5f) * spacing, 0f);
                    t.localRotation = Quaternion.identity;
                    t.localScale    = Vector3.one;

                    UIStorageSlot slot = go.GetComponent <UIStorageSlot>();

                    if (slot != null)
                    {
                        slot.storage = this;
                        slot.slot    = count;
                    }

                    b.Encapsulate(new Vector3(padding * 2f + (x + 1) * spacing, -padding * 2f - (y + 1) * spacing, 0f));

                    if (++count >= maxItemCount)
                    {
                        if (background != null)
                        {
                            background.transform.localScale = b.size;
                        }
                        return;
                    }
                }
            }
            if (background != null)
            {
                background.transform.localScale = b.size;
            }
        }
    }
예제 #5
0
    /// <summary>
    /// Initialize the container and create an appropriate number of UI slots.
    /// </summary>

    void Start()
    {
        if (template != null)
        {
            int    count = 0;
            Bounds b     = new Bounds();

            for (int y = 0; y < maxRows; ++y)
            {
                for (int x = 0; x < maxColumns; ++x)
                {
                    GameObject go = NGUITools.AddChild(gameObject, template);
                    Transform  t  = go.transform;
                    t.localPosition = new Vector3(padding + (x + 0.5f) * spacing, -padding - (y + 0.5f) * spacing, 0f);

                    UIStorageSlot slot = go.GetComponent <UIStorageSlot>();

                    if (slot != null)
                    {
                        slot.storage = this;
                        slot.slot    = count;
                    }

                    b.Encapsulate(new Vector3(padding * 2f + (x + 1) * spacing, -padding * 2f - (y + 1) * spacing, 0f));

                    if (++count >= maxItemCount)
                    {
                        if (background != null)
                        {
                            background.transform.localScale = b.size;
                        }
                        return;
                    }
                }
            }
            if (background != null)
            {
                background.transform.localScale = b.size;
            }
        }
    }
예제 #6
0
	private void SetClickDownSlot( UIStorageSlot slot )
	{
		m_ClickDownItemSlot = slot;
		
		if( null != m_ClickDownItemSlot )
		{			
			AttachFocusImg( m_ClickDownItemSlot );
		}
		else
		{
			DetachFocusImg();
		}
	}
예제 #7
0
	private void SetMoveSlot( UIStorageSlot slot )
	{
		if( null != slot.slotItem )
			slot.slotItem.ShowCoolTime( false );
		
		moveItemSlot.SetSlotItem( slot.slotItem );
		moveItemSlot.SetSlotIndex( slot.slotIndex );
	}
예제 #8
0
	public void AttachFocusImg( UIStorageSlot storageslot )
	{
		if( null == focusImg )
		{
			Debug.LogError("UIStorageDlg::AttachFocusImg() [ null == focusImg ]");
			return;
		}
		
		if( null == storageslot )
			return;
		
		
		focusImg.gameObject.active = true;
		Vector3 vec3SlotPos = storageslot.transform.position;
		vec3SlotPos.z -= 1.0f;
		focusImg.transform.position = vec3SlotPos;
	}
예제 #9
0
    void Update()
    {
        Player player = Player.localPlayer;

        if (player)
        {
            if (player.interaction.current != null &&
                ((NetworkBehaviour)player.interaction.current).GetComponent <Storage>() != null)
            {
                panel.SetActive(true);
                Storage storage = ((NetworkBehaviour)player.interaction.current).GetComponent <Storage>();
                UIUtils.BalancePrefabs(slotPrefab.gameObject, storage.slots.Count, content);
                for (int i = 0; i < storage.slots.Count; ++i)
                {
                    UIStorageSlot slot = content.GetChild(i).GetComponent <UIStorageSlot>();
                    slot.dragAndDropable.name = i.ToString();
                    ItemSlot itemSlot = storage.slots[i];
                    if (itemSlot.amount > 0)
                    {
                        slot.tooltip.enabled = true;
                        if (slot.tooltip.IsVisible())
                        {
                            slot.tooltip.text = itemSlot.ToolTip();
                        }
                        slot.dragAndDropable.dragable = true;
                        if (itemSlot.item.maxDurability > 0)
                        {
                            if (itemSlot.item.durability == 0)
                            {
                                slot.image.color = brokenDurabilityColor;
                            }
                            else if (itemSlot.item.DurabilityPercent() < lowDurabilityThreshold)
                            {
                                slot.image.color = lowDurabilityColor;
                            }
                            else
                            {
                                slot.image.color = Color.white;
                            }
                        }
                        else
                        {
                            slot.image.color = Color.white;
                        }
                        slot.image.sprite = itemSlot.item.image;
                        slot.amountOverlay.SetActive(itemSlot.amount > 1);
                        slot.amountText.text = itemSlot.amount.ToString();
                    }
                    else
                    {
                        slot.tooltip.enabled          = false;
                        slot.dragAndDropable.dragable = false;
                        slot.image.color  = Color.clear;
                        slot.image.sprite = null;
                        slot.amountOverlay.SetActive(false);
                    }
                }
            }
            else
            {
                panel.SetActive(false);
            }
        }
    }