예제 #1
0
    private void _updateHeadList()
    {
        List <HeroData> unLockedHeros = new List <HeroData>(HeroMgr.GetSingleton().Heros);

        unLockedHeros.Sort((HeroData a, HeroData b) =>
        {
            if (StubData.ContainsValue(a.HeroId) && !StubData.ContainsValue(b.HeroId))
            {
                return(-1);
            }
            else if (!StubData.ContainsValue(a.HeroId) && StubData.ContainsValue(b.HeroId))
            {
                return(1);
            }
            else
            {
                return(a.HeroId < b.HeroId ? -1 : (a.HeroId > b.HeroId ? 1 : 0));
            }
        });
        for (int idx = 0; idx < unLockedHeros.Count; ++idx)
        {
            HeroData data = unLockedHeros[idx];
            if (idx >= _herosBuffer.Count)
            {
                _createHero();
            }
            _herosBuffer[idx].gameObject.name = string.Format("HeroHead_{0}", data.HeroId);
            _herosBuffer[idx].SetHeroInfo(data.HeroId, data.Rare, data.Star, data.Level);
            _herosBuffer[idx].SetOnStub(StubData.ContainsValue(data.HeroId));
        }
        float maxHeight = Mathf.RoundToInt(_heroGrid.transform.childCount / 2.0f) * (_heroGrid.spacing.y + _heroGrid.cellSize.y);
        float maxWidth  = (_heroGrid.spacing.x + _heroGrid.cellSize.x * 2);

        _heroGridRect.sizeDelta = new Vector2(maxWidth, maxHeight);
    }
예제 #2
0
    private List <Officer> SortPost(int[] officers)
    {
        List <Officer> ret = new List <Officer>();

        for (int i = 0; i < officers.Length; ++i)
        {
            Officer o = JsonMgr.GetSingleton().GetOfficerByID(officers[i]);
            ret.Add(o);
        }
        ret.Sort((Officer a, Officer b) =>
        {
            int takeA = HeroMgr.GetSingleton().IsTake(a.ID);
            int takeB = HeroMgr.GetSingleton().IsTake(b.ID);
            if (takeA == 0 && takeB == 0)
            {
                if (a.ID < b.ID)
                {
                    return(-1);
                }
                return(1);
            }
            else if (takeA != 0 && takeB == 0)
            {
                if (takeA == heroData.HeroId)
                {
                    return(-1);
                }
                return(1);
            }
            else if (takeA == 0 && takeB != 0)
            {
                if (takeB == heroData.HeroId)
                {
                    return(1);
                }
                return(-1);
            }
            else if (takeA != 0 && takeB != 0 && takeA != takeB)
            {
                if (takeA == heroData.HeroId)
                {
                    return(-1);
                }
                if (takeB == heroData.HeroId)
                {
                    return(1);
                }
            }
            return(0);
        });

        return(ret);
    }
예제 #3
0
    public void Open(int heroId)
    {
        heroData = HeroMgr.GetSingleton().GetHeroData(heroId);

        SetHeadView();

        long exp = Role.Instance.ExpPool;

        exp_txt.text = exp.ToString("N0");
        tempLv       = heroData.Level;

        if (exp < heroData.NeedHero || heroData.Level == HeroMgr.MaxHeroLevel)
        {
            levelup_btn.interactable = false;
            expend_txt.text          = heroData.NeedHero.ToString("N0");
            targetLv_txt.text        = tempLv.ToString();
            return;
        }
        levelup_btn.interactable = true;

        do
        {
            cost = ComputerExpend();
            if (cost > exp)
            {
                tempLv--;
                cost = ComputerExpend();
                break;
            }
            if (tempLv == HeroMgr.MaxHeroLevel)
            {
                break;
            }
            tempLv++;
        } while (tempLv <= HeroMgr.MaxHeroLevel);

        expend_txt.text   = cost.ToString("N0");
        targetLv_txt.text = tempLv.ToString();

        EventListener.Get(levelup_btn.gameObject).OnClick = e =>
        {
            if (!levelup_btn.IsInteractable())
            {
                return;
            }
            Role.Instance.ExpPool -= cost;
            heroData.Level         = tempLv;
            Lv_txt.text            = heroData.Level.ToString();
            ZEventSystem.Dispatch(EventConst.REFRESHSIDE, false);
            exp_txt.text = Role.Instance.ExpPool.ToString("N0");
            UIFace.GetSingleton().Close(UIID.ExpPool);
        };
    }
예제 #4
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); //临时
                        }
                    }
                }
            }
        }
    }
예제 #5
0
    public void OnLoadHeroData(ServerMsgObj msg)
    {
        string         server = msg.Msg;
        HeroMsgCollect hm     = JsonUtility.FromJson <HeroMsgCollect>(server);

        HeroData[] dataArray = new HeroData[hm.heros.Length];
        for (int i = 0; i < dataArray.Length; i++)
        {
            dataArray[i] = new HeroData(hm.heros[i]);
            HeroMgr.GetSingleton().AddHeroData(dataArray[i]);
        }
        HeroMgr.GetSingleton().HeroDataLoaded();
    }
예제 #6
0
 /// <summary>
 /// 脱下装备 调用之前判空
 /// </summary>
 /// <param name="equip"></param>
 public void TakeOffEquip(EquipData equip)
 {
     if (!_id.ContainsKey(equip.md5))
     {
         return;
     }
     if (equip.HeroId != 0)
     {
         HeroData hero  = HeroMgr.GetSingleton().GetHeroData(equip.HeroId);
         int      index = PartToIndex(equip.JsonData.EquiPrat);
         hero[0, index] = "";
         equip.HeroId   = 0;
     }
 }
예제 #7
0
    /// <summary>
    /// 脱下气运
    /// </summary>
    /// <param name="totem"></param>
    public void TakeOffTotem(TotemData totem)
    {
        HeroData hero = HeroMgr.GetSingleton().GetHeroData(totem.HeroID);

        if (hero == null)
        {
            return;
        }

        hero.Totems[totem.Groove] = "";
        totem.HeroID = 0;
        totem.Groove = 0;
        hero.ClearTotemAttr();
    }
예제 #8
0
    private int TestColor(bool down)
    {
        int takeID = HeroMgr.GetSingleton().IsTake(officerID);

        Officerdis_cr.SetAlpha(takeID == hd.HeroId || takeID == 0 ? 0 : 1);
        string show = "";

        show = takeID != hd.HeroId && takeID != 0 ?
               string.Format("<color=#5C5C5C>{0}  {1}</color>", text, down ? "" :JsonMgr.GetSingleton().GetHeroByID(takeID).name) :
               down?string.Format("<color=#FFFF30>{0}</color>", text) : string.Format("<color=#FF8A00>{0}</color>", text);

        officername_txt.text = show;
        return(takeID);
    }
예제 #9
0
 public void Open()
 {
     select_trf.gameObject.SetActive(false);
     progress = Role.Instance.DivinationTree;
     SetProgress(progress);
     lucky_img.fillAmount = Role.Instance.DivinationLucky / maxLucky;
     EventListener.Get(take_btn.gameObject).OnClick = e =>
     {
         ZEventSystem.Register(EventConst.ONOPENCOMPOSE, this, "OnOpenCompose");
         UIFace.GetSingleton().Open(UIID.HeroDetail, HeroMgr.GetSingleton().GetNo1(), EHEROSHOWTYPE.Divination);
         Close();
         if (select_trf.gameObject.activeInHierarchy)
         {
             select_trf.gameObject.SetActive(false);
         }
         ZEventSystem.DeRegister(EventConst.ONOPENCOMPOSE);
     };
 }
예제 #10
0
    public void TakeTotem(TotemData td, HeroData hd)
    {
        if (!TotemDic.ContainsKey(td.md5))
        {
            return;
        }

        int res = HeroMgr.GetSingleton().TakeHeroTotem(hd, td);

        if (res == int.MaxValue)
        {
            return;
        }
        //服务器处理 这里模拟
        td.HeroID = hd.HeroId;
        td.Groove = res;
        hd.ClearTotemAttr();
    }
예제 #11
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);
            }
        }
    }
    /// <summary>
    /// 显示武将
    /// </summary>
    /// <param name="heross"></param>
    public void ShowHero()
    {
        if (RecruitingMgr.Instance.heroList.Count > heros.Count)
        {
            for (int i = 0; i < RecruitingMgr.Instance.heroList.Count; i++)
            {
                Hero heroses = JsonMgr.GetSingleton().GetHeroByID(RecruitingMgr.Instance.heroList[i]);
                if (i == heros.Count)
                {
                    GameObject   hero   = LoadHero();
                    HeroHaveInfo _heros = hero.GetComponent <HeroHaveInfo>();
                    _heros.Init();
                    _heros.heroid = RecruitingMgr.Instance.heroList[i];
                    heros.Add(_heros);
                }
                IsHeroHead herohead = new IsHeroHead();
                herohead._heros = heroses;
                if (HeroMgr.GetSingleton().HerosContainer.ContainsKey(heroses.ID))
                {
                    herohead.isHave = 1;
                }
                else
                {
                    herohead.isHave = 2;
                }
                herolist.Add(herohead);
            }
            UpdateHero();
        }
        //滑动窗大小
        if (grid == null)
        {
            grid   = hero_obj.GetComponent <GridLayoutGroup>();
            rect   = hero_obj.GetComponent <RectTransform>();
            srrect = allhero_obj.GetComponent <RectTransform>();
        }
        int num  = (int)(srrect.sizeDelta.y / grid.cellSize.y); //行数
        int xnum = (int)(srrect.sizeDelta.x / grid.cellSize.x); //每行个数

        rect.offsetMin = new Vector2(0, -((grid.cellSize.y + grid.spacing.y) * ((heros.Count / xnum) - num)));
        rect.offsetMax = Vector2.zero;
        herohead       = RecruitingMgr.Instance.heroList;
    }
예제 #13
0
    public void Open(int heroId)
    {
        data = HeroMgr.GetSingleton().GetHeroData(heroId);
        HeroName_txt.text = data.JsonData.name;

        int[] matnum = JsonMgr.GetSingleton().GetHeroStarByID(heroId).matnum;
        //取下一星级需要数量 刚好为当前星级下标
        int needPiece = matnum[data.Star];

        Piece_txt.text = data.Piece + "/" + needPiece;
        //边框为碎片稀有度 -- 固定
        //OfficerUp officerUp = JsonMgr.GetSignleton().GetOfficerUpByID(data.Rare);
        //broder_img.sprite = ResourceMgr.Instance.LoadSprite(officerUp.CardBorder);
        //碎片ID没定
        piece_img.sprite = ResourceMgr.Instance.LoadSprite(data.JsonData.headid);

        EventListener.Get(close_btn.gameObject).OnClick = e =>
        {
            UIFace.GetSingleton().Close(UIID.HeroGoto);
        };
    }
예제 #14
0
    public void Open(int heroid, EHEROSHOWTYPE type = EHEROSHOWTYPE.Card, bool move = true)
    {
        heroData = HeroMgr.GetSingleton().GetHeroData(heroid);
        BuildHeroEvent(heroid);

        RegisteEvent();

        foreach (var item in imageType)
        {
            if (item.Value == type)
            {
                item.Key.GetComponent <Toggle>().isOn = true;
            }
        }
        ddActive = true;
        ShowPopList(null);

        ShowType(type);
        ShowLeft();
        ShowSide(move);
    }
예제 #15
0
    public void Open(int heroId)
    {
        HeroData heroData = HeroMgr.GetSingleton().GetHeroData(heroId);

        int[] matnum = JsonMgr.GetSingleton().GetHeroStarByID(heroData.HeroId).matnum;
        //取下一星级需要数量 刚好为当前星级下标
        int needPiece = matnum[heroData.Star];

        Piece_txt.text = heroData.Piece + "/" + needPiece;

        HeroRare officerUp = JsonMgr.GetSingleton().GetHeroRareByID(heroData.Rare);

        Border_img.sprite = ResourceMgr.Instance.LoadSprite(officerUp.HeadBorder);
        Head_img.sprite   = ResourceMgr.Instance.LoadSprite(heroData.JsonData.headid);
        Lv_txt.text       = heroData.Level.ToString();
        //碎片ID为武将ID
        piece_img.sprite  = ResourceMgr.Instance.LoadSprite(heroData.HeroId);
        Fighting_txt.text = "12334325";
        Cost_txt.text     = JsonMgr.GetSingleton().GetGlobalIntArrayByID(heroData.Star + StarBegin).value.ToString("N0");

        int showStar = HeroMgr.MaxHeroStar - heroData.Star;

        starImage = HideStar_obj.transform.GetComponentsInChildren <Image>();
        for (int i = 0; i < heroData.Star; ++i)
        {
            starImage[i].transform.SetParent(StarParent_obj.transform);
        }

        CanvasRenderer[] leftStar = leftstar_obj.GetComponentsInChildren <CanvasRenderer>();
        for (int i = 0; i < leftStar.Length; ++i)
        {
            leftStar[i].SetAlpha((i < showStar) ? 0 : 1);
        }
        CanvasRenderer[] rightStar = rightstar_obj.GetComponentsInChildren <CanvasRenderer>();
        for (int i = 0; i < rightStar.Length; ++i)
        {
            rightStar[i].SetAlpha((i < (showStar - 1)) ? 0 : 1);
        }

        EventListener.Get(Canel_btn.gameObject).OnClick = e =>
        {
            UIFace.GetSingleton().Close(UIID.HeroStarUp);
        };
        EventListener.Get(StarUp_btn.gameObject).OnClick = e =>
        {
            if (heroData.Piece < needPiece)
            {
                CanvasView.Instance.AddNotice("碎片不足");
                return;
            }
            Close();
            //服务器处理升星逻辑 客户端暂代
            int expend = Mathf.RoundToInt(JsonMgr.GetSingleton().GetGlobalIntArrayByID(heroData.Star + StarBegin).value);
            Role.Instance.Cash -= expend;
            heroData.Piece     -= needPiece;
            heroData.Star++;
            ZEventSystem.Dispatch(EventConst.REFRESHSIDE, false);
            if (heroData.Star == HeroMgr.MaxHeroStar)
            {
                UIFace.GetSingleton().Close(UIID.HeroStarUp);
                return;
            }
            Open(heroId);
        };
        EventListener.Get(piece_img.gameObject).OnClick = e =>
        {
            UIFace.GetSingleton().Open(UIID.HeroGoto, heroId);
        };
    }
예제 #16
0
    public void StartFight(int id)
    {
        Client.Instance.Send(Msg.ServerMsgId.CCMD_BATTLE_BEGIN, null);

        List <FightUnit>  ownFighter = new List <FightUnit>();
        List <Vector2Int> stubData   = Role.Instance.GetStubData(StubType.PVE);

        List <FightUnit> enemy  = new List <FightUnit>();
        List <FightUnit> enemy1 = new List <FightUnit>();
        List <FightUnit> enemy2 = new List <FightUnit>();

        for (int idx = 0; idx < stubData.Count; ++idx)
        {
            JsonData.Hero heroJson = JsonMgr.GetSingleton().GetHeroByID(stubData[idx].y);
            FightUnit     fighter  = new FightUnit(HeroMgr.GetSingleton().GetHeroData(heroJson.ID), stubData[idx].x, false);
            ownFighter.Add(fighter);
        }

        LevelData leveldata = JsonMgr.GetSingleton().GetLevel(id);
        var       monsters  = JsonMgr.GetSingleton().GetMonstersArray();

        for (int idx1 = 0; idx1 < monsters.Length; idx1++)
        {
            for (int idx2 = 0; idx2 < monsters[idx1].monster.Length; idx2++)
            {
                switch (idx1)
                {
                case 0:
                    FightUnit fighter = new FightUnit(JsonMgr.GetSingleton().GetMonsterByID(monsters[idx1].monster[idx2]), monsters[idx1].position[idx2], true);
                    enemy.Add(fighter);
                    break;

                case 1:
                    FightUnit fighter1 = new FightUnit(JsonMgr.GetSingleton().GetMonsterByID(monsters[idx1].monster[idx2]), monsters[idx1].position[idx2], true);
                    enemy1.Add(fighter1);
                    break;

                case 2:
                    FightUnit fighter2 = new FightUnit(JsonMgr.GetSingleton().GetMonsterByID(monsters[idx1].monster[idx2]), monsters[idx1].position[idx2], true);
                    enemy2.Add(fighter2);
                    break;
                }
            }
        }
        List <List <FightUnit> > enemyFighter = new List <List <FightUnit> >()
        {
            enemy, enemy1, enemy2
        };

        FightLogic.Instance.Clear();
        FightLogic.Instance.SetFightUnit(ownFighter, enemyFighter);

        switch (SectionKey)
        {
        case 0:
            for (int i = 0; i < Genlevel[SectionKey][SectionChapter].GenStage.Count; i++)
            {
                if (Genlevel[SectionKey][SectionChapter].GenStage[i].LevelID == id)
                {
                    if (Genlevel[SectionKey][SectionChapter].GenStage[i].ResidueTime > 0)
                    {
                        Genlevel[SectionKey][SectionChapter].GenStage[i].ResidueTime--;
                        isOff = true;
                        SceneMgr.Instance.LoadScene("Game");
                    }
                    else
                    {
                        CanvasView.Instance.AddNotice("次数不足");
                        break;
                    }
                }
            }

            break;

        case 1:
            for (int i = 0; i < Genlevel[SectionKey][SectionChapter].GenStage.Count; i++)
            {
                if (Genlevel[SectionKey][SectionChapter].GenStage[i].LevelID == id)
                {
                    if (Genlevel[SectionKey][SectionChapter].GenStage[i].ResidueTime > 0)
                    {
                        Genlevel[SectionKey][SectionChapter].GenStage[i].ResidueTime--;
                        isOff = true;
                        SceneMgr.Instance.LoadScene("Game");
                    }
                    else
                    {
                        Debug.Log("次数不足");
                        break;
                    }
                }
            }
            break;

        case 2:
            for (int i = 0; i < Genlevel[SectionKey][SectionChapter].GenStage.Count; i++)
            {
                if (Genlevel[SectionKey][SectionChapter].GenStage[i].LevelID == id)
                {
                    if (Genlevel[SectionKey][SectionChapter].GenStage[i].ResidueTime > 0)
                    {
                        Genlevel[SectionKey][SectionChapter].GenStage[i].ResidueTime--;
                        isOff = true;
                        SceneMgr.Instance.LoadScene("Game");
                    }
                    else
                    {
                        Debug.Log("次数不足");
                        break;
                    }
                }
            }
            break;
        }
    }
예제 #17
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();
    }
예제 #18
0
    private void SetAdvancedView()
    {
        int[] targets = equip.JsonData.Advanced;
        int   target  = PlayerPrefs.GetInt("advancedtarget");

        //处理紫升橙
        if (targets.Length > 1)
        {
            bool has = false;
            for (int i = 0; i < targets.Length; ++i)
            {
                if (targets[i] == target)
                {
                    has = true;
                }
            }
            if (target != 0 && has)
            {
                advancedequip_img.raycastTarget = true;
                target_img.raycastTarget        = false;
                EventListener.Get(advancedequip_img.gameObject).OnClick = e =>
                {
                    attr_obj.SetActive(false);
                    null_obj.SetActive(true);
                    for (int i = 0, length = parent_trf.childCount; i < length; ++i)
                    {
                        DestroyImmediate(parent_trf.GetChild(0).gameObject);
                    }
                    target = 0;
                    PlayerPrefs.SetInt("advancedtarget", 0);
                    UIFace.GetSingleton().Open(UIID.EuqipTipCtrl, targets);
                };
            }
            else
            {
                advancedequip_img.gameObject.SetActive(false);
                advancedborder_img.gameObject.SetActive(false);
                target_img.gameObject.SetActive(true);
                attr_obj.SetActive(false);
                null_obj.SetActive(true);
                target_img.raycastTarget        = true;
                advancedequip_img.raycastTarget = false;

                EventListener.Get(target_img.gameObject).OnClick = e =>
                {
                    PlayerPrefs.SetInt("advancedtarget", 0);
                    UIFace.GetSingleton().Open(UIID.EuqipTipCtrl, targets);
                };
                return;
            }
        }
        else if (targets.Length == 0)
        {
            advancedequip_img.gameObject.SetActive(false);
            advancedborder_img.gameObject.SetActive(false);
            target_img.gameObject.SetActive(true);
            attr_obj.SetActive(false);
            null_obj.SetActive(true);
            target_img.raycastTarget        = true;
            advancedequip_img.raycastTarget = false;
            EventListener.Get(target_img.gameObject).OnClick = e =>
            {
                CanvasView.Instance.AddNotice("当前装备已进阶至最大等级");
            };
            return;
        }
        else
        {
            advancedequip_img.raycastTarget = false;
            target = targets[0];
        }

        advancedequip_img.gameObject.SetActive(true);
        advancedborder_img.gameObject.SetActive(true);
        target_img.gameObject.SetActive(false);
        attr_obj.SetActive(true);
        null_obj.SetActive(false);
        AdvancedSpend aspend = JsonMgr.GetSingleton().GetAdvancedSpendByID(target);

        SetSpendView(aspend);
        EventListener.Get(advanced_btn.gameObject).OnClick = e =>
        {
            if (equip.JsonData.Advanced.Length == 0)
            {
                CanvasView.Instance.AddNotice("当前装备已进阶至最大等级");
                return;
            }
            else if (equip.StrengthenLv < equip.JsonData.AdvancedCondition)
            {
                CanvasView.Instance.AddNotice(string.Format("进阶失败!需要强化等级达到{0},才能继续进阶。", equip.JsonData.AdvancedCondition));
                return;
            }
            else if (target == 0)
            {
                return;
            }
            for (int i = 0, length = parent_trf.childCount; i < length; ++i)
            {
                DestroyImmediate(parent_trf.GetChild(0).gameObject);
            }

            equip.EquipId = target;
            SetAdvancedView();
            HeroData hero = HeroMgr.GetSingleton().GetHeroData(equip.HeroId);
            if (hero == null)
            {
                return;
            }
            hero.ClearEquipAttr();
            ZEventSystem.Dispatch(EventConst.REFRESHRIGHT);
        };
        StringBuilder sb = new StringBuilder();

        Pro[] p = equip.Attribute;
        for (int i = 0, length = p.Length; i < length; ++i)
        {
            sb.Append(AttrUtil.GetAttribute(p[i].attr));
            sb.Append(": +");
            sb.Append(AttrUtil.ShowText(p[i].attr, equip.JsonData.Attribute[i].num + p[i].num, equip.JsonData.Attribute[i].per + p[i].per));
            sb.Append("\n");
        }
        name_txt.supportRichText = true;
        string color = ColorMgr.Colors[equip.ItemData.rare - 1];

        name_txt.text     = string.Format("<color=#{0}>{1}{2}</color>", color, equip.JsonData.Name, equip.StrengthenLv > 0 ? "  +" + equip.StrengthenLv : "");
        baseattr_txt.text = string.Format("<color=#{0}>{1}</color>", color, sb);

        Equip         q      = JsonMgr.GetSingleton().GetEquipByID(target);
        StringBuilder append = new StringBuilder();

        p = q.Attribute;
        for (int i = 0, length = p.Length; i < length; ++i)
        {
            append.Append(AttrUtil.GetAttribute(p[i].attr));
            append.Append(": +");
            append.Append(AttrUtil.ShowText(p[i].attr, p[i].num + p[i].num * equip.StrengthenLv, p[i].per + p[i].per * equip.StrengthenLv));
            append.Append("\n");
        }
        ItemConfig ic = JsonMgr.GetSingleton().GetItemConfigByID(target);

        color = ColorMgr.Colors[ic.rare - 1];
        advanced_txt.supportRichText = true;
        advanced_txt.text            = string.Format("<color=#{0}>{1}{2}</color>", color, q.Name, equip.StrengthenLv > 0 ? "  +" + equip.StrengthenLv : "");
        advancedattr_txt.text        = string.Format("<color=#{0}>{1}</color>", color, append);
        sb     = null;
        append = null;
    }
예제 #19
0
    public void BuildHeroEvent(int heroId)
    {
        if (showID == heroId)
        {
            return;
        }
        if (Herotf != null)
        {
            Destroy(Herotf.gameObject);
        }
        Vector3 v3 = billboard.GetCamPos();

        v3.y           += -1.45f;
        v3.z           += 10f;
        billboard.Layer = LayerMask.NameToLayer("Hero");
        HeroData data = HeroMgr.GetSingleton().GetHeroData(heroId);

        GameObject heroGo = ResourceMgr.Instance.LoadResource(data.JsonData.resid) as GameObject;

        if (heroGo == null)
        {
            return;
        }
        heroGo = Instantiate(heroGo);
        Herotf = heroGo.transform;
        Herotf.localPosition = v3;
        int horseid = data.JsonData.horseid;

        if (horseid != 0)
        {
            GameObject horseGo = ResourceMgr.Instance.LoadResource(horseid) as GameObject;
            if (horseGo == null)
            {
                EDebug.LogError("加载马匹资源失败 -- " + horseid);
                return;
            }
            horseGo = Instantiate(horseGo, heroGo.transform, false);
            horseGo.transform.localPosition = Vector3.zero;
            horseGo.transform.localScale    = Vector3.one;
        }
        HeroShow hs = JsonMgr.GetSingleton().GetHeroShowByID(heroId);
        Vector3  vc = billboard.Cam.transform.eulerAngles;

        vc.x = hs.RotX;
        Quaternion qc = new Quaternion
        {
            eulerAngles = vc
        };

        billboard.Cam.transform.rotation = qc;
        Vector3 vh = heroGo.transform.localEulerAngles;

        vh.y = hs.RotY + +180f;
        Quaternion qh = new Quaternion
        {
            eulerAngles = vh
        };

        heroGo.transform.rotation = qh;
        billboard.Fov             = hs.Fov;
        showID = heroId;
        heroGo.SetLayer("Hero");
        player = heroGo.AddComponent <AnimatorPlayer>();
        player.RandomPlay(true);
    }
예제 #20
0
    public void ShowLeft()
    {
        Name_txt.text = heroData.JsonData.name;

        show_txt.text = heroData.Officer > 0 ? JsonMgr.GetSingleton().GetOfficerByID(heroData.Officer).Post : "";

        //需要获取武将官阶的官职列表并对dd赋值

        int[] unlock = JsonMgr.GetSingleton().GetHeroRareByID(heroData.Rare).UnLock;

        for (int i = 0; i < officerText.Length; ++i)
        {
            if (i >= unlock.Length)
            {
                officerText[i].text = "";
                continue;
            }
            Officer o   = JsonMgr.GetSingleton().GetOfficerByID(unlock[i]);
            string  txt = officerText[i].text = o.Post;

            EventListener.Get(officerText[i].gameObject).OnClick = e =>
            {
                show_txt.text = txt;
                ShowPopList(null);
                HeroMgr.GetSingleton().TakeOfficer(heroData, o.ID);
                if (showType == EHEROSHOWTYPE.Detail)
                {
                    ShowDetail();
                }
            };
        }
        Vector2 size = scrollRect.content.sizeDelta;

        size.y = unlock.Length * 53;
        scrollRect.content.sizeDelta        = size;
        EventListener.Get(hero_obj).OnClick = e =>
        {
            if (player != null && !player.IsPlaying)
            {
                player.RandomPlay(true);
            }
        };
        EventListener.Get(hero_obj).BegineDragEvent = e =>
        {
            previousX = Input.mousePosition.x;
        };
        EventListener.Get(hero_obj).DragEvent = e =>
        {
            offset    = previousX - Input.mousePosition.x;
            previousX = Input.mousePosition.x;
            Herotf.Rotate(Vector3.up, offset * scale, Space.Self);
        };
        HeroEquipView hev = Equip_obj.GetComponent <HeroEquipView>();

        hev.SetView(heroData);
        EventListener.Get(Dress_btn.gameObject).OnClick = e =>
        {
            EquipData[] equips = heroData.GetEquip();
            for (int i = 0; i < equips.Length; ++i)
            {
                EquipData data = equips[i];
                if (data == null)
                {
                    string    md5   = EquipMgr.GetSingleton().TestCanDress((EquipPart)i + 1, heroData);
                    EquipData equip = EquipMgr.GetSingleton().GetEquipDataByUID(md5);
                    if (equip != null)
                    {
                        EquipMgr.GetSingleton().TakeEquip(equip, heroData);
                        hev.SetView(heroData);
                    }
                }
            }
        };
        EventListener.Get(Intensify_btn.gameObject).OnClick = e =>
        {
            EquipData[] equips = heroData.GetEquip();
            bool        canUp  = false;
            for (int i = 0; i < equips.Length; ++i)
            {
                EquipData data = equips[i];
                if (data == null || data.StrengthenLv == HeroMgr.MaxHeroLevel)
                {
                    continue;
                }
                canUp = true;
                EquipMgr.GetSingleton().UpEquip(data);
                hev.SetView(heroData);
            }
            if (!canUp)
            {
                CanvasView.Instance.AddNotice("暂时没有可强化装备");
            }
        };
    }
예제 #21
0
    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();
        }
    }
예제 #22
0
    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);
    }
예제 #23
0
    /// <summary>
    /// 初始化头像
    /// </summary>
    public void Init()
    {
        Level_txt.text = Role.Instance.Level.ToString();
        Exp_txt.text   = Role.Instance.Exp.ToString();
        Name_txt.text  = Role.Instance.RoleName;
        if (ct == null)
        {
            HaveClear    = HaveClear_trf.GetComponent <GridLayoutGroup>();
            NotClear     = NotClears_trf.GetComponent <GridLayoutGroup>();
            HaveRect     = Have_trf as RectTransform;
            NotClearRect = NotClear_trf as RectTransform;
            Control      = Control_obj.transform as RectTransform;

            ct        = GameObject.Find("HeroParent").transform;
            grid      = Clear_trf.GetComponent <GridLayoutGroup>();
            Mask_rect = Mask_trf.transform as RectTransform;
            Clear     = Clear_trf.transform as RectTransform;
        }
        if (ct.childCount > 0)
        {
            for (int i = 0, length = ct.childCount; i < length; ++i)
            {
                Destroy(ct.GetChild(0).gameObject);
            }
        }
        GameObject heroGo = ResourceMgr.Instance.LoadResource(ID) as GameObject;

        if (heroGo == null)
        {
            return;
        }
        heroGo = Instantiate(heroGo, ct, false);
        Hreo   = heroGo.transform;
        heroGo.transform.localPosition = new Vector3(0, -1, 0);
        heroGo.transform.localScale    = new Vector3(2f, 2f, 2f);
        heroGo.SetLayer("Hero");
        EventListener.Get(RawImage_obj).BegineDragEvent = e =>
        {
            previousX = Input.mousePosition.x;
        };
        EventListener.Get(RawImage_obj).DragEvent = e =>
        {
            offset    = previousX - Input.mousePosition.x;
            previousX = Input.mousePosition.x;
            heroGo.transform.Rotate(Vector3.up, offset * Time.deltaTime, Space.Self);
        };


        Hreo.transform.localRotation = new Quaternion(0, 0, 0, 0);

        Portrait_img.sprite = ResourceMgr.Instance.LoadSprite(Role.Instance.HeadId);


        //头像
        allHero = HeroMgr.GetSingleton().Heros;
        if (allHero.Length > PortraitList.Count)
        {
            for (int idx = 0; idx < allHero.Length; idx++)
            {
                if (idx > PortraitList.Count)
                {
                    GameObject         majesty     = InitItemInfo(true, Clear_trf);
                    PortraitCircleView majestyview = majesty.GetComponent <PortraitCircleView>();
                    majestyview.Init();
                    if (idx > 10)
                    {
                        majestyview.Endow(allHero[idx].HeroId, false);
                    }
                    else
                    {
                        majestyview.Endow(allHero[idx].HeroId, true);
                    }
                    PortraitList.Add(majestyview);
                }
            }
        }

        SelectSort();
    }