示例#1
0
        private void AddItemInfo(GameObject go, int itemId)
        {
            AItemHandler aBaseItemHandler = go.GetComponent <AItemHandler>();

            if (aBaseItemHandler == null)
            {
                aBaseItemHandler = (go.AddComponent(this.m_handlerType) as AItemHandler);
                aBaseItemHandler.Init();
                aBaseItemHandler.dataType = this.m_dataType;
            }
            if (this.m_dataList == null)
            {
                aBaseItemHandler.Show(itemId, null);
            }
            else if (this.m_dataList.Count > itemId)
            {
                aBaseItemHandler.Show(itemId, this.m_dataList[itemId]);
            }
            if (!this.m_handlerDic.ContainsKey(itemId))
            {
                this.m_handlerDic.Add(itemId, aBaseItemHandler);
            }
            else
            {
                this.m_handlerDic[itemId] = aBaseItemHandler;
            }
        }
示例#2
0
 public void UpdataItem()
 {
     for (int i = 0; i < this.m_content.childCount; i++)
     {
         AItemHandler component = this.m_content.transform.GetChild(i).GetComponent <AItemHandler>();
         if (!(component != null))
         {
             this.m_childCountCache = -1;
             this.InitRollItem();
             return;
         }
         if (this.m_dataList != null)
         {
             if (this.m_dataList.Count > component.id)
             {
                 component.Show(component.id, this.m_dataList[component.id]);
             }
         }
         else
         {
             component.Show(component.id, null);
         }
         if (!this.m_handlerDic.ContainsValue(component))
         {
             this.m_handlerDic[component.id] = component;
         }
     }
 }
示例#3
0
        private void RemoveItemInfo(GameObject go)
        {
            AItemHandler component = go.GetComponent <AItemHandler>();

            if (component != null)
            {
                this.m_handlerDic.Remove(component.id);
            }
        }
示例#4
0
        private void InitHideItem()
        {
            GameObjectUtils.CreateChilds(this.m_content, this.m_itemGameobj.transform, this.m_childCount);
            for (int i = 0; i < this.m_childCount; i++)
            {
                GameObject gameObject = this.m_content.transform.GetChild(i).gameObject;
                gameObject.transform.localPosition = this.m_itemPosDic[i];
                gameObject.transform.localScale    = Vector3.one;
                gameObject.name = i.ToString();
                AItemHandler aBaseItemHandler = gameObject.GetComponent <AItemHandler>();
                if (aBaseItemHandler == null)
                {
                    aBaseItemHandler = (gameObject.AddComponent(this.m_handlerType) as AItemHandler);
                    aBaseItemHandler.Init();
                    aBaseItemHandler.dataType = this.m_dataType;
                }
                if (this.m_dataList != null)
                {
                    aBaseItemHandler.Show(i, this.m_dataList[i]);
                }
                else
                {
                    aBaseItemHandler.Show(i, null);
                }
                aBaseItemHandler.initPos = this.m_itemPosDic[i];
                if (!this.m_handlerDic.ContainsKey(i))
                {
                    this.m_handlerDic.Add(i, aBaseItemHandler);
                }
                else
                {
                    this.m_handlerDic[i] = aBaseItemHandler;
                }
            }
            this.ScrollRectEvent(Vector2.zero);
            int num = (this.m_itemIdIntUp - 1) * this.m_constraintCount;

            if (num > 0 && this.m_childCount > num)
            {
                for (int j = 0; j < num; j++)
                {
                    this.m_handlerDic[j].trans.gameObject.SetActive(false);
                }
            }
            num = (this.m_itemIdIntDown + 1) * this.m_constraintCount;
            if (num > 0 && this.m_childCount > num)
            {
                for (int k = num; k < this.m_childCount; k++)
                {
                    this.m_handlerDic[k].trans.gameObject.SetActive(false);
                }
            }
        }
示例#5
0
        public AItemHandler GetHandler(int itemId)
        {
            AItemHandler result = null;

            if (this.m_handlerDic == null)
            {
                return(result);
            }
            if (!this.m_handlerDic.TryGetValue(itemId, out result))
            {
            }
            return(result);
        }
示例#6
0
        public void UpdateOnce()
        {
            int itemIdUp   = this.GetItemIdUp();
            int itemIdDown = this.GetItemIdDown();

            for (int i = itemIdUp; i < itemIdDown + 1; i++)
            {
                AItemHandler handler = this.GetHandler(i);
                if (handler != null)
                {
                    handler.Show(null);
                }
            }
        }