Esempio n. 1
0
    public override void InitUIView()
    {
        base.InitUIView();

        ObjectSelf.GetInstance().SetIsPrompt(false);

        //ChapterinfoTemplate ct = DataTemplate.GetInstance().GetChapterTemplateByStageID(1310381000);
        /////
        /////当前所打关卡没有解锁新关卡时,从战斗结算界面回到关卡选择界面时,选中的关卡仍为之前所打的那关,
        /////当前关卡打完后有新关卡解锁,返回关卡选择界面就跳到下一关(困难难度一样如此),若同时解锁了两个
        /////关卡(主线和支线),返回关卡选择界面选中主线关
        /////
        if (NeedSpecialStage)
        {
            InitLevelId = ObjectSelf.GetInstance().BattleStageData.GetSpecialStageData().m_StageID;
        }
        else
        {
            List <int> newStages = ObjectSelf.GetInstance().BattleStageData.GetNewStageList();

            if (newStages != null && newStages.Count > 0)
            {
                DisplayNormal();
            }
            else
            {
                if (ObjectSelf.GetInstance().CurStageID > 0 && StageModule.IsStageLevelById(ObjectSelf.GetInstance().CurStageID))
                {
                    InitLevelId = ObjectSelf.GetInstance().CurStageID;
                }
                else
                {
                    DisplayNormal();
                }
            }
        }

        if (InitLevelId <= 0)
        {
            if (InitChapterId <= 0)
            {
                DisplayNormal();
            }
            else
            {
                ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(InitChapterId);
                if (chapterT == null)
                {
                    DisplayNormal();
                }
                else
                {
                    mDifficutType = EM_STAGE_DIFFICULTTYPE.NORMAL;
                    mCurChapterId = InitChapterId;
                    mCurLevelId   = StageModule.GetLastStageIdInTheChapter(chapterT, mDifficutType);
                }
            }
        }
        else
        {
            StageTemplate stageT = StageModule.GetStageTemplateById(InitLevelId);
            if (stageT == null)
            {
                DisplayNormal();
            }
            else
            {
                mDifficutType = StageModule.GetStageDifficultType(stageT);
                mCurLevelId   = InitLevelId;
                int chapterId = DataTemplate.GetInstance().GetChapterIdByStageT(stageT);
                if (chapterId == -1)
                {
                    Debug.LogError("关卡stageid找不到对应的章节id,stageid=" + InitLevelId);
                }
                else
                {
                    mCurChapterId = chapterId;
                }
            }
        }
        OnNewMapOpenShow();
        Sprite inst = UIResourceMgr.LoadSprite(common.defaultPath + "Ui_guanqiabeijing");

        Dictionary <int, BattleStage> .KeyCollection keycoll = TotalCharpter.Keys;
        foreach (int chapterid in keycoll)
        {
            if (chapterid != 1001)
            {
                ChapterinfoTemplate info = StageModule.GetChapterinfoTemplateById(chapterid);
                if (info != null)
                {
                    //var info = (ChapterinfoTemplate)DataTemplate.GetInstance().m_ChapterTable.getTableData(chapterid);
                    //var info = (ChapterinfoTemplate)table[chapterid];
                    Sprite     pic  = UIResourceMgr.LoadSprite(common.defaultPath + info.getBackgroundPicture());
                    GameObject item = new GameObject("background");
                    if (pic != null)
                    {
                        item.AddComponent <Image>().sprite = Instantiate(pic, Vector3.zero, Quaternion.identity) as Sprite;
                    }
                    else
                    {
                        item.AddComponent <Image>().sprite = Instantiate(inst, Vector3.zero, Quaternion.identity) as Sprite;
                    }
                    item.transform.SetParent(mBgTrans, false);
                }
            }
        }

        Init();

        // 新手引导 100302
        if (GuideManager.GetInstance().isGuideUser&& GuideManager.GetInstance().IsContentGuideID(100302) == false)
        {
            GuideManager.GetInstance().ShowGuideWithIndex(100302);
        }
    }
Esempio n. 2
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);
            }
        }
    }