Esempio n. 1
0
    private void Instantiate(string id)
    {
        GameObject         go  = Instantiate(item, itemparent_trf, false);
        DivinationItemView div = go.GetComponent <DivinationItemView>();
        TotemData          td  = TotemMgr.GetSingleton().GetTotemByID(id);

        if (td == null)
        {
            td = new TotemData(40007)
            {
                md5 = id
            };
            TotemMgr.GetSingleton().AddTotem(td);
        }
        div.SetView(td);
        EventListener.Get(go).OnClick = e =>
        {
            ZEventSystem.Register(EventConst.ONOPENCOMPOSE, this, "OnOpenCompose");
            UIFace.GetSingleton().Open(UIID.DivinationTip, td, SHOWBUTTON.Ecompose);
            if (!select_trf.gameObject.activeInHierarchy)
            {
                select_trf.gameObject.SetActive(true);
            }
            select_trf.SetParent(go.transform);
            select_trf.transform.localPosition = Vector3.zero;
        };
        EventListener.Get(go).BegineDragEvent = e =>
        {
            Item_sr.OnBeginDrag(e);
        };
        EventListener.Get(go).DragEvent = e =>
        {
            Item_sr.OnDrag(e);
        };
        EventListener.Get(go).EndDragEvent = e =>
        {
            Item_sr.OnEndDrag(e);
        };
        Role.Instance.DivinationLucky += JsonMgr.GetSingleton().GetTotemTreeByID(progress + 1).spend;
        lucky_img.fillAmount           = Role.Instance.DivinationLucky / maxLucky;
    }
Esempio n. 2
0
    private void InitItem()
    {
        TotemData[] totems = TotemMgr.GetSingleton().Totems;
        for (int i = 0; i < totems.Length; ++i)
        {
            TotemData totem = totems[i];
            if (totem.md5 == composeItem.md5 || totem.HeroID != 0)
            {
                continue;
            }
            GameObject         t   = Instantiate(item, divination_sr.content);
            DivinationItemView div = t.GetComponent <DivinationItemView>();
            div.SetView(totem);
            allItem.Add(div);
            EventListener.Get(t).OnClick = e =>
            {
                if (!playItem.Contains(div))
                {
                    if (playItem.Count >= 6)
                    {
                        CanvasView.Instance.AddNotice("已到最大数量");
                        return;
                    }
                    playItem.Add(div);
                    div.SetAlpha(1);
                    for (int j = 1; j < div.data.Level; j++)
                    {
                        playExp += div.data.LevelUpExp(j);
                    }
                    playExp += totem.Exp;
                    playExp += totem.TotemConfig.Exp;
                }
                else
                {
                    playItem.Remove(div);
                    div.SetAlpha(0);
                    for (int j = 1; j < div.data.Level; j++)
                    {
                        playExp -= div.data.LevelUpExp(j);
                    }
                    playExp -= totem.Exp;
                    playExp -= totem.TotemConfig.Exp;
                }
                SetPlayView();
                ExpValue();
            };
            EventListener.Get(t).BegineDragEvent = e =>
            {
                divination_sr.OnBeginDrag(e);
            };
            EventListener.Get(t).DragEvent = e =>
            {
                divination_sr.OnDrag(e);
            };
            EventListener.Get(t).EndDragEvent = e =>
            {
                divination_sr.OnEndDrag(e);
            };
        }

        EventListener.Get(auto_btn.gameObject).OnClick = e =>
        {
            int count = playItem.Count;
            int index = allItem.Count;
            index--;
            while (playItem.Count < 6 && index >= 0)
            {
                if (!playItem.Contains(allItem[index]))
                {
                    playItem.Add(allItem[index]);
                    allItem[index].SetAlpha(1);
                }
                index--;
            }
            playExp = 0;
            for (int i = 0; i < playItem.Count; i++)
            {
                for (int j = 1; j < playItem[i].data.Level; j++)
                {
                    playExp += playItem[i].data.LevelUpExp(j);;
                }
                playExp += playItem[i].data.Exp;
                playExp += playItem[i].data.TotemConfig.Exp;
            }
            SetPlayView();
            ExpValue();
        };

        Vector2 size = divination_sr.content.sizeDelta;

        size.y = Mathf.CeilToInt(totems.Length / 3f) * 182 + 24;
        divination_sr.content.sizeDelta = size;
        EventListener.Get(sure_btn.gameObject).OnClick = e =>
        {
            if (composeItem == null)
            {
                return;
            }
            Compose();
            SetPlayView();
            ExpValue();
            Close();
            Open(composeItem);
        };
    }
Esempio n. 3
0
    private void ShowDivination()
    {
        showGo = Divination_trf;
        showGo.SetParent(Right_trf);
        Divination_obj.SetActive(true);
        takeoff_btn.gameObject.SetActive(true);
        take_btn.gameObject.SetActive(true);
        Dress_btn.gameObject.SetActive(false);
        Intensify_btn.gameObject.SetActive(false);
        Equip_obj.SetActive(false);
        HeroDivinationView hdv = Divination_obj.GetComponent <HeroDivinationView>();

        hdv.SetHeroTotemView(heroData);
        EventListener.Get(gotoDiv_btn.gameObject).OnClick = e =>
        {
            UIFace.GetSingleton().Open(UIID.Divination);
        };
        int count = divparent_trf.childCount;

        TotemData[] mData = TotemMgr.GetSingleton().GetUnDressTotem();
        while (count > mData.Length)
        {
            DestroyImmediate(divparent_trf.GetChild(0).gameObject);
            count = divparent_trf.childCount;
        }
        for (int i = 0; i < mData.Length; ++i)
        {
            TotemData data = mData[i];
            if (data.HeroID != 0)
            {
                continue;
            }
            GameObject totem;
            if (i < count)
            {
                totem = divparent_trf.GetChild(i).gameObject;
            }
            else
            {
                totem = Instantiate(totemGo, divparent_trf);
            }
            DivinationItemView div = totem.GetComponent <DivinationItemView>();
            div.SetView(data);
            EventListener.Get(totem).OnClick = e =>
            {
                ZEventSystem.Register(EventConst.TAKETOTEM, this, "TakeTotem");
                UIFace.GetSingleton().Open(UIID.DivinationTip, data, SHOWBUTTON.Etake);
            };
            EventListener.Get(totem).BegineDragEvent = e =>
            {
                divination_sr.OnBeginDrag(e);
            };
            EventListener.Get(totem).DragEvent = e =>
            {
                divination_sr.OnDrag(e);
            };
            EventListener.Get(totem).EndDragEvent = e =>
            {
                divination_sr.OnEndDrag(e);
            };
        }

        Vector2 size = divination_sr.content.sizeDelta;

        size.y = Mathf.CeilToInt(mData.Length / 3f) * 159 + 26;
        divination_sr.content.sizeDelta = size;

        EventListener.Get(take_btn.gameObject).OnClick = e =>
        {
            if (mData.Length <= 0)
            {
                return;
            }
            int         index  = mData.Length - 1;
            TotemData[] totems = heroData.GetTotem();
            if (totems.Length == 0)
            {
                CanvasView.Instance.AddNotice("没有可用的气运槽");
                return;
            }
            for (int i = 0, length = totems.Length; i < length; ++i)
            {
                TotemMgr.GetSingleton().TakeTotem(mData[i], heroData);
            }
            ShowSide(false);
        };
        EventListener.Get(takeoff_btn.gameObject).OnClick = e =>
        {
            TotemData[] totems = heroData.GetTotem();
            for (int i = 0, length = totems.Length; i < length; ++i)
            {
                if (totems[i] == null)
                {
                    continue;
                }
                TotemMgr.GetSingleton().TakeOffTotem(totems[i]);
            }
            ShowSide(false);
        };
    }