예제 #1
0
 public void isInventoryViewUpdate()
 {
     // map slot image thumbnails to inventory object thumbnails
     // brute force!
     if (collection != null)
     {
         int i = 0;
         foreach (isInventorySlot iis in slots)
         {
             // what if collection.size < slots.size
             GameObject obj = collection.GetDataItem(i);                //data [i];
             if (obj != null)
             {
                 hasThumbnail ht = obj.GetComponent <hasThumbnail> ();
                 if (ht != null)
                 {
                     // if we have a thumbnail, associate this obj with our slot
                     Image slotImage = iis.gameObject.GetComponent <Image>();
                     if (slotImage != null)
                     {
                         slotImage.overrideSprite = ht.img;
                         iis.obj = obj;                             // keep reference to collection obj in the slot
                     }
                 }
             }
             i++;
         }
     }
 }
예제 #2
0
    public void isInventoryViewUpdate()
    {
        // map slot image thumbnails to inventory object thumbnails
        // brute force!
        if (collection != null)
        {
            int i = 0;

            foreach (isInventorySlot slot in slots)
            {
                // what if collection.size < slots.size
                GameObject obj = collection.GetDataItem(i);     //data [i];
                // if we have a thumbnail, associate this obj with our slot
                Image slotImage = slot.gameObject.GetComponent <Image>();
                if (obj != null)
                {
                    hasThumbnail ht = obj.GetComponent <hasThumbnail>();
                    if (ht != null)
                    {
                        //int j = 0;
                        //foreach (isInventorySlot checkSlot in slots)
                        //{
                        //    if (j < i)
                        //    {
                        //        if (checkSlot.obj != null)
                        //        {
                        //            string checkName = checkSlot.obj.GetComponent<isCollectible>().Name;
                        //            string nameInSlot = obj.GetComponent<isCollectible>().Name;
                        //            if (checkName == nameInSlot)
                        //            {
                        //                print("duplicate");
                        //            }
                        //        }
                        //    }
                        //    j++;
                        //}
                        if (slotImage != null)
                        {
                            slotImage.overrideSprite = ht.img;
                            slot.obj = obj;     // keep reference to collection obj in the slot
                            if (slot.GetComponent <FloatData>() != null)
                            {
                                slot.GetComponent <FloatData>().data = collection.GetDataCount(i);
                            }

                            if (i + 1 == selectorIndex)
                            {
                                selector.transform.localPosition = slot.transform.localPosition;
                            }
                        }
                    }
                }
                else
                {
                    slotImage.overrideSprite = null;
                    slot.obj = null;
                    if (slot.GetComponent <FloatData>() != null)
                    {
                        slot.GetComponent <FloatData>().data = 0;
                    }
                    //if (i != 0)
                    //{
                    //    highlight.transform.position = slots[i - 1].transform.position;

                    //    selector.transform.position = slots[i - 1].transform.position;
                    //}
                }
                i++;
            }
        }
    }