public void SetInfo(int headid, string playername, int herocnt, string corpsName, Dictionary <int, int> stubData,
                        bool isPvp = false, int arenaRank = 0, int arenaWin = 0)
    {
        //TODO:headid
        this.name_txt.text      = playername;
        this.herocnt_txt.text   = herocnt.ToString();
        this.corpsname_txt.text = corpsName;
        foreach (var p in _stubui)
        {
            p.Value.sprite = StubEmpty;
        }
        foreach (var p in stubData)
        {
            if (_stubui.ContainsKey(p.Key))
            {
                JsonData.Hero heroData = JsonMgr.GetSingleton().GetHeroByID(p.Value);
                _stubui[p.Key].sprite = ResourceMgr.Instance.LoadSprite(heroData.headid);
            }
            else
            {
                EDebug.LogErrorFormat("PlayerInfoDetailView.SetInfo failed, _stubui doesn't contains stubpos {0}", p.Key);
            }
        }

        this.arena_obj.SetActive(isPvp);

        if (isPvp)
        {
            this.arenarank_txt.text = arenaRank.ToString();
            this.arenawin_txt.text  = arenaWin.ToString();
        }
    }
Пример #2
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);
            }
        }
    }
Пример #3
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;
        }
    }