/// <summary> /// 第一轮游戏 /// </summary> async void FirstGames() { nv1dice.transform.DOShakePosition(duration, strength, vibrato); nv2dice.transform.DOShakePosition(duration, strength, vibrato); nan1dice.transform.DOShakePosition(duration, strength, vibrato); jiesuanText.text = ChapterHelper.ReadChapterFuncTable(10000524); await UniTask.Delay(3300);//等待动画播放完成 Debug.Log("显示第一轮计分"); nv2lid.gameObject.SetActive(false);//女2先开 jiesuanText.text += ChapterHelper.ReadChapterFuncTable(10000525); await UniTask.Delay(800); nv1lid.gameObject.SetActive(false); jiesuanText.text += ChapterHelper.ReadChapterFuncTable(10000526); await UniTask.Delay(800); nan1lid.gameObject.SetActive(false); jiesuanText.text += ChapterHelper.ReadChapterFuncTable(10000527); //开始对话 dialogueBox_four.Initial(() => {//12000135开始 dialogueBox_four.Close(); //OpenClickBtn(true); SecondGames(); Debug.Log("对话完毕"); }, FourSpeakBeforeAction); dialogueBox_four.Show(); }
/// <summary> /// 通关章节 /// </summary> /// <param name="id">通关的章节id</param> public void PassChpter(int id) { if (id <= this.passChapterID) { return; } CSClearance cSClearance = new CSClearance() { SectionId = id }; //bool receive = false;等待返回 ProtocalManager.Instance().SendCSClearance(cSClearance, (x) => { this.passChapterID = id; ChapterHelper.PassChapter(this.passChapterID); foreach (var item in chapterItems) { if (item.GetItemID() == this.passChapterID) { item.SetWatchOver(true);//当前章节看完 } if (item.GetItemID() == this.passChapterID + 1) { item.SetBeforeWatchOver(true);//下一章的前一章标记看完 } } }, (ErrorInfo e) => { Debug.Log("请求过关章节失败"); }); }
void ClickCallBACK(int unlockPrice, Action ClickCallBack) { if (StaticData.GetWareHouseDiamond() >= unlockPrice) { //扣除资源 //刷新章节 StaticData.UpdateWareHouseDiamond(-unlockPrice); CSBuySection cSBuySection = new CSBuySection() { SectionId = curChapterID + 1 }; ProtocalManager.Instance().SendCSBuySection(cSBuySection, (SCBuySection x) => { StaticData.CreateToastTips("章节购买成功"); ChapterHelper.UnlockChapter(curChapterID + 1); foreach (var goodsInfo in x.CurrencyInfo) { StaticData.UpdateWareHouseItems(goodsInfo.GoodsId, (int)goodsInfo.Count); } ClickCallBack?.Invoke(); }, (ErrorInfo e) => { StaticData.CreateToastTips("章节购买失败"); Debug.LogError("章节购买失败" + e.webErrorCode); }, false); } else { StaticData.OpenRechargeUI(); } }
/// <summary> /// 初始化多语言 /// </summary> void InitialOADDialogues() { Title = transform.Find("Top/Title").GetComponent <Text>(); var OADinfo = StaticData.configExcel.GetExtraStoryByExtraStoryId(_OADindex); Title.text = ChapterHelper.GetOADDialogueString(ChapterHelper.GetOADData(OADinfo.ExtraStoryName)); _contentRect = transform.Find("Scroll View/Viewport/Content").GetComponent <RectTransform>(); BackBtn = transform.Find("BackBtn").GetComponent <Button>(); BackBtn.onClick.RemoveAllListeners(); BackBtn.onClick.AddListener(ClickBackBtn); switch (OADType) { case OADType.plainText: Debug.Log("初始化纯文本番外"); PlainTextInitial(); break; case OADType.mixtureText: Debug.Log("初始化图文番外"); MixtureTextInitial(); break; case OADType.cartoon: Debug.Log("初始化条漫番外"); CatoonInitial(); break; } }
/// <summary> /// 纯文本多语言初始化 /// </summary> private void PlainTextInitial() { var data = ChapterHelper.GetOADData(startDialogueId); string dialogue = ChapterHelper.GetOADDialogueString(data); plainText.text = dialogue; LayoutRebuilder.ForceRebuildLayoutImmediate(_contentRect); }
void SetParent(Transform thisTrans, Transform parentTrans) { thisTrans.SetParent(parentTrans); thisTrans.localPosition = Vector3.zero; thisTrans.localRotation = Quaternion.identity; thisTrans.localScale = Vector3.one; ChapterHelper.SetActive(thisTrans.gameObject, true); }
/// <summary> /// 创建滑动引导 /// </summary> public ChapterGuidance SlideGuidance(Transform parent) { GameObject go = GameObject.Instantiate(slideGuidance); ChapterHelper.SetParent(go, parent); var guidance = go.GetComponent <ChapterGuidance>(); return(guidance); }
//显示拥抱 void ShowHugGrandpa_image() { ChapterHelper.SetActive(hugGrandpa_image.gameObject, true); dialogueBoxBubble.Initial(() => { ShowEndScene(); dialogueBoxBubble.Close(); }); dialogueBoxBubble.Show(); }
/// <summary> /// 创建点击引导 /// </summary> public async System.Threading.Tasks.Task <GameObject> ClickGuidance(Transform parent, float DelayTime = 0) { int time = (int)DelayTime * 1000; await Cysharp.Threading.Tasks.UniTask.Delay(time); GameObject go = GameObject.Instantiate(clickGuidance); ChapterHelper.SetParent(go, parent); return(go); }
/// <summary> /// 设置对话完成回调 /// </summary> public void WordOverOpenBtn(Behaviour component, int DelayTime = 0) { ShowBtnCallBack = async() => {//有对话时 对话显示完成后开启按钮 await UniTask.Delay(DelayTime); ChapterHelper.SetEnable(component, true); ShowBtnCallBack = null; }; }
/// <summary> /// 弹出购买章节界面 /// </summary> public async static void PopupBuyChapterView(int chapterID, Action cancelCallBack) {//如果还没出下一章TODO var chapterInfo = StaticData.configExcel.GetSectionBySectionId(chapterID); if (chapterInfo == null) { StaticData.ToManorSelf(); cancelCallBack?.Invoke(); return; } int id = chapterInfo.UnlockPrice[0].ID; //取到钻石图片的id int count = (int)chapterInfo.UnlockPrice[0].Count; //取到数量 Sprite sprite = await ZillionaireToolManager.LoadItemSprite(id); string str = $"你的等级不够解锁下一章了哦"; StaticData.OpenCommonBuyTips(str, sprite, count, () => { if (StaticData.GetWareHouseDiamond() >= count) { //扣除资源 //刷新章节 StaticData.UpdateWareHouseDiamond(-count); CSBuySection cSBuySection = new CSBuySection() { SectionId = chapterID }; ProtocalManager.Instance().SendCSBuySection(cSBuySection, (SCBuySection x) => { StaticData.CreateToastTips("章节购买成功"); ChapterHelper.UnlockChapter(chapterID);//存入前端缓存 foreach (var goodsInfo in x.CurrencyInfo) { StaticData.UpdateWareHouseItems(goodsInfo.GoodsId, (int)goodsInfo.Count); } //进入下一章 EnterIntoChapter(chapterID); }, (ErrorInfo e) => { StaticData.CreateToastTips("章节购买失败"); Debug.LogError("章节购买失败" + e.webErrorCode); }, false); } else { StaticData.OpenRechargeUI(); } }, () => //取消购买直接进庄园 { cancelCallBack?.Invoke(); StaticData.ToManorSelf(); }, 120212); }
private void OnClickEnter() { //新手引导标记完成 if (StaticData.isOpenGuide && GuideCanvasComponent._instance != null && GuideCanvasComponent._instance.isCurrStepGuiding) { GuideCanvasComponent._instance.SetLittleStepFinish(); } //需要打开界面 ChapterHelper.EnterIntoChapter(_unlockChapterID, true); OnClickCancel(); }
/// <summary> /// 创建滑动引导 /// </summary> public async System.Threading.Tasks.Task <ChapterGuidance> SlideGuidance(Transform parent) { var parfab = await ABManager.GetAssetAsync <GameObject>(GuidanceName); GameObject go = GameObject.Instantiate(parfab); ChapterHelper.SetParent(go, parent); var guidance = go.GetComponent <ChapterGuidance>(); return(guidance); }
/// <summary> /// 登录+ 设置昵称完成完成进入主页 /// </summary> private async void LoginCompleteEnterManor() { //await ChatTool.InitialChat(); HideAnimEffect(); if (!ChapterHelper.IsFinishSection()) { await ChapterHelper.NewUserJoinChapter(); } else { //关闭登录界面 UIComponent.RemoveUI(UIType.UILogin); //加载自己庄园 await StaticData.ToManorSelf(); StaticData.DataDot(Company.Cfg.DotEventId.LoginToLobby); //登录完成初始化角色 //HallRoleManager.Instance.InitRole(); } //加载本地存储数据 UniversalTool.LoadLocalSaveData(); RedDotManager.Initial(); //是否请求每日订单 if (StaticData.playerInfoData.userInfo.SectionId >= 1000) //1000 序章 { //请求每日订单 StaticData.RequestDeals(); } //打开公告界面 StaticData.OpenUISystemNotification(); //更新任务图标红点标记 2020/12/18 TaskPanelTool.InitialUpdateTaskTag(); //更新邮件图标红点标记 2020/12/21 MailboxTool.InitialUpdateTaskTag(); StaticData.SetSceneState(StaticData.SceneState.ManorSelf); List <int> GuideIdList = new List <int>(); if (StaticData.playerInfoData.userInfo.Guidance != null) { for (int i = 0; i < StaticData.playerInfoData.userInfo.Guidance.Count; i++) { GuideIdList.Add(StaticData.playerInfoData.userInfo.Guidance[i]); } } GuideCanvasComponent._instance.SetGuideFinishListId(GuideIdList); //关闭登录界面 UIComponent.RemoveUI(UIType.UILogin); }
//女主走路 async void ShowWalk_Image() { ChapterHelper.Fade(walk_image.gameObject, 1, 0.8f, 0); var parfab = await ABManager.GetAssetAsync <GameObject>(walk); walk_RewImage = GameObject.Instantiate(parfab); walk_RewImage.transform.parent = _oneScene; await UniTask.Delay(1000); GetPhoneCall(); }
//前景草丛 void InstanceFbg() { GameObject go_fbg = GameObject.Instantiate(fbgCaoCong); go_fbg.SetActive(true); ChapterHelper.SetParent(go_fbg, this.transform.parent); go_fbg.transform.transform.localPosition = fbgPos; Tween tween = go_fbg.transform.DOLocalMoveX(fbg_X, 12f).OnComplete(() => { Destroy(go_fbg); }); tween.SetEase(Ease.Linear); }
//地板 void InstanceDiban() { GameObject go_diban = GameObject.Instantiate(diban); go_diban.SetActive(true); ChapterHelper.SetParent(go_diban, parent); go_diban.transform.transform.localPosition = dibanPos; Tween tween = go_diban.transform.DOLocalMoveX(fbg_X, 15f).OnComplete(() => { Destroy(go_diban); }); tween.SetEase(Ease.Linear); }
void InstanceTree() { GameObject go_tree = GameObject.Instantiate(bgTree); go_tree.SetActive(true); ChapterHelper.SetParent(go_tree, this.transform.parent); go_tree.transform.SetSiblingIndex(1); go_tree.transform.localPosition = treePos; Tween tween = go_tree.transform.DOLocalMoveX(bg_X, 18f).OnComplete(() => { Destroy(go_tree); }); tween.SetEase(Ease.Linear); }
//第三次点击开始游戏 async void ThirdlyStartGame() { jiesuanText.text = ""; nv1lid.gameObject.SetActive(true); nv2lid.gameObject.SetActive(true); nan1lid.gameObject.SetActive(true); //设置骰子精灵 nv1point1.sprite = point5; nv1point2.sprite = point4; nv1point3.sprite = point2; nv2point1.sprite = point2; nv2point2.sprite = point3; nv2point3.sprite = point5; nan1point1.sprite = point1; nan1point2.sprite = point1; nan1point3.sprite = point1; nv1dice.transform.DOShakePosition(duration, strength, vibrato); nv2dice.transform.DOShakePosition(duration, strength, vibrato); nan1dice.transform.DOShakePosition(duration, strength, vibrato); jiesuanText.text = ChapterHelper.ReadChapterFuncTable(10000532); await UniTask.Delay(3300);//等待动画播放完成 Debug.Log("显示第三轮计分"); nv2lid.gameObject.SetActive(false);//女2先开 jiesuanText.text += ChapterHelper.ReadChapterFuncTable(10000533); await UniTask.Delay(800); nv1lid.gameObject.SetActive(false); jiesuanText.text += ChapterHelper.ReadChapterFuncTable(10000534); await UniTask.Delay(800); nan1lid.gameObject.SetActive(false); jiesuanText.text += ChapterHelper.ReadChapterFuncTable(10000535); //重新开始对话 //dialogueBox_four.SetStartDialogueId(12000156); dialogueBox_six.Initial(() => { dialogueBox_six.Close(); //显示下一章按钮 ReadOverThisChapter(); Debug.Log("对话完毕"); }, FourSpeakBeforeAction); dialogueBox_six.Show(); }
//AD弹出 void UnlockViewAD(int OADid) { StaticData.OpenAd("OADAd", (code, msg) => { if (code == 1) { //成功请求 CSAdvExtraStory sCEmtpyAdvExtraStory = new CSAdvExtraStory() { ExtraStoryId = OADid }; ProtocalManager.Instance().SendCSAdvExtraStory(sCEmtpyAdvExtraStory, (x) => { Debug.Log($"观看广告+{this.ADcount}次"); this.ADcount += 1; if (this.ADcount >= _currShowData.AdvertisingNum) {//观看广告次数达到 ChapterHelper.UnlockOAD(_currShowData.ExtraStoryId); } bool isAddCount = false; foreach (var item in StaticData.playerInfoData.userInfo.AdvInfo) { if (item.GoodsId != OADid) { continue; } isAddCount = true; item.AdvNum += 1; } if (!isAddCount) { CSAdvStruct cSAdv = new CSAdvStruct() { GoodsId = OADid, AdvNum = this.ADcount }; StaticData.playerInfoData.userInfo.AdvInfo.Add(cSAdv); } ; ShwoData(); }, (ErrorInfo e) => { Debug.LogError("广告观看请求失败");//TODO? }); } else { // } }); }
public async void SwitchAnima(ChapterType chapterType) { Mask.gameObject.SetActive(true); switch (chapterType) { case ChapterType.Main: //全部移动到左边 ChapterHelper.SetActive(m_chapterList.gameObject, true); m_chapterList.Init(_curVersionsMaxCount + 1, _passChapterID, _unlockMaxChapterID); m_OADList.transform.DOLocalMoveX(1242, 0.3f); ZjbBtn_canvasGroup.DOFade(0, switchBtnPosDutation); (ZjbBtn_canvasGroup.transform as RectTransform).DOAnchorPosY(diamondStartPosY, switchBtnPosDutation); diamondBtn_canvasGroup.DOFade(1, switchBtnPosDutation); (diamondBtn_canvasGroup.transform as RectTransform).DOAnchorPosY(diamondEndPosY, switchBtnPosDutation); m_chapterList.transform.DOLocalMoveX(0, 0.3f).OnComplete(() => { btn_chapter.enabled = true; btn_OAD.enabled = true; }); StartCoroutine(CutIn(2)); await UniTask.Delay(300); break; case ChapterType.OAD: ChapterHelper.SetActive(m_OADList.gameObject, true); m_chapterList.transform.DOLocalMoveX(-1242, 0.3f); ZjbBtn_canvasGroup.DOFade(1, switchBtnPosDutation); (ZjbBtn_canvasGroup.transform as RectTransform).DOAnchorPosY(diamondEndPosY, switchBtnPosDutation); diamondBtn_canvasGroup.DOFade(0, switchBtnPosDutation); (diamondBtn_canvasGroup.transform as RectTransform).DOAnchorPosY(diamondStartPosY, switchBtnPosDutation); m_OADList.transform.DOLocalMoveX(0, 0.3f).OnComplete(() => { btn_chapter.enabled = true; btn_OAD.enabled = true; Mask.gameObject.SetActive(false); }); await UniTask.Delay(300); m_chapterList.Clear(); break; } }
//显示鼓掌 void ShowPaPaPa_Image() { ChapterHelper.SetActive(papapa_image.gameObject, true, async() => { ChapterHelper.SetActive(platform_image.gameObject, false); papapa_text1.text = ChapterTool.GetChapterFunctionString(10000542); papapa_text2.text = ChapterTool.GetChapterFunctionString(10000542); papapa_text1.transform.GetComponent <CanvasGroup>().DOFade(1, 0.4f); papapa_text1.transform.DOLocalMove(new Vector3(-14, 1016, 0), 0.4f); papapa_text2.transform.GetComponent <CanvasGroup>().DOFade(1, 0.2f); papapa_text2.transform.DOLocalMove(new Vector3(560, -1100, 0), 0.2f); await UniTask.Delay(500); OpenClickBtn(true); }); }
/// <summary> /// 图文多语言初始化 /// </summary> private void MixtureTextInitial() { for (int i = 0; i < mixtureText.Count; i++) { var data = ChapterHelper.GetOADData(startDialogueId); string dialogue = ChapterHelper.GetOADDialogueString(data); mixtureText[i].text = dialogue; if (data.NextDialogId != 0) { startDialogueId = data.NextDialogId; } } LayoutRebuilder.ForceRebuildLayoutImmediate(_contentRect); }
/// <summary> /// 点击解锁按钮 /// </summary> void OnClickUnlockBtn() { switch (type) { case OADItemType.AD: UnlockViewAD(this._currShowData.ExtraStoryId); break; case OADItemType.Money: UIChapterComponent.Instance.OpenBuyOAD(this._currShowData, this._currDataIndex, this, ShwoData); break; } ChapterHelper.ReduceRedDot(this._currShowData.ExtraStoryId, false); UIChapterComponent.Instance.ShowOADBtnRedDot(); NoUnlockRedDot.gameObject.SetActive(false); }
//显示路人讲话 async void ShowPasserby_Image() { var data = ChapterTool.GetChapterData(10000005); string dialogue = ChapterTool.GetDialogueString(data); particle.Clear(); particle.Pause();//暂停特效 ChapterHelper.SetActive(passerby_image.gameObject, true, () => { ChapterHelper.SetActive(lecture_image.gameObject, false); passerbyDialgoue.Play(dialogue); }); await UniTask.Delay(800); OpenClickBtn(true); }
GameObject verticalCartoonClickGuidance; //条漫的点击引导 //条漫1 async void ShowVerticalCartoon() { ChapterHelper.Fade(VerticalCartoon.gameObject, 1, 0.8f, 0); VerticalCartoon.onValueChanged.AddListener(VerticalCartoonOver); //引导 guidance = await SlideGuidance(VerticalCartoon.transform); guidance.PlayGuidanceAnima(VerticalCartoon_startPos, VerticalCartoon_endPos, () => { VerticalCartoon.content.DOAnchorPosY(VerticalCartoon.content.anchoredPosition.y + 250f, 1).OnComplete(() => { //引导移动完成后记录位置 playerIsControll = false; }); }, -1, 1); }
/// <summary> /// 解锁章节 /// </summary> void UnlockChapter() { this.unlockMaxChapterID += 1; ChapterHelper.UnlockChapter(this.unlockMaxChapterID); foreach (var item in chapterItems) { if (item.GetItemID() == unlockMaxChapterID) { item.SetUnlock(true); } if (item.GetItemID() == unlockMaxChapterID + 1) { item.SetBeforeUnlock(true); } } }
/// <summary> /// 获取文本 /// </summary> /// <returns></returns> public string GetDialogue() {//自动赋值下一句 var dialogue = StaticData.configExcel.GetChapterDialogueTextByID(beginID); if (dialogue.DialogIdList.Count > 0)//有分支的存在数组里 { dialogIdList.Clear(); dialogIdList.AddRange(dialogue.DialogIdList); } else//没有的 也往数组里放一份 { beginID = dialogue.NextDialogId; dialogIdList.Clear(); dialogIdList.Add(dialogue.NextDialogId);//此时 List 应该只有1个元素 } return(ChapterHelper.GetTableDialogue(dialogue.ID)); }
//显示最后一幕 async void ShowEndScene() { //隐藏之前的所有图 ChapterHelper.SetActive(carMoveBG.gameObject, false); ChapterHelper.SetActive(hugGrandpa_image.gameObject, false); ChapterHelper.SetActive(endScene.gameObject, true); var parfab = await ABManager.GetAssetAsync <GameObject>("openDoor"); var go = GameObject.Instantiate(parfab); go.transform.parent = _oneScene; anim = go.transform.Find("Camera/kaimen").GetComponent <Animator>(); //显示最后一幕时 请求保存 if (isFirst) {//新手引导初次阅读 ChapterModuleManager._Instance.RequestPassChapter(); end_btn.onClick.RemoveAllListeners(); end_btn.onClick.AddListener(() => { end_btn.enabled = false; GoToManor(); }); } else { ChapterModuleManager._Instance.ClickEndChapterBtn(end_btn, null, async() => { anim.SetBool("openDoor", true); await UniTask.Delay(1500); endScene.GetComponent <CanvasGroup>().DOFade(0, 3f); await UniTask.Delay(3500); }, 5500); } //首次通关序章 if (isFirst) { end_btn.transform.Find("Text").GetComponent <Text>().text = StaticData.GetMultilingual(120224);//去庄园 } else { end_btn.transform.Find("Text").GetComponent <Text>().text = ChapterTool.GetChapterFunctionString(10000000);//下一章 } }
public void Play(string title, string titleContent, bool isAutoFade = false) { Init(title, titleContent); var s = DOTween.Sequence(); s.AppendInterval(0.1f); s.Append(line_image.transform.DOScale(1, lineDuration)); s.Append(TextRect.DOAnchorPosX(TextRect_endPosX, maskDuration).OnComplete(() => { TextRect_image.enabled = false; })); s.Join(circle.DOAnchorPosX(circle_endPosX, maskDuration).OnComplete(() => { circle_image.enabled = false; })); s.Append(titleText.DOColor(titleText_endColor, fadeDuration)); s.Play().OnComplete(() => { if (isAutoFade) { ChapterHelper.Fade(this.gameObject, 0, 2f, 1, () => { GameObject.Destroy(this.gameObject); UIComponent.RemoveUI(UIType.ChapterTitle); }); } else { var fadeOutBtn = transform.GetComponent <Button>(); fadeOutBtn.onClick.RemoveAllListeners(); fadeOutBtn.onClick.AddListener(() => { fadeOutBtn.enabled = false; ChapterHelper.Fade(this.gameObject, 0, 2f, 1, () => { GameObject.Destroy(this.gameObject); UIComponent.RemoveUI(UIType.ChapterTitle); ChapterTool.ShowChapterManager(); }); }); } }); }