예제 #1
0
    public override void Awake()
    {
        base.Awake();
        workerGo = new Dictionary <EWORKER, GameObject>
        {
            { EWORKER.Worker_fangyu, Fangyu_obj },
            { EWORKER.Worker_fuzhu, Fuzhu_obj },
            { EWORKER.Worker_gongshou, Gongshou_obj },
            { EWORKER.Worker_shuchu, Shuchu_obj },
            { EWORKER.Worker__moushi, Moushi_obj }
        };

        gle = Content_obj.GetComponent <GridLayerExpand>();

        sr      = ScrollView_obj.GetComponent <ScrollRect>();
        rt      = Content_obj.GetComponent <RectTransform>();
        lockobj = Instantiate(Lock, transform, false).transform;

        HeroData[] allHero = HeroMgr.GetSingleton().Heros;
        //英雄分类
        heroGo = new Dictionary <HeroInfo, Transform>();
        for (int i = allHero.Length - 1; i >= 0; --i)
        {
            EWORKER    worker   = (EWORKER)allHero[i].JsonData.type;
            GameObject info     = Instantiate(HeadInfo, workerGo[worker].transform, false);
            HeroInfo   heroInfo = info.GetComponent <HeroInfo>();
            heroInfo.SetData(allHero[i]);
            EventListener.Get(info).OnClick = e =>
            {
                if (isDrag)
                {
                    return;
                }
                UIFace.GetSingleton().Open(UIID.HeroDetail, heroInfo.heroData.HeroId);
            };
            EventListener.Get(info).BegineDragEvent = e =>
            {
                isDrag = true;
                sr.OnBeginDrag(e);
            };
            EventListener.Get(info).DragEvent = e =>
            {
                sr.OnDrag(e);
            };
            EventListener.Get(info).EndDragEvent = e =>
            {
                isDrag = false;
                sr.OnEndDrag(e);
            };
            heroGo.Add(heroInfo, info.transform);
        }
        foreach (var item in workerGo)
        {
            item.Value.SetActive(false);
        }
        //图片分类
        imageWorker = new Dictionary <GameObject, EWORKER>
        {
            { all_img.gameObject, EWORKER.ALL },
            { shuchu_img.gameObject, EWORKER.Worker_shuchu },
            { fangyu_img.gameObject, EWORKER.Worker_fangyu },
            { gongshou_img.gameObject, EWORKER.Worker_gongshou },
            { fuzhu_img.gameObject, EWORKER.Worker_fuzhu },
            { moushi_img.gameObject, EWORKER.Worker__moushi }
        };

        TriggerListenr();
    }