Esempio n. 1
0
    void OnScrollItemClick(GameObject go)
    {
        MapNpcScrollItem item = go.GetComponent <MapNpcScrollItem>();

        if (item != null)
        {
            NPCInfo npcInfo = item.Info;
            if (npcInfo != null)
            {
                MapScrollItemType t = (MapScrollItemType)npcInfo.type;
                if (showDic.ContainsKey(t))
                {
                    bool bShow = showDic[t];
                    showDic[t] = !bShow;
                    MapScrollItemType bigType = MapScrollItemType.NPC | MapScrollItemType.Monster | MapScrollItemType.Transmit;
                    if ((t & bigType) != 0)
                    {
                        FilterList(t);
                    }
                }
                else
                {
                    ClearIcon();
                    Vector3 npcPos = new Vector3(npcInfo.pos.x, 0, -npcInfo.pos.y);
                    AutoFindPath(npcPos, (uint)npcInfo.npcID, true);
                }
            }
            else
            {
                Log.Error("npcinfo is null");
            }
        }
        else
        {
            Log.Error("item is null");
        }
    }
Esempio n. 2
0
    void ShowList(Transform contain)
    {
        m_scrollview_npcscrollview.ResetPosition();
        Transform container = contain;

        if (container != null)
        {
            //if (container.childCount != 0)
            //    return;
            for (int j = showNpcList.Count; j < container.childCount; j++)
            {
                string    itemName  = string.Format("{0:D3}", j);
                Transform itemTrans = container.Find(itemName);
                if (itemTrans != null)
                {
                    itemTrans.gameObject.SetActive(false);
                }
            }
            for (int i = 0; i < showNpcList.Count; i++)
            {
                NPCInfo          info     = showNpcList[i];
                MapNpcScrollItem itemInfo = null;
                GameObject       bigItem  = null;
                string           itemName = string.Format("{0:D3}", i);

                if ((MapScrollItemType)info.type == MapScrollItemType.Small)
                {
                    Transform itemTrans = container.Find(itemName);
                    if (itemTrans != null)
                    {
                        bigItem = itemTrans.gameObject;
                    }
                    else
                    {
                        bigItem   = NGUITools.AddChild(container.gameObject, m_sprite_btn_child.gameObject);
                        itemTrans = bigItem.transform;
                    }
                    bigItem.SetActive(true);
                    if (bigItem != null)
                    {
                        itemInfo = bigItem.GetComponent <MapNpcScrollItem>();
                        if (itemInfo == null)
                        {
                            itemInfo = bigItem.AddComponent <MapNpcScrollItem>();
                        }
                    }
                    bigItem.transform.localPosition = new Vector3(0, (i * -70) - 34, 0);
                }
                if (bigItem != null)
                {
                    bigItem.name = itemName;
                    UIEventListener.Get(bigItem.gameObject).onClick = OnScrollItemClick;
                }
                else
                {
                    Log.Error("bigItem is null");
                }
                if (itemInfo != null)
                {
                    itemInfo.InitInfo(info);
                }
            }
        }
    }