Exemple #1
0
    void CreateItem(int tableId, string count, string name)
    {
        UniversalItemCell _cell = UniversalItemCell.GenerateItem(listObj.transform);

        _cell.transform.localScale = Vector3.one;
        _cell.InitByID(tableId, int.Parse(count));
        _cell.SetText(GameUtils.getString(name), null, null);
        _cell.AddClickListener(OnItemClick);
        itemsList.Add(_cell);
    }
Exemple #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);
            }
        }
    }
Exemple #3
0
    public void ShowInnerDrop(List <int> innerdropIDList)
    {
        for (int i = 0; i < innerdropIDList.Count; i++)
        {
            UniversalItemCell m_Cell = UniversalItemCell.GenerateItem(listObj.transform);

            InnerdropTemplate value = (InnerdropTemplate)DataTemplate.GetInstance().m_InnerdropTable.getTableData(innerdropIDList[i]);
            if (value == null)
            {
                return;
            }

            int itemid = value.getObjectid();//掉落物ID
            int type   = value.getObjectid() / 1000000;
            m_Cell.AddClickListener(OnItemClick);

            switch (type)
            {
            case (int)EM_OBJECT_CLASS.EM_OBJECT_CLASS_RES:
                ResourceindexTemplate _temp_res = (ResourceindexTemplate)DataTemplate.GetInstance().m_ResourceindexTemplate.getTableData(itemid);
                if (_temp_res != null)
                {
                    m_Cell.InitByID(itemid, value.getDropnum());
                    m_Cell.SetText(GameUtils.getString(_temp_res.getName()), "", "");
                }
                break;

            case (int)EM_OBJECT_CLASS.EM_OBJECT_CLASS_RUNE:     //符文
            {
                ItemTemplate itemTable = (ItemTemplate)DataTemplate.GetInstance().m_ItemTable.getTableData(itemid);
                if (itemTable != null)
                {
                    m_Cell.InitByID(itemid, -1);
                    m_Cell.SetText(GameUtils.getString(itemTable.getName()), "", "");
                }
            }
            break;

            case (int)EM_OBJECT_CLASS.EM_OBJECT_CLASS_COMMON:
            {
                ItemTemplate itemTable = (ItemTemplate)DataTemplate.GetInstance().m_ItemTable.getTableData(itemid);
                if (itemTable != null)
                {
                    m_Cell.InitByID(itemid, value.getDropnum());
                    m_Cell.SetText(GameUtils.getString(itemTable.getName()), "", "");
                }
            }
            break;

            case (int)EM_OBJECT_CLASS.EM_OBJECT_CLASS_HERO:
            {
                HeroTemplate hero = (HeroTemplate)DataTemplate.GetInstance().m_HeroTable.getTableData(itemid);
                if (hero != null)
                {
                    m_Cell.InitByID(itemid, value.getDropnum());
                    m_Cell.SetText(GameUtils.getString(hero.getTitleID()), "", "");
                }
            }
            break;

            default:
                break;
            }
        }
    }
        //public bool isReward(int difficulttype, int rewardnum)
        //{
        //    int reward = 0;
        //    if (difficulttype == 1)
        //    {
        //        reward = rewardnum % 10;
        //    }
        //    else if (difficulttype == 2)
        //    {
        //        reward = rewardnum % 100 / 10;
        //    }
        //    else if (difficulttype == 3)
        //    {
        //        reward = rewardnum / 100;
        //    }
        //    return reward != 0;
        //}

        public void UpdateShow()
        {
            //Debug.Log(mGrid.transform.position);
            //mGrid.transform.position = new Vector3(-225.4f, -4.7f, -263.4f);
            //与服务器交互显示所得物品
            //UI_SelectFightArea sfight = UI_SelectFightArea.Inst;
            int chapterId   = ObjectSelf.GetInstance().GetCurChapterID();
            int difficultLv = ObjectSelf.GetInstance().CurChapterLevel;
            ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(chapterId);

            if (chapterT != null)
            {
                int total    = 0;
                int curstart = 0;

                StageModule.GetCurTotalStarsCount(chapterT, (EM_STAGE_DIFFICULTTYPE)difficultLv, out curstart, out total);

                if (curstart >= total)
                {
                    //TODO 宝箱弹窗
                    //if (isReward(difficultLv, sfight.iTotalCharpter[sfight.iChapterID].m_bRewardGot))
                    if (StageModule.isReward(difficultLv, ObjectSelf.GetInstance().BattleStageData.GetRewardGot(chapterId)))
                    {
                        mHeader.text = GameUtils.getString("fight_bosbox_content");
                        mCloseImage.overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "Ui_xuanze");
                        //mCloseText.text = "关  闭";
                        mCloseText.text = GameUtils.getString("common_button_close");
                    }
                    else
                    {
                        mHeader.text = GameUtils.getString("sign_content5");
                        mCloseImage.overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "Ui_xuanze");
                        //mCloseText.text = "领  取";
                        mCloseText.text = GameUtils.getString("common_button_receive");
                    }
                }
                else
                {
                    mHeader.text = GameUtils.getString("fight_bosbox_content");
                    mCloseImage.overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "Ui_xuanze");
                    //mCloseText.text = "关  闭";
                    mCloseText.text = GameUtils.getString("common_button_close");
                }
                innerdropIDList.Clear();
                //int[] chapterDropList = ((ChapterinfoTemplate)DataTemplate.GetInstance().m_ChapterTable.getTableData(sfight.iChapterID)).getChapterDrop();
                //int chapterDropID = chapterDropList[difficultLv - 1];
                //int[] innerdropList = ((NormaldropTemplate)DataTemplate.GetInstance().m_NormaldropTable.getTableData(chapterDropID)).getInnerdrop();
                //Dictionary<int, IExcelBean> innerIExcel = DataTemplate.GetInstance().m_InnerdropTable.getData();
                ////List<InnerdropTemplate> innerdropIDList = new List<InnerdropTemplate>();
                //for (int i = 0; i < innerdropList.Length; i++)
                //{
                //    foreach (var item in innerIExcel.Values)
                //    {
                //        if (((InnerdropTemplate)item).getInnerdropid() == innerdropList[i])
                //        {
                //            innerdropIDList.Add((InnerdropTemplate)item);
                //        }
                //    }
                //}

                //ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(ObjectSelf.GetInstance().GetCurChapterID());
                //if (chapterT == null)
                //{
                //    LogSystem.LogManager.LogToFile("战斗奖励界面失败---ChapterinfoTemplate is NULL. id=" + chapterId);
                //    return;
                //}
                int dropId = difficultLv - 1;

                if (chapterT.getChapterDrop().Length <= 0)
                {
                    LogSystem.LogManager.LogToFile("战斗奖励界面失败---ChapterinfoTemplate 中章节掉落包数组是空的. id=" + chapterId);
                    return;
                }

                int chapterDropId          = chapterT.getChapterDrop()[dropId];
                NormaldropTemplate normalT = DataTemplate.GetInstance().GetNormaldropTemplateById(chapterDropId);
                if (normalT == null)
                {
                    LogSystem.LogManager.LogToFile("战斗奖励界面失败---ChapterinfoTemplate is NULL. id=" + chapterDropId);
                    return;
                }
                int[] innerDropList = normalT.getInnerdrop();
                for (int i = 0, j = innerDropList.Length; i < j; i++)
                {
                    foreach (int k in DataTemplate.GetInstance().m_InnerdropTable.GetDataKeys())
                    {
                        InnerdropTemplate _it = (InnerdropTemplate)DataTemplate.GetInstance().m_InnerdropTable.getTableData(k);

                        if (_it == null)
                        {
                            continue;
                        }

                        if (_it.getInnerdropid() == innerDropList[i])
                        {
                            innerdropIDList.Add(k);
                        }
                    }
                }
            }
            //char[] sfightList = sfight.iTotalCharpter[sfight.iChapterID].m_bRewardGot.ToString().ToCharArray();
            else
            {
                mCloseImage.overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "Ui_xuanze");
                //mCloseText.text = "关  闭";
                mCloseText.text = GameUtils.getString("common_button_close");
                for (int i = 0; i < UI_SacredAltar._instance.m_FallItemList.Count; i++)
                {
                    //InnerdropTemplate item = (InnerdropTemplate)DataTemplate.GetInstance().m_InnerdropTable.getTableData(UI_SacredAltar._instance.m_FallItemList[i]);
                    //InnerdropTemplate item = DataTemplate.GetInstance().GetInnerdropTemplateById(UI_SacredAltar._instance.m_FallItemList[i]);
                    innerdropIDList.Add(UI_SacredAltar._instance.m_FallItemList[i]);
                }
            }

            for (int i = 0; i < innerdropIDList.Count; i++)
            {
                m_Cell = UniversalItemCell.GenerateItem(mGrid.transform);

                InnerdropTemplate value = (InnerdropTemplate)DataTemplate.GetInstance().m_InnerdropTable.getTableData(innerdropIDList[i]);
                if (value == null)
                {
                    return;
                }

                int itemid = value.getObjectid();//掉落物ID
                int type   = value.getObjectid() / 1000000;
                m_Cell.AddClickListener(ShowItemPreviewUIHandler);

                switch (type)
                {
                case (int)EM_OBJECT_CLASS.EM_OBJECT_CLASS_RES:
                    ResourceindexTemplate _temp_res = (ResourceindexTemplate)DataTemplate.GetInstance().m_ResourceindexTemplate.getTableData(itemid);
                    if (_temp_res != null)
                    {
                        m_Cell.InitByID(itemid, value.getDropnum());
                        m_Cell.SetText(GameUtils.getString(_temp_res.getName()), "", "");
                    }
                    break;

                case (int)EM_OBJECT_CLASS.EM_OBJECT_CLASS_RUNE:     //符文
                {
                    ItemTemplate itemTable = (ItemTemplate)DataTemplate.GetInstance().m_ItemTable.getTableData(itemid);
                    if (itemTable != null)
                    {
                        m_Cell.InitByID(itemid, -1);
                        m_Cell.SetText(GameUtils.getString(itemTable.getName()), "", "");
                    }
                }
                break;

                case (int)EM_OBJECT_CLASS.EM_OBJECT_CLASS_COMMON:
                {
                    ItemTemplate itemTable = (ItemTemplate)DataTemplate.GetInstance().m_ItemTable.getTableData(itemid);
                    if (itemTable != null)
                    {
                        m_Cell.InitByID(itemid, value.getDropnum());
                        m_Cell.SetText(GameUtils.getString(itemTable.getName()), "", "");
                    }
                }
                break;

                case (int)EM_OBJECT_CLASS.EM_OBJECT_CLASS_HERO:
                {
                    HeroTemplate hero = (HeroTemplate)DataTemplate.GetInstance().m_HeroTable.getTableData(itemid);
                    if (hero != null)
                    {
                        m_Cell.InitByID(itemid, value.getDropnum());
                        m_Cell.SetText(GameUtils.getString(hero.getTitleID()), "", "");
                    }
                }
                break;

                default:
                    break;
                }
            }
        }