Exemplo n.º 1
0
    public void Show(StageTemplate stageT)
    {
        if (stageT == null)
        {
            Debug.LogError("关卡数据为null");
            return;
        }

        mStageT = stageT;

        //-----------------星级----------------;
        StageData sd      = ObjectSelf.GetInstance().BattleStageData.GetStageDataByStageId(stageT.m_stageid);
        int       starNum = 0;

        if (sd != null)
        {
            starNum = sd.m_StageStar;
        }

        for (int i = 0; i < 3; i++)
        {
            StarImgs[i].gameObject.SetActive(i < starNum);
        }

        int stageNum  = StageModule.GetStageNumInChapter(stageT);
        int chapterId = StageModule.GetChapterinfoIdByStageId(stageT.GetID());

        m_ChapterNameTxt.text = string.Format(GameUtils.getString("chapter_title"), GameUtils.ConverIntToString(chapterId));
        m_StageNameTxt.text   = string.Format(GameUtils.getString("guanqia_mingzi"), stageNum, GameUtils.getString(stageT.m_stagename));
        m_StageDescTxt.text   = GameUtils.getString(stageT.m_stageinfo);

        m_ResourceCount1.text = stageT.m_playerexp.ToString();
        m_ResourceCount2.text = stageT.m_goldreward.ToString();

        if (stageT.m_expcrystal == -1)
        {
            ResouceObj3.SetActive(false);
        }
        else
        {
            ResouceObj3.SetActive(true);
            m_ResourceCount3.text = stageT.m_expcrystal.ToString();
        }

        EM_STAGE_DIFFICULTTYPE difficultType = StageModule.GetStageDifficultType(stageT);
        string difficultStr = "";

        switch (difficultType)
        {
        case EM_STAGE_DIFFICULTTYPE.NONE:
            break;

        case EM_STAGE_DIFFICULTTYPE.NORMAL:
            difficultStr = GameUtils.getString("chapter_difficult_type1");
            break;

        case EM_STAGE_DIFFICULTTYPE.HARD:
            difficultStr = GameUtils.getString("chapter_difficult_type2");
            break;

        case EM_STAGE_DIFFICULTTYPE.HARDEST:
            difficultStr = GameUtils.getString("chapter_difficult_type2");
            break;

        default:
            break;
        }

        //-------------------关卡挑战次数--------------------
        //无限制;
        if (stageT.m_limittime < 0)
        {
            SetRapidObjActive(false);
        }
        else
        {
            SetRapidObjActive(true);
            int remineTimes = Mathf.Max(0, stageT.m_limittime - sd.m_FightSum);

            TEXT_COLOR tc = TEXT_COLOR.WHITE;
            if (remineTimes > 0)
            {
                tc = TEXT_COLOR.WHITE;
                m_ResetBtn.gameObject.SetActive(false);
            }
            else
            {
                m_ResetBtn.gameObject.SetActive(true);
                tc = TEXT_COLOR.RED;
            }
            m_RemindTimeTxt.text = GameUtils.getString("fight_fightprepare_content3") + GameUtils.StringWithColor(remineTimes.ToString(), tc) + "/" + stageT.m_limittime;
        }

        m_DifficultTxt.text = difficultStr;

        //行动力不足颜色标红;
        if (isEnoughPow(mStageT))
        {
            m_ConsumeCountTxt.text = stageT.m_cost.ToString();
        }
        else
        {
            m_ConsumeCountTxt.text = GameUtils.StringWithColor(stageT.m_cost.ToString(), TEXT_COLOR.RED);
        }

        switch (stageT.m_winCondition)
        {
        case 1:
            m_SucessConditionTxt.text = "◆" + GameUtils.getString("System_setting_content28");
            break;

        case 2:
            m_SucessConditionTxt.text = "◆" + string.Format(GameUtils.getString("System_setting_content29"), StageModule.GetBossName(stageT));
            break;
        }
        //--------------------敌方英雄信息------------------;
        for (int i = 0; i < mEnermyList.Count; i++)
        {
            if (mEnermyList[i] != null)
            {
                mEnermyList[i].Destroy();
            }
        }
        mEnermyList.Clear();

        List <MonsterTemplate> _BossTemp    = new List <MonsterTemplate>();
        List <MonsterTemplate> _MonsterTemp = new List <MonsterTemplate>();

        for (int i = 0, j = stageT.m_displayMonster.Length; i < j; i++)
        {
            MonsterTemplate _monster = (MonsterTemplate)DataTemplate.GetInstance().m_MonsterTable.getTableData(stageT.m_displayMonster[i]);
            if (_monster.getMonstertype() == 2)
            {
                _BossTemp.Add(_monster);
            }
            else
            {
                _MonsterTemp.Add(_monster);
            }
        }

        for (int i = 0; i < _BossTemp.Count; ++i)
        {
            UniversalItemCell cell = UniversalItemCell.GenerateItem(EnermyListTrans);
            cell.InitByID(_BossTemp[i].getId());
            cell.SetSize(UniversalItemCell.UniversalItemSize.Type_114);
            cell.SetCount("BOSS");
            cell.AddClickListener(OnClickUniversalHeroHandler);
            mEnermyList.Add(cell);
        }

        for (int i = 0; i < _MonsterTemp.Count; i++)
        {
            UniversalItemCell cell = UniversalItemCell.GenerateItem(EnermyListTrans);
            cell.InitByID(_MonsterTemp[i].getId());
            cell.SetSize(UniversalItemCell.UniversalItemSize.Type_114);
            cell.AddClickListener(OnClickUniversalHeroHandler);
            //cell.SetCount("BOSS");
            mEnermyList.Add(cell);
        }

        //--------------------关卡掉落展示------------------;
        for (int i = 0; i < mItemsList.Count; i++)
        {
            if (mItemsList[i] != null)
            {
                mItemsList[i].Destroy();
            }
        }
        mItemsList.Clear();

        string displaydrop = stageT.m_displaydrop;

        if (displaydrop == "-1" || string.IsNullOrEmpty(displaydrop))
        {
        }
        else
        {
            string[] displaydropList = displaydrop.Split('#');
            if (displaydropList.Length == 0)
            {
                return;
            }

            for (int i = 0; i < displaydropList.Length; i++)
            {
                UniversalItemCell cell = UniversalItemCell.GenerateItem(ItemListTrans);
                cell.SetSize(UniversalItemCell.UniversalItemSize.Type_114);
                cell.AddClickListener(OnClickUniversalItemHandler);
                string[] itemList = displaydropList[i].Split('-');
                switch (int.Parse(itemList[0]))
                {
                case 1:
                    int itemid = int.Parse(itemList[1]);
                    if (int.Parse(itemList[2]) == 0)
                    {
                        //几率掉落;
                        cell.InitByID(itemid);
                        cell.SetText(null, GameUtils.getString("fight_stageselect_content3"), null);
                    }
                    else
                    {
                        //一定掉落;
                        int count = System.Convert.ToInt32(itemList[3]);
                        cell.InitByID(itemid, count);
                    }
                    break;

                case 2:
                    if (int.Parse(itemList[2]) == 0)
                    {
                        cell.InitBySprite(UIResourceMgr.LoadSprite(common.defaultPath + itemList[1]));
                        cell.SetText(null, GameUtils.getString("fight_stageselect_content3"), null);
                    }
                    else
                    {
                        int count = System.Convert.ToInt32(itemList[3]);
                        cell.InitBySprite(UIResourceMgr.LoadSprite(common.defaultPath + itemList[1]), count);
                    }
                    break;

                default:
                    break;
                }

                mItemsList.Add(cell);
            }
        }
    }