public void TryReceiveReward(ECopyType copyType, int chapter, int awardIndex) { if (awardIndex < 0 || awardIndex > 2) { GTItemHelper.ShowTip("非法AwardIndex" + awardIndex); return; } int rewardState = RaidModule.Instance.GetChapterRewardStateByAwardIndex(chapter, awardIndex); switch (rewardState) { case ERewardState.NOT_RECEIVE: GTItemHelper.ShowTip("未达成条件"); return; case ERewardState.HAS_RECEIVE: GTItemHelper.ShowTip("奖励已领取"); return; } DWorld chapterDB = ReadCfgWorld.GetDataById(chapter); DAward awardDB = ReadCfgAward.GetDataById(chapterDB.Awards[awardIndex]); if (GTItemHelper.CheckBagFull(awardDB.MaxDropNum)) { return; } ReqGetChapterAward req = new ReqGetChapterAward(); req.CopyType = (int)copyType; req.Chapter = chapter; req.Index = awardIndex; NetworkManager.Instance.Send <ReqGetChapterAward>(MessageID.MSG_REQ_GET_CHAPTERAWARD, req); }
public int GetChapterRewardStateByAwardIndex(int chapter, int index) { if (!DataDBSMainChapter.ContainsKey(chapter)) { return(ERewardState.NOT_RECEIVE); } XMainChapter vo = DataDBSMainChapter.GetDataById(chapter); DWorld db = ReadCfgWorld.GetDataById(chapter); int starNum = GetChapterStarNumByChapter(chapter); if (starNum < db.Stars[index]) { return(ERewardState.NOT_RECEIVE); } int s = 0; switch (index) { case 0: s = vo.Award1; break; case 1: s = vo.Award2; break; case 2: s = vo.Award3; break; } return(s == 1 ? ERewardState.HAS_RECEIVE : ERewardState.CAN_RECEIVE); }
public bool CheckCopy(ECopyType copyType, int chapter, int copyID) { int key = (int)copyType; DWorld db = ReadCfgWorld.GetDataById(chapter); if (DataDBSRaid.ContainsKey(key)) { XRaid raid = DataDBSRaid.GetDataById(key); if (chapter > raid.MaxChapter) { if (chapter != raid.MaxChapter + 1) { GTItemHelper.ShowTip(string.Format("章节超出限制:{0}/{1}", chapter, raid.MaxChapter)); return(false); } if (copyID != db.Copys[0]) { GTItemHelper.ShowTip("非法CopyID" + copyID); return(false); } } else if (chapter == raid.MaxChapter) { if (copyID > raid.MaxCopyId + 1) { GTItemHelper.ShowTip("非法CopyID" + copyID); return(false); } } } return(true); }
private void ShowDialogueContent(DDialogue db) { string replaceName = string.Empty; switch (db.ContentType) { case EDialogueContentType.TYPE_NONE: { replaceName = string.Empty; } break; case EDialogueContentType.TYPE_PLAYER: { Character c = CharacterManager.Main; replaceName = c == null ? string.Empty : c.Name; } break; case EDialogueContentType.TYPE_ACTOR: { DActor actorDB = ReadCfgActor.GetDataById(db.ContentID); replaceName = actorDB == null ? string.Empty : actorDB.Name; } break; case EDialogueContentType.TYPE_ITEM: { DItem itemDB = ReadCfgItem.GetDataById(db.ContentID); replaceName = itemDB == null ? string.Empty : itemDB.Name; } break; case EDialogueContentType.TYPE_MAP: { DWorld worldDB = ReadCfgWorld.GetDataById(db.ContentID); replaceName = worldDB == null ? string.Empty : worldDB.Name; } break; } dlgContent.text = db.Content.Replace("%p%", replaceName); switch (db.ContentShowType) { case EDialogueContentShowType.Normal: dlgContent.GetComponent <TypewriterEffect>().enabled = false; break; case EDialogueContentShowType.Effect: dlgContent.GetComponent <TypewriterEffect>().enabled = true; dlgContent.GetComponent <TypewriterEffect>().ResetToBeginning(); break; } }
public void ShowViewByChapter(int chapterID) { mChapter = chapterID; DWorld chapterDB = ReadCfgWorld.GetDataById(chapterID); for (int i = 0; i < 3; i++) { mBoxStarNums[i].text = chapterDB.Stars[i].ToString(); int rewardState = RaidModule.Instance.GetChapterRewardStateByAwardIndex(chapterID, i); switch (rewardState) { case ERewardState.NOT_RECEIVE: case ERewardState.CAN_RECEIVE: mBoxStates[i].spriteName = "613"; break; case ERewardState.HAS_RECEIVE: mBoxStates[i].spriteName = "614"; break; } } int copysNum = chapterDB.Copys.Length; mChapterName.text = chapterDB.Name; GTItemHelper.ShowTexture(mMapTexture, chapterDB.Map); int enterIndex = RaidModule.Instance.GetMaxCanEnterCopyIndex(mCurCopyType, chapterID); for (int i = 0; i < mCopyItems.Count; i++) { ItemCopy item = mCopyItems[i]; if (i < copysNum) { item.item.SetActive(true); item.Show(i < enterIndex); int copyID = chapterDB.Copys[i]; DCopy db = ReadCfgCopy.GetDataById(copyID); int starNum = RaidModule.Instance.GetCopyStarNumById(copyID); item.copyName.text = db.Name; item.item.transform.localPosition = chapterDB.CopyPosArray[i]; GTItemHelper.ShowStarNum(item.stars, starNum); } else { mCopyItems[i].item.SetActive(false); } if (i == enterIndex - 1) { mLight.gameObject.SetActive(false); mLight.transform.parent = item.item.transform; mLight.transform.localPosition = Vector3.zero; } } }
public int GetChapterStarNumByChapter(int chapter) { int starNum = 0; if (DataDBSMainChapter.ContainsKey(chapter)) { DWorld db = ReadCfgWorld.GetDataById(chapter); for (int i = 0; i < db.Copys.Length; i++) { starNum += GetCopyStarNumById(db.Copys[i]); } } return(starNum); }
private void OnBoxClick(GameObject go) { GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK); int index = go.name.ToInt32() - 1; DWorld db = ReadCfgWorld.GetDataById(mChapter); GTWindowManager.Instance.OpenWindow(EWindowID.UIAwardBox); UIAwardBox window = (UIAwardBox)GTWindowManager.Instance.GetWindow(EWindowID.UIAwardBox); int state = RaidModule.Instance.GetChapterRewardStateByAwardIndex(mChapter, index); UIEventListener.VoidDelegate doReceive = delegate(GameObject w) { RaidService.Instance.TryReceiveReward(mCurCopyType, mChapter, index); }; window.ShowAwardById(db.Awards[index], state, doReceive); }
private void OnAck_GetChapterAward(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); AckGetChapterAward ack = Serializer.Deserialize <AckGetChapterAward>(ms); int chapter = ack.Chapter; int awardIndex = ack.Index; DWorld db = ReadCfgWorld.GetDataById(chapter); XMainChapter xc; if (!DataDBSMainChapter.ContainsKey(chapter)) { xc = new XMainChapter(); xc.Id = chapter; } else { xc = DataDBSMainChapter.GetDataById(chapter); } switch (awardIndex) { case 0: xc.Award1 = 1; break; case 1: xc.Award2 = 1; break; case 3: xc.Award3 = 1; break; } DataDBSMainChapter.Update(chapter, xc); int awardID = db.Awards[awardIndex]; List <KStruct> list = AwardModule.Instance.GetAwardDataByID(awardID); for (int i = 0; i < list.Count; i++) { GTDataManager.Instance.AddNewItem(list[i].Id, list[i].Num); } GTEventCenter.FireEvent(GTEventID.TYPE_GET_CHAPTERAWARD); }
private void OnCopyClick(GameObject go) { GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK); DWorld chapterDB = ReadCfgWorld.GetDataById(mChapter); int enterIndex = RaidModule.Instance.GetMaxCanEnterCopyIndex(mCurCopyType, mChapter); int index = go.name.ToInt32(); if (index > enterIndex) { GTItemHelper.ShowTip("未通关前置关卡"); return; } GTWindowManager.Instance.OpenWindow(EWindowID.UIMainGate); UIMainGate window = (UIMainGate)GTWindowManager.Instance.GetWindow(EWindowID.UIMainGate); window.ShowViewById(mCurCopyType, mChapter, chapterDB.Copys[index - 1]); }
private void ShowInitView() { transform.Find("Center").gameObject.SetActive(true); mapColor.gameObject.SetActive(true); background.gameObject.SetActive(true); int pChapter = RaidModule.Instance.GetMaxChapterByCopyType(ECopyType.TYPE_WORLD); Color pOpenNameColor = new Color32(246, 139, 4, 255); Color pOpenChapterColor = new Color32(246, 209, 4, 255); for (int i = 0; i < mAreas.Count; i++) { WorldArea tab = mAreas[i]; tab.areaIcon1.gameObject.SetActive(true); GTItemHelper.ShowImageBlack(tab.areaIcon1, !tab.isOpen); int chapter = DWorld.WORLD_ST_CHAPTER_ID + i; DWorld db = ReadCfgWorld.GetDataById(chapter); tab.areaName.text = db.Name; tab.areaName.color = tab.isOpen ? pOpenNameColor : Color.gray; tab.areaChapter.text = GTTools.Format("第 {0} 章", chapter); tab.areaChapter.color = tab.isOpen ? pOpenChapterColor : Color.gray; } }
public int GetMaxCanEnterChapter(ECopyType copyType) { int key = (int)copyType; int chapter = 0; if (DataDBSRaid.ContainsKey(key)) { XRaid raid = DataDBSRaid.GetDataById(key); DWorld chapterDB = ReadCfgWorld.GetDataById(raid.MaxChapter); if (chapterDB.Copys[chapterDB.Copys.Length - 1] == raid.MaxCopyId) { chapter = GetNextChapter(raid.MaxChapter); } else { chapter = raid.MaxChapter; } } else { chapter = DWorld.WORLD_ST_CHAPTER_ID; } return(chapter); }
public int GetMaxCanEnterCopyIndex(ECopyType copyType, int chapterID) { int maxCopyID = GetMaxCopyIdByCopyType(copyType); int maxChapter = GetMaxChapterByCopyType(copyType); DWorld db = ReadCfgWorld.GetDataById(chapterID); if (maxChapter == 0 && chapterID == DWorld.WORLD_ST_CHAPTER_ID) { return(1); } if (maxChapter > chapterID) { return(db.Copys.Length); } if (maxChapter == chapterID) { if (maxCopyID >= 0) { int index = 1; for (int i = 0; i < db.Copys.Length; i++) { if (db.Copys[i] <= maxCopyID) { index++; } else { break; } } index = index > db.Copys.Length ? db.Copys.Length : index; return(index); } } return(0); }