public void OnClickBtn()
        {
            for (int i = 0; i < objList.Count; i++)
            {
                Destroy(objList[i]);
            }
            objList.Clear();
            //UI_SelectFightArea sfight = UI_SelectFightArea.Inst;
            // char[] sfightList = sfight.iTotalCharpter[sfight.iChapterID].m_bRewardGot.ToString().ToCharArray();
            int difficultLv = ObjectSelf.GetInstance().CurChapterLevel;
            int chapterId   = ObjectSelf.GetInstance().GetCurChapterID();
            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 (total == curstart)
                {
                    //TODO 宝箱弹窗
                    //if (isReward(ObjectSelf.GetInstance().CurChapterLevel, sfight.iTotalCharpter[sfight.iChapterID].m_bRewardGot))
                    if (StageModule.isReward(ObjectSelf.GetInstance().CurChapterLevel, ObjectSelf.GetInstance().BattleStageData.GetRewardGot(chapterId)))
                    {
                        UI_HomeControler.Inst.ReMoveUI(gameObject);
                    }
                    else
                    {
                        //与服务器交互
                        CGetStageReward cStage = new CGetStageReward();
                        cStage.difficulttype = (byte)ObjectSelf.GetInstance().CurChapterLevel;
                        cStage.stageid       = (byte)chapterId;
                        IOControler.GetInstance().SendProtocol(cStage);
                        UI_HomeControler.Inst.ReMoveUI(gameObject);
                    }
                }
                else
                {
                    UI_HomeControler.Inst.ReMoveUI(gameObject);
                }
            }
            else
            {
                UI_HomeControler.Inst.ReMoveUI(gameObject);
            }
        }
    void BoxHandler(int idx)
    {
        ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(mCurChapterId);

        if (chapterT == null)
        {
            Debug.LogError("章节数据错误id=" + mCurChapterId);
            return;
        }

        //是否可以领取;
        int curStars   = 0;
        int totalStars = 0;

        if (StageModule.GetCurTotalStarsCount(chapterT, mDifficutType, out curStars, out totalStars))
        {
            //可领取;
            if (curStars >= chapterT.getStarnum()[idx])
            {
                //判断是否领取了;
                if (ObjectSelf.GetInstance().BattleStageData.GetRewardGot(mCurChapterId, idx))
                {
                    InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("maoxianguanka5"));
                }
                else
                {
                    //与服务器交互
                    CGetStageReward cStage = new CGetStageReward();
                    cStage.stageid = (byte)mCurChapterId;
                    //cStage.difficulttype = (byte)ObjectSelf.GetInstance().CurChapterLevel;

                    //TODO::临时这么写;
                    cStage.difficulttype = (byte)idx;
                    IOControler.GetInstance().SendProtocol(cStage);
                }
            }
            else //不可领取;
            {
                int dropId = chapterT.getChapterDrop()[idx];

                UICommonManager.Inst.ShowRewardBox(dropId, chapterT.getStarnum()[idx]);
            }
        }
    }
Beispiel #3
0
    void UpdateBox(ChapterinfoTemplate chapterT)
    {
        ResetBoxToZero();

        //--------------宝箱--------------
        int curStars   = 0;
        int totalStars = 0;

        if (StageModule.GetCurTotalStarsCount(chapterT, mDifficutType, out curStars, out totalStars))
        {
            m_curTxt.text   = curStars.ToString();
            m_totalTxt.text = "/" + totalStars;

            mScrollBar.value = (float)(curStars) / (float)(totalStars);

            int[] perStars = chapterT.getStarnum();
            for (int i = 0, j = mBoxs.Count; i < j; i++)
            {
                //TODO::是否领取过---章节id,难度,第几个宝箱;
                bool isGot = StageModule.IsRewardGot(mCurChapterId);
                if (curStars >= perStars[i])
                {
                    if (isGot)
                    {
                        mBoxs[i].SetBoxImg(BoxSprite[1]);
                        mBoxs[i].SetEffActive(false);
                    }
                    else
                    {
                        mBoxs[i].SetBoxImg(BoxSprite[0]);
                        mBoxs[i].SetEffActive(true);
                    }
                }
                else
                {
                    //NoOpen;
                    mBoxs[i].SetBoxImg(BoxSprite[0]);
                    mBoxs[i].SetEffActive(false);
                }
                mBoxs[i].SetStarNum(perStars[i]);
            }

            //if (curStars >= totalStars)
            //{
            //    //是否领取过;
            //    bool isGot = StageModule.IsRewardGot(mCurChapterId);
            //    if (isGot)
            //    {
            //        m_BoxImg.sprite = BoxSprite[1];
            //    }
            //    else
            //    {
            //        //宝箱震动;
            //        InvokeRepeating("Shake", mShakeDelay, mShakeRate);

            //        m_BoxImg.sprite = BoxSprite[0];
            //    }
            //}
            //else
            //{
            //    m_BoxImg.sprite = BoxSprite[0];
            //}
        }
        else
        {
            Debug.LogError("数据错误");
        }
    }
    void UpdateBox(ChapterinfoTemplate chapterT)
    {
        //--------------宝箱--------------
        int curStars   = 0;
        int totalStars = 0;

        if (StageModule.GetCurTotalStarsCount(chapterT, mDifficutType, out curStars, out totalStars))
        {
            m_curTxt.text   = curStars.ToString();
            m_totalTxt.text = "/" + totalStars;

            m_SliderFront.SetActive(curStars > 0);
            //m_Slider.value = (float)(curStars) / (float)(totalStars);

            //判断当前星级属于第几个阶段;
            int   stageLv  = StarLvStage(curStars, chapterT.getStarnum());
            float progress = 0f;
            for (int i = 0; i < 3; i++)
            {
                if (i < stageLv)
                {
                    progress += 0.34f;
                }
                else
                {
                    float delta = 0f;
                    if (stageLv <= 0)
                    {
                        delta = (float)(curStars) / (float)(chapterT.getStarnum()[0]);
                    }
                    else
                    {
                        int star = curStars;
                        //for (int m = 0; m < stageLv ; m++)
                        //{
                        //    star -= chapterT.getStarnum()[m];
                        //}
                        star -= chapterT.getStarnum()[stageLv - 1];
                        delta = (float)(star) / (float)(chapterT.getStarnum()[stageLv] - chapterT.getStarnum()[stageLv - 1]);
                    }
                    progress += delta * 0.34f;

                    break;
                }
            }

            m_Slider.value = progress;

            int[] perStars = chapterT.getStarnum();
            for (int i = 0, j = mBoxs.Count; i < j; i++)
            {
                //TODO::是否领取过---章节id,难度,第几个宝箱;
                bool isGot = StageModule.IsRewardGot(mCurChapterId, i);
                if (curStars >= perStars[i])
                {
                    if (isGot)
                    {
                        if (i == 2)
                        {
                            mBoxs[i].SetBoxImg(BoxSprite[3]);
                        }
                        else
                        {
                            mBoxs[i].SetBoxImg(BoxSprite[1]);
                        }
                        mBoxs[i].SetEffActive(false);
                    }
                    else
                    {
                        if (i == 2)
                        {
                            mBoxs[i].SetBoxImg(BoxSprite[2]);
                        }
                        else
                        {
                            mBoxs[i].SetBoxImg(BoxSprite[0]);
                        }
                        mBoxs[i].SetEffActive(true);
                    }
                }
                else
                {
                    if (i == 2)
                    {
                        mBoxs[i].SetBoxImg(BoxSprite[2]);
                    }
                    else
                    {
                        mBoxs[i].SetBoxImg(BoxSprite[0]);
                    }
                    mBoxs[i].SetEffActive(false);
                }
                mBoxs[i].SetStarNum(perStars[i]);
            }

            //if (curStars >= totalStars)
            //{
            //    //是否领取过;
            //    bool isGot = StageModule.IsRewardGot(mCurChapterId);
            //    if (isGot)
            //    {
            //        m_BoxImg.sprite = BoxSprite[1];
            //    }
            //    else
            //    {
            //        //宝箱震动;
            //        InvokeRepeating("Shake", mShakeDelay, mShakeRate);

            //        m_BoxImg.sprite = BoxSprite[0];
            //    }
            //}
            //else
            //{
            //    m_BoxImg.sprite = BoxSprite[0];
            //}
        }
        else
        {
            Debug.LogError("数据错误");
        }
    }
        //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;
                }
            }
        }