Esempio 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);
            }
        }
    }
Esempio n. 2
0
    public void SetTemplateData(StageTemplate data, EM_STAGE_STAGETYPE flag = EM_STAGE_STAGETYPE.NONE)
    {
        mStageT = data;

        if (data == null)
        {
            mGo.SetActive(false);
            return;
        }

        //如果是神秘商店特殊处理;
        if (flag == EM_STAGE_STAGETYPE.MYSTERIOUS)
        {
            m_TitleTxt.text = "";

            mStarsImg[0].gameObject.SetActive(false);
            mStarsImg[1].gameObject.SetActive(false);
            mStarsImg[2].gameObject.SetActive(false);

            mIsNewImg.gameObject.SetActive(false);

            //这里data.m_stageid存的是场景id;
            ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(data.m_stageid);
            float[]             val      = chapterT.getShopposition();
            Vector2             pos1     = new Vector2(val[0], val[1]);
            mGo.transform.localPosition = pos1;

            return;
        }

        //不是神秘商店另外处理;
        int chapterId = DataTemplate.GetInstance().GetChapterIdByStageT(data);

        EM_STAGE_TYPE type = StageModule.GetStageType(data);

        switch (type)
        {
        case EM_STAGE_TYPE.MAIN_QUEST1:
        case EM_STAGE_TYPE.MAIN_QUEST2:
        case EM_STAGE_TYPE.MAIN_QUEST3:
            //m_TitleTxt.text = string.Format("{0}-{1}", chapterId, StageModule.GetStageNumInChapter(data));
            m_TitleTxt.text = StageModule.GetStageNumInChapter(data).ToString();
            break;

        case EM_STAGE_TYPE.SIDE_QUEST:
            m_TitleTxt.text = GameUtils.getString("stage_type_branch");
            break;

        //case EM_STAGE_TYPE.SPEC_QUEST:
        // break;
        //case EM_STAGE_TYPE.ACTIVE_QUEST_DIJING:
        // break;
        //case EM_STAGE_TYPE.ACTIVE_QUEST_YANLONG:
        // break;
        //case EM_STAGE_TYPE.LIMIT_TEST:
        // break;
        //case EM_STAGE_TYPE.BOSS_SHOUWANGZHE:
        // break;
        //case EM_STAGE_TYPE.BOSS_CHUANSHUO:
        // break;
        default:
            m_TitleTxt.text = "";
            break;
        }

        //位置;
        Vector2 pos = new Vector2(data.getStageiconposition()[0], data.getStageiconposition()[1]);

        mGo.transform.localPosition = pos;
        m_Icon.sprite = UIResourceMgr.LoadSprite(common.defaultPath + data.m_stageicon);
        m_Icon.SetNativeSize();
        float delta = (float)(data.getStageIconScale()) / 100f;

        m_Icon.transform.localScale = Vector3.one * delta;
        //是否已开启;
        if (ObjectSelf.GetInstance().BattleStageData.IsStageOpen(data.m_stageid))
        {
            GameUtils.SetBtnSpriteGrayState(m_IconBtn, false);
            //星星;
            int starNum = 0;
            if (ObjectSelf.GetInstance().BattleStageData.IsCopyScenePass(data.m_stageid, out starNum))
            {
                for (int i = 0; i < MaxStars; i++)
                {
                    mStarsImg[i].gameObject.SetActive(false);
                }
                //switch (starNum)
                //{
                //    case 0:
                //        mStarsImg[0].gameObject.SetActive(false);
                //        mStarsImg[1].gameObject.SetActive(false);
                //        mStarsImg[2].gameObject.SetActive(false);
                //        break;
                //    case 1:
                //        mStarsImg[0].gameObject.SetActive(true);
                //        mStarsImg[1].gameObject.SetActive(false);
                //        mStarsImg[2].gameObject.SetActive(false);
                //        break;
                //    case 2:
                //        mStarsImg[0].gameObject.SetActive(false);
                //        mStarsImg[1].gameObject.SetActive(true);
                //        mStarsImg[2].gameObject.SetActive(true);
                //        break;
                //    case 3:
                //        mStarsImg[0].gameObject.SetActive(true);
                //        mStarsImg[1].gameObject.SetActive(true);
                //        mStarsImg[2].gameObject.SetActive(true);
                //        break;
                //    default:
                //        mStarsImg[0].gameObject.SetActive(false);
                //        mStarsImg[1].gameObject.SetActive(false);
                //        mStarsImg[2].gameObject.SetActive(false);
                //        break;
                //}
                if (starNum > 0 && starNum <= 3)
                {
                    mStarsImg[starNum - 1].gameObject.SetActive(true);
                }
            }
            else
            {
                mStarsImg[0].gameObject.SetActive(false);
                mStarsImg[1].gameObject.SetActive(false);
                mStarsImg[2].gameObject.SetActive(false);
            }
        }
        else
        {
            GameUtils.SetBtnSpriteGrayState(m_IconBtn, true);
            mStarsImg[0].gameObject.SetActive(false);
            mStarsImg[1].gameObject.SetActive(false);
            mStarsImg[2].gameObject.SetActive(false);
        }

        //是否限制次数关卡;
        if (data.m_limittime > 0)
        {
            StageData sd = ObjectSelf.GetInstance().BattleStageData.GetStageDataByStageId(data.m_stageid);

            int useTimes = sd == null ? 0 : sd.m_FightSum;

            mRemindTimes.text = (data.m_limittime - useTimes).ToString();

            mRemindTitle.gameObject.SetActive(true);
        }
        else
        {
            mRemindTitle.gameObject.SetActive(false);
        }

        //是否是新开启的关卡;
        UpdateIsNew();
    }