From 439510ca0d2da7fa0af0496d4a05096841f01f8f Mon Sep 17 00:00:00 2001 From: wangguan <wangguan@kt007.com> Date: Mon, 26 Oct 2020 14:20:42 +0800 Subject: [PATCH] 新手引导2.0 --- Assets/Scripts/Guide/GuideCtrl.cs | 257 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 248 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/Guide/GuideCtrl.cs b/Assets/Scripts/Guide/GuideCtrl.cs index 345d9fa..8d5cf15 100644 --- a/Assets/Scripts/Guide/GuideCtrl.cs +++ b/Assets/Scripts/Guide/GuideCtrl.cs @@ -1,12 +1,17 @@ using System.Collections; +using System.Diagnostics; using System.Collections.Generic; using UnityEngine; +using KTGMGemClient; /// <summary> /// 新手引导控制脚本 /// </summary> public class GuideCtrl : MonoBehaviour { + private static GuideCtrl ins; + public static GuideCtrl Ins { get { return ins; } } + GuidePanel panel;//UI Dictionary<GuideEnum, string[]> allGuideDic; GuideEnum currentStep;//当前引导到了第几步 @@ -18,6 +23,7 @@ /// </summary> void Awake() { + ins = this; AddDic(); currentStep = GuideEnum.None; currentIndex = -1; @@ -27,6 +33,29 @@ private void Start() { Init(); + EventCenter.Ins.Add((int)KTGMGemClient.EventType.AddCard, AddCard); + EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFireLv2, CreateFireLv2); + EventCenter.Ins.Add((int)KTGMGemClient.EventType.ChargingEnd, ChargingEnd); + EventCenter.Ins.Add((int)KTGMGemClient.EventType.KillDone, KillDone); + EventCenter.Ins.Add((int)KTGMGemClient.EventType.GetOneTowerPos, GetOneTowerPos); + EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateWaterLv1, CreateWaterLv1); + EventCenter.Ins.Add((int)KTGMGemClient.EventType.SkillStep, SkillStep); + EventCenter.Ins.Add((int)KTGMGemClient.EventType.SkillReleaseDone, SkillReleaseDone); + + } + + private void OnDestroy() + { + EventCenter.Ins.Remove((int)KTGMGemClient.EventType.AddCard, AddCard); + EventCenter.Ins.Remove((int)KTGMGemClient.EventType.CreateFireLv2, CreateFireLv2); + EventCenter.Ins.Remove((int)KTGMGemClient.EventType.ChargingEnd, ChargingEnd); + EventCenter.Ins.Remove((int)KTGMGemClient.EventType.KillDone, KillDone); + EventCenter.Ins.Remove((int)KTGMGemClient.EventType.GetOneTowerPos, GetOneTowerPos); + EventCenter.Ins.Remove((int)KTGMGemClient.EventType.CreateWaterLv1, CreateWaterLv1); + EventCenter.Ins.Remove((int)KTGMGemClient.EventType.SkillStep, SkillStep); + EventCenter.Ins.Remove((int)KTGMGemClient.EventType.SkillReleaseDone, SkillReleaseDone); + + } public void Init() { @@ -108,6 +137,9 @@ case GuideEnum.Step12: Step12(); break; + case GuideEnum.Finish: + Finish(); + break; } @@ -136,18 +168,44 @@ { if (currentIndex == -1) { - panel.SetGuideUI(false); currentIndex = 0; needIndex = 2; - panel.Step1(allGuideDic[currentStep][currentIndex], currentIndex, OnFinishOneStep); + panel.SetGuideUI(false); + panel.Step1(allGuideDic[currentStep][currentIndex], currentIndex, Step1_1); } else if (currentIndex == 1) { - panel.Step1(allGuideDic[currentStep][currentIndex], currentIndex, OnFinishOneStep); + panel.Step1(allGuideDic[currentStep][currentIndex], currentIndex, Step1_2); + currentIndex++; } } + + /// <summary> + /// 分步1,购买1排1列的火元素 + /// </summary> + private void Step1_1() + { + panel.Step1_1(); + OnFinishOneStep(); + } + /// <summary> + /// 分步2,购买2排3列的火元素 + /// </summary> + private void Step1_2() + { + panel.Step1_2(); + StartCoroutine(AfterCreateFire()); + + } + + IEnumerator AfterCreateFire() + { + yield return new WaitForSeconds(1f); + OnFinishOneStep(); + } + //对话 private void Step2() { isShowing = true; @@ -167,76 +225,257 @@ } } + //引导合成 private void Step3() { if (currentIndex == -1) { - + currentIndex = 0; + needIndex = 2; + panel.Step3(currentIndex, allGuideDic[currentStep][currentIndex]); } } + + //开始拖拽 + public void BeginDrag() + { + panel.Step3_2(allGuideDic[currentStep][1]); + } + + //结束推拽 没有合成,回到上一步 + public void EndDrag() + { + panel.Step3(0, allGuideDic[currentStep][0]); + } + + //合成了卡牌,开始下一步 + private void AddCard() + { + currentIndex = -1; + ChangeStep(GuideEnum.Step4); + } + private void Step4() { if (currentIndex == -1) { - + currentIndex = 0; + panel.Step4(currentIndex, allGuideDic[currentStep][currentIndex]); } } + + //建造了塔,开始下一步 + private void CreateFireLv2() + { + currentIndex = -1; + ChangeStep(GuideEnum.Step5); + } + + private void Step5() { if (currentIndex == -1) { + EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.CreateFirstWave); + panel.Step5(currentIndex, ""); + } + else if (currentIndex == 1) + { + isShowing = true; + panel.StartShowWord(allGuideDic[currentStep][currentIndex], ShowWordCallBack); } } + + private void ChargingEnd() + { + currentIndex = 0; + needIndex = 2; + panel.SetGuideUI(true); + isShowing = true; + panel.StartShowWord(allGuideDic[currentStep][currentIndex], ShowWordCallBack); + + } + private void Step6() { if (currentIndex == -1) { + panel.SetGuideUI(false); + //恢复出怪 + EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.RestartWave); + } + else if (currentIndex == 1) + { + isShowing = true; + panel.StartShowWord(allGuideDic[currentStep][currentIndex], ShowWordCallBack); + + //增加200金币 + EventCenter.Ins.BroadCast<int>((int)KTGMGemClient.EventType.AddGold, 200); } } + + private void KillDone() + { + currentIndex = 0; + needIndex = 2; + panel.SetGuideUI(true); + isShowing = true; + panel.StartShowWord(allGuideDic[currentStep][currentIndex], ShowWordCallBack); + } + + private void Step7() { if (currentIndex == -1) { + currentIndex = 0; + needIndex = 1; + panel.SetGuideUI(false); + //等待解锁塔 + panel.Step7(currentIndex, allGuideDic[currentStep][currentIndex]); } } + + + private void GetOneTowerPos() + { + currentIndex = -1; + ChangeStep(GuideEnum.Step8); + } + + + private void Step8() { - if (currentIndex == -1) + isShowing = true; + if (currentIndex == -1)//初始化本步 { + currentIndex = 0; + needIndex = 2; + panel.Step8(); + panel.StartShowWord(allGuideDic[currentStep][currentIndex], ShowWordCallBack); } + else if (currentIndex == 1) + { + panel.StartShowWord(allGuideDic[currentStep][currentIndex], ShowWordCallBack); + } + } + private void Step9() { if (currentIndex == -1) { - + currentIndex = 0; + needIndex = 2; + panel.SetGuideUI(false); + panel.Step9(allGuideDic[currentStep][currentIndex], currentIndex, Step9_1); + } + else if (currentIndex == 1) + { + panel.Step9(allGuideDic[currentStep][currentIndex], currentIndex, null); } } + + /// <summary> + /// 分步9,购买1排5列的水元素 + /// </summary> + private void Step9_1() + { + panel.Step9_1(); + OnFinishOneStep(); + } + + private void CreateWaterLv1() + { + panel.CleanMask(); + EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.CreateSecondWave);//生成第二波小怪 + } + + private void SkillStep() + { + currentIndex = -1; + ChangeStep(GuideEnum.Step10); + } + private void Step10() { - if (currentIndex == -1) + isShowing = true; + if (currentIndex == -1)//初始化本步 { + currentIndex = 0; + needIndex = 2; + panel.SetGuideUI(true); + panel.StartShowWord(allGuideDic[currentStep][currentIndex], ShowWordCallBack); } + else if (currentIndex == 1) + { + panel.StartShowWord(allGuideDic[currentStep][currentIndex], ShowWordCallBack); + panel.Step10(); + } } + private void Step11() { if (currentIndex == -1) { + currentIndex = 0; + needIndex = 1; + + panel.Step11(currentIndex, allGuideDic[currentStep][currentIndex]); } } + + //开始拖拽 + public void BeginDrag11_1() + { + + panel.Step11(1, allGuideDic[currentStep][1]); + } + + //结束推拽 没有合成,回到上一步 + public void EndDrag11_1() + { + panel.Step11(0, allGuideDic[currentStep][0]); + } + + + private void SkillReleaseDone() + { + currentIndex = -1; + ChangeStep(GuideEnum.Step12); + } + private void Step12() { - if (currentIndex == -1) + isShowing = true; + if (currentIndex == -1)//初始化本步 { + currentIndex = 0; + needIndex = 3; + panel.Step12(); + + panel.StartShowWord(allGuideDic[currentStep][currentIndex], ShowWordCallBack); } + else + { + panel.StartShowWord(allGuideDic[currentStep][currentIndex], ShowWordCallBack); + } } + + private void Finish() + { + UnityEngine.Debug.Log("新手指导已经完成了"); + gameObject.SetActive(false); + } + #endregion #region 点击事件 -- Gitblit v1.9.1