Beispiel #1
0
    public void OpenSettlement(bool win, bool pvp, List <FightUnit> fighters)
    {
        this.Top_obj.SetActive(false);
        this.Bottom_obj.SetActive(false);
        if (!win)
        {
            this.Fail_obj.SetActive(true);
        }
        else
        {
            if (pvp)
            {
                this.PVPSuccess_obj.SetActive(true);
            }
            else
            {
                this.PVESuccess_obj.SetActive(true);

                ZEventSystem.Dispatch(EventConst.DropOutItem, ItemMgr.Instance.itemList);
            }
            if (fighters != null && heroHeadView != null)
            {
                GameObject heroHeadParent = pvp ? pvpheros_obj : pveheros_obj;
                for (int idx = 0; idx < fighters.Count; ++idx)
                {
                    FightUnit unit = fighters[idx];
                    if (unit == null)
                    {
                        continue;
                    }
                    GameObject heroHead = GameObject.Instantiate(heroHeadView.gameObject);
                    heroHead.transform.SetParent(heroHeadParent.transform, false);
                    RectTransform heroHeadRect = heroHead.GetComponent <RectTransform>();
                    heroHeadRect.anchoredPosition = new Vector2(heroHeadRect.sizeDelta.x * (idx * (1 + SETTLE_HEAD_INTERVAL) - (5 + SETTLE_HEAD_INTERVAL * 4) / 2 + 0.5f), 0);
                    HeroHeadView view = heroHead.GetComponent <HeroHeadView>();
                    view.Init();
                    int headId = JsonMgr.GetSingleton().GetHeroByID(unit.HeroId).headid;
                    if (pvp)
                    {
                        view.SetHeroInfo(headId, unit.Rare, unit.Star, unit.Level);
                    }
                    else
                    {
                        HeroData heroData = HeroMgr.GetSingleton().GetHeroData(unit.HeroId);
                        if (heroData != null)
                        {
                            view.SetHeroInfo(headId, unit.Rare, unit.Star, unit.Level, 10, heroData.Exp, heroData.NeedHero); //临时
                        }
                    }
                }
            }
        }
    }
Beispiel #2
0
 public void SetInfo(int headId, int rare, int star, int level, int harm, int max)
 {
     if (heroHeadView != null)
     {
         GameObject node = GameObject.Instantiate(heroHeadView.gameObject, HeadPos_obj.transform, false);
         node.transform.localPosition = Vector3.zero;
         HeroHeadView headView = node.GetComponent <HeroHeadView>();
         headView.Init();
         headView.SetHeroInfo(headId, rare, star, level);
     }
     data_text.text          = harm.ToString("N0");
     harm_pro_img.fillAmount = max > 0 ? ((float)harm / max) : 1;
 }
Beispiel #3
0
    public void InitAreanDefend()
    {
        List <Vector2Int> stubData = Role.Instance.GetStubData(StubType.PVPDefend);
        int needHead = stubData.Count - _heroHeads.Count;

        if (needHead > 0)
        {
            for (int idx = 0; idx < needHead; ++idx)
            {
                GameObject   HeroHeadGo = GameObject.Instantiate(HeroHead.gameObject, this.defend_obj.transform);
                HeroHeadView view       = HeroHeadGo.GetComponent <HeroHeadView>();
                view.Init();
                _heroHeads.Add(view);
            }
        }

        for (int idx = 0; idx < _heroHeads.Count; ++idx)
        {
            if (idx < stubData.Count)
            {
                int           heroId = (int)stubData[idx].y;
                JsonData.Hero jHero  = JsonMgr.GetSingleton().GetHeroByID(heroId);
                if (jHero == null)
                {
                    EDebug.LogErrorFormat("couldn't find hero {0} in json", heroId);
                    return;
                }
                HeroData hero = HeroMgr.GetSingleton().GetHeroData(heroId);
                if (hero == null)
                {
                    EDebug.LogErrorFormat("couldn't find hero {0}", heroId);
                }
                else
                {
                    _heroHeads[idx].SetHeroInfo(jHero.headid, hero.Rare, hero.Star, hero.Level);
                }
            }
            else
            {
                _heroHeads[idx].gameObject.SetActive(false);
            }
        }
    }
Beispiel #4
0
    private void _createHero()
    {
        GameObject heroHead = GameObject.Instantiate(HeroHead.gameObject);

        heroHead.transform.SetParent(herogrid_obj.transform);
        RectTransform headRect = heroHead.GetComponent <RectTransform>();

        headRect.anchoredPosition3D   = Vector3.zero;
        heroHead.transform.localScale = Vector3.one;

        EventListener.Get(heroHead).BegineDragEvent = e =>
        {
            isMove = true;
            _herosScroll.OnBeginDrag(e);
        };
        EventListener.Get(heroHead).DragEvent = e =>
        {
            if (isMove)
            {
                if ((e.delta.y >= 10 || e.delta.x >= 10) && isMove)
                {
                    isMove = false;
                    isDrag = Mathf.Abs(e.delta.y) > e.delta.x;
                    if (!isDrag)
                    {
                        HeroHeadView hv = heroHead.GetComponent <HeroHeadView>();
                        if (StubData.ContainsValue(hv.HeroId))  //已经上阵
                        {
                            return;
                        }
                        _startDrag(hv.HeroId);
                    }
                    return;
                }
            }

            if (!_isDraging)
            {
                _herosScroll.OnDrag(e);
            }
            _onDrag(e);
        };
        EventListener.Get(heroHead).EndDragEvent = e =>
        {
            _endDrag();
            _herosScroll.OnEndDrag(e);
        };

        //EventListener.Get(heroHead).PointerDown = e =>
        //{
        //    HeroHeadView hv = heroHead.GetComponent<HeroHeadView>();
        //    if (StubData.ContainsValue(hv.HeroId))  //已经上阵
        //        return;
        //    _headDragTime = Time.time;
        //    ProcessCtrl.Instance.GoCoroutine("DelayStartDrag", _delayStartDrag(hv.HeroId, e));
        //};

        //EventListener.Get(heroHead).PointerUp = e =>
        //{
        //    _headDragTime = 0;
        //    _endDrag();
        //};

        HeroHeadView headView = heroHead.GetComponent <HeroHeadView>();

        headView.Init();
        _herosBuffer.Add(headView);
    }
    private void ShowOfficer()
    {
        showGo = Officer_trf;
        showGo.SetParent(Right_trf);

        LOfficer_obj.SetActive(true);
        Left_obj.SetActive(false);
        HeroRare ou = JsonMgr.GetSingleton().GetHeroRareByID(heroData.Rare);
        HeroRare up = JsonMgr.GetSingleton().GetHeroRareByID(Mathf.Min(heroData.Rare + 1));

        if (ou == null)
        {
            return;
        }
        if (up == null)
        {
            return;
        }
        currentleft_img.sprite = currentright_img.sprite = ResourceMgr.Instance.LoadSprite(ou.Officer);
        upleft_img.sprite      = upright_img.sprite = ResourceMgr.Instance.LoadSprite(up.Officer);
        current_txt.text       = ou.Name.AddColorLabel(ou.Color);
        up_txt.text            = up.Name.AddColorLabel(up.Color);
        HeroHeadView hhvL = LeftHead_trf.GetComponent <HeroHeadView>();
        HeroHeadView hhvR = RightHea_trf.GetComponent <HeroHeadView>();

        hhvL.Init();
        hhvR.Init();
        hhvL.SetHeroInfo(heroData.JsonData.headid, heroData.Rare, heroData.Star, heroData.Level, true);
        hhvR.SetHeroInfo(heroData.JsonData.headid, heroData.Rare + 1, heroData.Star, heroData.Level, true);
        needhonor_txt.color = Role.Instance.Honor < up.NeedNum ? Color.red : Color.white;
        needhonor_txt.text  = up.NeedNum.ToString("N0");
        EventListener.Get(up_btn.gameObject).OnClick = e =>
        {
            if (heroData.Rare >= JsonMgr.GetSingleton().GetGlobalIntArrayByID(1023).value)
            {
                CanvasView.Instance.AddNotice("高处不胜寒呐~~");
                return;
            }
            if (Role.Instance.Honor < up.NeedNum)
            {
                CanvasView.Instance.AddNotice("荣誉不足!!");
                return;
            }
            HeroMgr.GetSingleton().UnfixOfficer(heroData);
            heroData.Rare++;
            ShowOfficer();
            ShowSide(false);
        };
        Dictionary <Attr, float> ret = heroData.RareAttr(false);
        StringBuilder            sb  = new StringBuilder();

        foreach (var item in ret)
        {
            if (item.Value != 0)
            {
                sb.Append(AttrUtil.GetAttribute(item.Key));
                sb.Append(" ");
                sb.Append(AttrUtil.ShowText(item.Key, item.Value));
                sb.Append("\n");
            }
        }
        leftpro_txt.text = sb.ToString();
        Dictionary <Attr, float> next = heroData.RareAttr(true);

        sb.Length = 0;
        foreach (var item in next)
        {
            if (item.Value != 0)
            {
                sb.Append(AttrUtil.GetAttribute(item.Key));
                sb.Append(" ");
                sb.Append(AttrUtil.ShowText(item.Key, item.Value));
                sb.Append(" ");
                float befor = 0;
                if (ret.ContainsKey(item.Key))
                {
                    befor = ret[item.Key];
                }
                sb.Append(string.Format(@"<color=#00FF00> (+{0})</color>", AttrUtil.ShowText(item.Key, item.Value - befor)));
                sb.Append("\n");
            }
        }
        rightpro_txt.text = sb.ToString();

        int[]          officers   = HeroMgr.GetSingleton().GetUnLockOfficer(heroData.Rare);
        int            childCount = OfficerList_obj.transform.childCount;
        List <Officer> os         = SortPost(officers);

        for (int i = 0; i < os.Count; ++i)
        {
            Officer o = os[i];
            if (o == null)
            {
                continue;
            }
            GameObject itemgo;
            if (i < childCount)
            {
                itemgo = OfficerList_obj.transform.GetChild(i).gameObject;
            }
            else
            {
                itemgo = Instantiate(officerGo, OfficerList_obj.transform, false);
            }
            OfficerItem oi = itemgo.GetComponent <OfficerItem>();

            oi.SetView(heroData, o);
            EventListener.Get(oi.take_btn.gameObject).OnClick = e =>
            {
                int takeID = HeroMgr.GetSingleton().IsTake(o.ID);
                if (takeID == heroData.HeroId)
                {
                    return;
                }
                if (takeID != 0)
                {
                    string  name = HeroMgr.GetSingleton().GetHeroData(takeID).JsonData.name;
                    TipCtrl ctrl = (TipCtrl)UIFace.GetSingleton().Open(UIID.Tip, 1, name);
                    ctrl.SetHandler(delegate() { UIFace.GetSingleton().Close(UIID.Tip); },
                                    delegate()
                    {
                        UIFace.GetSingleton().Close(UIID.Tip);
                        HeroMgr.GetSingleton().TakeOfficer(heroData, o.ID);
                        ShowOfficer();
                    });
                }
                else
                {
                    HeroMgr.GetSingleton().TakeOfficer(heroData, o.ID);
                    ShowOfficer();
                }
            };
            EventListener.Get(itemgo).OnClick = e =>
            {
                oi.OnClickItem();
                float minu   = (oi.highlightY - oi.normalY);
                float height = oi.down ? minu : -minu;
                officerrt.sizeDelta = new Vector2(officerrt.sizeDelta.x, officerrt.sizeDelta.y + height);
            };
            if (oi.down)
            {
                oi.OnClickItem();
            }
            EventListener.Get(itemgo).BegineDragEvent = e =>
            {
                OfficerSV_sr.OnBeginDrag(e);
            };
            EventListener.Get(itemgo).DragEvent = e =>
            {
                OfficerSV_sr.OnDrag(e);
            };
            EventListener.Get(itemgo).EndDragEvent = e =>
            {
                OfficerSV_sr.OnEndDrag(e);
            };
        }
        float maxHeight = (officers.Length + 0.5f) * (10.6f + 101);

        officerrt.sizeDelta = new Vector2(officerrt.sizeDelta.x, maxHeight);
    }
    public void ShowSide(bool move)
    {
        int index = 0;

        unLockData = HeroMgr.GetSingleton().Heros;

        if (move)
        {
            maxHeight = (unLockData.Length + 0.5f) * (glg.spacing.y + glg.cellSize.y);
            maxWidth  = (glg.spacing.x + glg.cellSize.x);
            Vector2 v = rect.sizeDelta;
            v.x            = maxWidth;
            v.y            = maxHeight;
            rect.sizeDelta = v;
        }
        for (int i = 0; i < unLockData.Length; ++i)
        {
            GameObject go;
            HeroData   data = unLockData[i];
            if (instantiate.ContainsKey(data))
            {
                go = instantiate[data];
            }
            else
            {
                go = Instantiate(headGo, LeftContent_obj.transform, false);
                instantiate.Add(data, go);
            }
            if (data.HeroId == heroData.HeroId)
            {
                index = i;
                sideselect_trf.SetParent(go.transform);
                sideselect_trf.localPosition = Vector3.zero;
                if (move)
                {
                    Vector2 v2 = sr.content.anchoredPosition;
                    v2.y = -maxHeight + index * glg.cellSize.y;
                    sr.content.anchoredPosition = v2;
                }
            }
            EventListener.Get(go).OnClick = e =>
            {
                if (isOnDrag)
                {
                    return;
                }
                Close();
                sideselect_trf.SetParent(e.transform);
                sideselect_trf.localPosition = Vector3.zero;
                Open(data.HeroId, showType, false);
            };
            EventListener.Get(go).BegineDragEvent = e =>
            {
                isOnDrag = true;
                sr.OnBeginDrag(e);
            };
            EventListener.Get(go).DragEvent = e =>
            {
                sr.OnDrag(e);
            };
            EventListener.Get(go).EndDragEvent = e =>
            {
                isOnDrag = false;
                sr.OnEndDrag(e);
            };

            HeroHeadView hhv = go.GetComponent <HeroHeadView>();
            hhv.Init();
            hhv.SetHeroInfo(data.HeroId, data.Rare, data.Star, data.Level);
        }
        //算法还没有
        Power_txt.text     = "583138";
        LeftLevel_txt.text = heroData.Level.ToString();
        int needExp = JsonMgr.GetSingleton().GetExpByID(Mathf.Max(1, heroData.Level)).NeedHero;

        Exp_slider.value = (heroData.Exp * 100 / needExp * 100) * 0.01f;
        Exp_txt.text     = heroData.Exp + "/" + needExp;
        if (showType == EHEROSHOWTYPE.Card)
        {
            ShowCard();
        }
        else if (showType == EHEROSHOWTYPE.Divination)
        {
            ShowDivination();
        }
        else if (showType == EHEROSHOWTYPE.Detail)
        {
            ShowDetail();
        }
    }