//protected override void OnClickWorldMap() //{ // UI_HomeControler.Inst.AddUI(UI_WordMap.UI_ResPath); // UI_HomeControler.Inst.ReMoveUI(UI_SelectLevelMgr.UI_ResPath); // UI_WorldMapManage._instance.WorldMapShow(); //} /// <summary> /// 判断当前章节,某个难度的关卡是否通关; /// </summary> /// <param name="chapterId"></param> /// <param name="type"></param> /// <returns></returns> bool CheckPrevStageIsPass(int chapterId, EM_STAGE_DIFFICULTTYPE type, out int prevStageId) { ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(chapterId); prevStageId = -1; if (chapterT != null) { int stageId = StageModule.GetFirstStageIdInTheChapter(chapterT, type); StageTemplate st = StageModule.GetStageTemplateById(stageId); prevStageId = st.m_premissionid; ///前置关卡为-1时,表示不需要前置关卡,直接开启; if (prevStageId == -1) { return(true); } int star = -1; if (ObjectSelf.GetInstance().BattleStageData.IsCopyScenePass(prevStageId, out star)) { if (star > 0) { return(true); } } } return(false); }
//刷新宝箱显示; void UpdateChapter(ChapterinfoTemplate chapterT) { //--------------翻页按钮----------- UpdatePageBtnState(); //--------------章节名字----------- m_title.text = string.Format(GameUtils.getString("chapter_title"), GameUtils.ConverIntToString(chapterT.getId())); m_value.text = GameUtils.getString(chapterT.getChapterName()); //--------------宝箱-------------- UpdateBox(chapterT); //--------------背景图------------ Sprite inst = UIResourceMgr.LoadSprite(common.defaultPath + "Ui_guanqiabeijing"); ChapterinfoTemplate info = StageModule.GetChapterinfoTemplateById(chapterT.getId()); 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()); mChapterBgImg.sprite = pic; //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; //} } }
public static int GetChapterinfoIdByStageId(int stageId) { foreach (var item in DataTemplate.GetInstance().m_ChapterTable.getData()) { if (item.Value == null) { continue; } ChapterinfoTemplate chapterT = item.Value as ChapterinfoTemplate; if (chapterT == null) { continue; } int length = chapterT.getStageID().Length; for (int i = 0; i < length; i++) { if (chapterT.getStageID()[i] == stageId) { return(item.Key); } } } return(-1); }
void OnDifficultChanged(EM_STAGE_DIFFICULTTYPE difficultType) { ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(mCurChapterId); if (chapterT == null) { Debug.LogError("章节数据错误id=" + mCurChapterId); return; } ObjectSelf.GetInstance().CurChapterLevel = (int)difficultType; UpdateHardBtnImgs(difficultType); //---------------关卡------------ //选中当前章节最后一个可以挑战的关卡; mCurLevelId = StageModule.GetLastStageIdInTheChapter(chapterT, difficultType); //---------------章节------------ UpdateChapter(chapterT); //-------------关卡详细描述------- UpdateLevelInfo(); //--------------所有关卡--------- UpdateLevels(chapterT); }
void OnChapterChanged(int curChapterId) { ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(curChapterId); if (chapterT == null) { Debug.LogError("章节数据错误id=" + curChapterId); return; } ObjectSelf.GetInstance().SetCurChapterID(mCurChapterId); //---------------关卡难度--------- mDifficutType = EM_STAGE_DIFFICULTTYPE.NORMAL; UpdateHardBtnImgs(mDifficutType); UpdateDifficults(chapterT); //---------------章节------------ UpdateChapter(chapterT); //---------------关卡------------ //选中当前章节最后一个可以挑战的关卡; mCurLevelId = StageModule.GetLastStageIdInTheChapter(chapterT, mDifficutType); //----------- 关卡详细描述--------- UpdateLevelInfo(); //--------------所有关卡---------- UpdateLevels(chapterT); }
void InitUI() { ChapterinfoTemplate levelInfo = (ChapterinfoTemplate)DataTemplate.GetInstance().m_ChapterTable.getTableData(ObjectSelf.GetInstance().GetCurChapterID()); m_NewMapName.text = GameUtils.getString(levelInfo.getChapterName()); m_NewMapBackImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + levelInfo.getBackgroundPicture()); }
//刷新难度标签; void UpdateDifficults(ChapterinfoTemplate chapterT) { int difficultCount = StageModule.GetDifficultCount(chapterT); m_normal.gameObject.SetActive(difficultCount >= 1); m_hard.gameObject.SetActive(difficultCount >= 2); m_hardest.gameObject.SetActive(difficultCount >= 3); }
void Init() { ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(mCurChapterId); if (chapterT == null) { Debug.LogError("章节数据错误id=" + mCurChapterId); return; } UpdateHardBtnImgs(mDifficutType); //---------------------关卡难度----------------------- //m_normal.isOn = true; UpdateDifficults(chapterT); //---------------------章节-------------------------- UpdateChapter(chapterT); //--------------------- 关卡详细描述------------------- UpdateLevelInfo(); //---------------------所有关卡----------------------- UpdateLevels(chapterT); m_MapScroll.setIdx(mCurChapterId - 1); //特殊关卡计时; //if (ObjectSelf.GetInstance().BattleStageData.m_IsOpenSpecialStage) //{ // m_SpecialStageTime = ObjectSelf.GetInstance().BattleStageData.m_SpecialStage.m_Time; // m_CountDownObject.SetActive(true); // //m_CountDownText.text = string.Format("剩余时间:{0}:{1}", m_SpecialStageTime / 60, m_SpecialStageTime % 60); //} //else //{ // m_CountDownObject.SetActive(false); //} //// 新手引导相关--- 开启支线关卡 if (ObjectSelf.GetInstance().m_isOpenZhiXian) { for (int i = 0; i < stageDatas.Count; i++) { if (StageModule.GetStageType(stageDatas[i]) == EM_STAGE_TYPE.SIDE_QUEST) { OnLevelItemClick(stageDatas[i].m_stageid); } } } //新手引导 关卡选择 强制点击返回第一章 if (ObjectSelf.GetInstance().m_isOpenPerfectReward) { OnClickbackpoint(); } }
public static int GetLastStageIdInTheChapter(int chapterId, EM_STAGE_DIFFICULTTYPE difficultType) { ChapterinfoTemplate chapterT = GetChapterinfoTemplateById(chapterId); if (chapterT == null) { return(-1); } return(GetLastStageIdInTheChapter(chapterT, difficultType)); }
//刷新宝箱显示; void UpdateChapter(ChapterinfoTemplate chapterT) { //--------------翻页按钮----------- UpdatePageBtnState(); //--------------章节名字----------- m_title.text = string.Format(GameUtils.getString("chapter_title"), GameUtils.ConverIntToString(chapterT.getId())); m_value.text = GameUtils.getString(chapterT.getChapterName()); //--------------宝箱-------------- //UpdateBox(chapterT); }
void OnStageDataRefreshed(GameEvent ge) { ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(mCurChapterId); if (chapterT == null) { Debug.LogError("章节数据错误id=" + mCurChapterId); return; } UpdateLevels(chapterT); }
/// <summary> /// 是否通过了指定关卡 /// </summary> /// <param name="_pieceNum"></param> /// <param name="stageId"></param> /// <returns></returns> private bool CheckThroughCheckPoint(int _pieceNum, int stageId) { int _num; ChapterinfoTemplate chapterinfo = (ChapterinfoTemplate)DataTemplate.GetInstance().m_ChapterTable.getTableData(_pieceNum); int[] levelID = chapterinfo.getStageID(); if (ObjectSelf.GetInstance().BattleStageData.IsCopyScenePass(_pieceNum, levelID[stageId - 1], out _num)) { return(true); } return(false); }
public void RefreshStageItem() { //OnChapterChanged(mCurChapterId); ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(mCurChapterId); if (chapterT == null) { Debug.LogError("章节数据错误id=" + mCurChapterId); return; } UpdateLevels(chapterT); }
public void FightNumShow() { ChapterinfoTemplate levelInfo = (ChapterinfoTemplate)DataTemplate.GetInstance().m_ChapterTable.getTableData(1001); int[] levelID = levelInfo.getStageID(); for (int i = 0; i < levelID.Length; i++) { if (levelID[i] == ObjectSelf.GetInstance().CurStageID) { StageTemplate stage = (StageTemplate)DataTemplate.GetInstance().m_StageTable.getTableData(levelID[i]); mStageItemList[i].init(stage, i); } } }
/// <summary> /// 通过关卡id获得该关卡所在的章节信息; /// </summary> /// 策划说关卡id在章节中是唯一的,一个关卡不可能出现在多个章节中,所以该方法有效; /// <param name="id"></param> /// <returns></returns> public int GetChapterIdByStageT(StageTemplate stageT) { if (stageT != null) { ChapterinfoTemplate chapterT = GetChapterTemplateByStageID(stageT.m_stageid); if (chapterT != null) { return(chapterT.getId()); } } return(-1); }
public bool IsCopyScenePass(int stageId, out int stageStar) { stageStar = -1; ChapterinfoTemplate ct = DataTemplate.GetInstance().GetChapterTemplateByStageID(stageId); if (ct == null) { return(false); } int chapterId = ct.getId(); return(IsCopyScenePass(chapterId, stageId, out stageStar)); }
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 OnRewardGot(GameEvent ge) { ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(mCurChapterId); if (chapterT == null) { Debug.LogError("章节数据错误id=" + mCurChapterId); return; } UpdateBox(chapterT); //打开宝箱物品获得窗; int boxIdx = System.Convert.ToInt32(ge.data); UICommonManager.Inst.ShowRewardView(chapterT.getChapterDrop()[boxIdx]); }
void OnLevelChanged(int levelId) { ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(mCurChapterId); if (chapterT == null) { Debug.LogError("章节数据错误id=" + mCurChapterId); return; } ObjectSelf.GetInstance().CurStageID = mCurLevelId; ObjectSelf.GetInstance().SetCurCampaignID(mCurLevelId); ////---------------------所有关卡----------------------- //UpdateLevels(chapterT); UpdateSelectState(); }
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]); } } }
/// <summary> /// 获得指定章节拥有的关卡难度个数; /// </summary> /// <param name="chapterT"></param> /// <returns></returns> public static int GetDifficultCount(ChapterinfoTemplate chapterT) { if (chapterT == null) { return(-1); } int count = 0; for (int i = 0, j = chapterT.getDifficult().Length; i < j; i++) { if (chapterT.getDifficult()[i] > 0) { count++; } } return(count); }
/// <summary> /// 获得当前章节中指定难度第一个关卡; /// </summary> /// <param name="chapterT"></param> /// <param name="difficultType"></param> /// <returns></returns> public static int GetFirstStageIdInTheChapter(ChapterinfoTemplate chapterT, EM_STAGE_DIFFICULTTYPE difficultType) { if (chapterT == null) { throw new Exception("Null Refrence Exception"); } int[] stageIds = chapterT.getStageID(); if (stageIds == null || stageIds.Length <= 0) { return(-1); } int temp = -1; for (int i = 0, j = stageIds.Length; i < j; i++) { temp = stageIds[i]; StageTemplate stageT = GetStageTemplateById(temp); if (stageT == null) { continue; } //只选主线; EM_STAGE_STAGETYPE stageType = GetStageStageType(stageT); if (stageType != EM_STAGE_STAGETYPE.MAIN) { continue; } EM_STAGE_DIFFICULTTYPE type = GetStageDifficultType(stageT); if (type == difficultType) { return(temp); } } return(-1); }
protected override void OnClickhardest() { base.OnClickhardest(); if (mDifficutType == EM_STAGE_DIFFICULTTYPE.HARDEST) { return; } int prevStageId = -1; if (CheckPrevStageIsPass(mCurChapterId, EM_STAGE_DIFFICULTTYPE.HARDEST, out prevStageId)) { DifficultType = EM_STAGE_DIFFICULTTYPE.HARDEST; } else { ChapterinfoTemplate ct = DataTemplate.GetInstance().GetChapterTemplateByStageID(prevStageId); InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("fight_stageselect_tip1") + GameUtils.getString("fight_stageselect_difficulty2") + string.Format(GameUtils.getString("fight_stageselect_tip2"), GameUtils.getString(ct.getChapterName()))); } }
/// <summary> /// 获得指定章节,指定难度等级的获得星星的总数 /// </summary> /// <param name="chapterT"></param> /// <param name="difficultLevel"></param> /// <returns></returns> public static int GetTotalStarsCount(ChapterinfoTemplate chapterT, int difficultLevel) { if (chapterT == null || chapterT.getStageID().Length <= 0) { return(-1); } if (difficultLevel < 1 || difficultLevel > 3) { return(-1); } int result = 0; int adder = 0; //根据difficultLevel(难度等级)获取星星累加值; int stageCount = 0; switch (difficultLevel) { case 1: stageCount += GetStageCount(chapterT, EM_STAGE_TYPE.MAIN_QUEST1); stageCount += GetStageCount(chapterT, EM_STAGE_TYPE.SIDE_QUEST); adder = 3; break; case 2: stageCount += GetStageCount(chapterT, EM_STAGE_TYPE.MAIN_QUEST2); adder = 3; break; case 3: stageCount += GetStageCount(chapterT, EM_STAGE_TYPE.MAIN_QUEST3); adder = 3; break; default: break; } result = adder * stageCount; return(result); }
/// <summary> /// 通过关卡id获得该关卡所在的章节信息; /// </summary> /// 策划说关卡id在章节中是唯一的,一个关卡不可能出现在多个章节中,所以该方法有效; /// <param name="id"></param> /// <returns></returns> public ChapterinfoTemplate GetChapterTemplateByStageID(int stageid) { List <int> keys = m_ChapterTable.GetDataKeys(); if (keys == null || keys.Count == 0) { return(null); } for (int i = 0; i < keys.Count; i++) { ChapterinfoTemplate ct = GetChapterTemplateByID(keys [i]); if (ct.getStageID().ToList <int> ().Contains(stageid)) { return(ct); } } return(null); }
void Init() { ChapterinfoTemplate chapterT = StageModule.GetChapterinfoTemplateById(mCurChapterId); if (chapterT == null) { Debug.LogError("章节数据错误id=" + mCurChapterId); return; } UpdateHardBtnImgs(mDifficutType); //---------------------关卡难度----------------------- //m_normal.isOn = true; UpdateDifficults(chapterT); //---------------------章节-------------------------- UpdateChapter(chapterT); //---------------------所有关卡----------------------- UpdateLevels(chapterT); //// 新手引导相关--- 开启支线关卡 if (ObjectSelf.GetInstance().m_isOpenZhiXian) { for (int i = 0; i < stageDatas.Count; i++) { if (StageModule.GetStageType(stageDatas[i]) == EM_STAGE_TYPE.SIDE_QUEST) { OnLevelItemClick(stageDatas[i].m_stageid); } } } //新手引导 关卡选择 强制点击返回第一章 if (ObjectSelf.GetInstance().m_isOpenPerfectReward) { OnClickbackpoint(); } }
public static List <StageTemplate> GetStageTemplatesByChapter(ChapterinfoTemplate chapterT) { if (chapterT == null || chapterT.getStageID().Length <= 0) { return(null); } List <StageTemplate> result = new List <StageTemplate>(); for (int i = 0, j = chapterT.getStageID().Length; i < j; i++) { StageTemplate st = GetStageTemplateById(chapterT.getStageID()[i]); if (st == null) { continue; } result.Add(st); } return(result); }
/// <summary> /// 获得玩家当前章节可以进入的最后(按id排序)一个关卡信息; /// </summary> /// <param name="chapterId"></param> /// <returns></returns> public static int GetLastStageIdInTheChapter(ChapterinfoTemplate chapterT, EM_STAGE_DIFFICULTTYPE difficultType) { List <StageData> bs = ObjectSelf.GetInstance().BattleStageData.GetStageDataListByChapterId(chapterT.getId()); if (bs == null || bs.Count <= 0) { return(-1); } int lastStageId = -1; int temp = -1; for (int i = 0; i < bs.Count; i++) { temp = bs[i].m_StageID; StageTemplate stageT = GetStageTemplateById(temp); if (stageT == null) { continue; } //只选主线; EM_STAGE_STAGETYPE stageType = GetStageStageType(stageT); if (stageType != EM_STAGE_STAGETYPE.MAIN) { continue; } EM_STAGE_DIFFICULTTYPE type = GetStageDifficultType(stageT); if (type == difficultType) { lastStageId = temp; } } return(lastStageId); }
/// <summary> /// 获取当前章节所含有的指定类型的关卡的所有数据; /// </summary> /// <param name="chapterT"></param> /// <returns></returns> public static List <StageTemplate> GetStageDatas(ChapterinfoTemplate chapterT, int stageType) { if (chapterT == null) { return(null); } List <StageTemplate> result = new List <StageTemplate>(); for (int i = 0, j = chapterT.getStageID().Length; i < j; i++) { StageTemplate stageT = GetStageTemplateById(chapterT.getStageID()[i]); if (stageT == null || stageT.m_stagetype != stageType) { continue; } result.Add(stageT); } return(result); }
/// <summary> /// 判断指定关卡是否开启; /// </summary> /// <param name="stageId"></param> /// <returns></returns> public bool IsStageOpen(int stageId) { ChapterinfoTemplate ct = DataTemplate.GetInstance().GetChapterTemplateByStageID(stageId); if (ct == null) { return(false); } int chapterId = ct.getId(); BattleStage bs = GetBattleStageByChapterId(chapterId); if (bs != null) { StageData sd = bs.GetStageData(stageId); if (sd != null) { return(true); } } return(false); }