GuideSystemBase.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System;
  5. namespace FrameWork.GuideSystem
  6. {
  7. /// <summary>
  8. /// 新手引导类
  9. /// 建议使用Tools -> 新手引导 ->初始化 自动生成的GuideSystem单例类
  10. /// </summary>
  11. public abstract class GuideSystemBase
  12. {
  13. public const string c_guideWindowName = "GuideWindow"; //引导界面名称
  14. public const string c_guideDataName = "GuideData"; //引导数据名
  15. public const string c_guideStartPoint = "StartPoint"; //引导开始点
  16. public const string c_guideEndPoint = "EndPoint"; //引导结束点
  17. public const string c_guideClosePoint = "ClosePoint"; //引导关闭点
  18. public const string c_PremiseKey = "Premise"; //前提条件
  19. public const string c_NextGuideNameKey = "NextGuide"; //下一步引导,如果为空,则为下一条记录
  20. public const string c_CallToNextKey = "CallToNext"; //是否调用去下一步引导
  21. public const string c_ClickToNextKey = "ClickToNext"; //是否点击去下一步引导
  22. public const string c_CustomEventKey = "CustomEvent"; //自定义事件名称
  23. public const string c_ConditionToNextKey = "ConditionToNextKey"; //是否自动判断条件去下一步引导
  24. public const string c_GuideWindowNameKey = "GuideWindowName"; //引导的界面名字
  25. public const string c_GuideObjectNameKey = "GuideObjectName"; //高亮显示的对象名字
  26. public const string c_GuideItemNameKey = "GuideItemName"; //高亮的Item名字
  27. public const string c_TipContentKey = "TipContent"; //提示文本内容
  28. public const string c_TipContentPosKey = "TipContentPos"; //提示文本位置
  29. public const string c_MaskAlphaKey = "MaskAlpha"; //遮罩Alpha
  30. public const string c_guideRecordName = "GuideRecord"; //引导记录名
  31. public const string c_guideSwitchName = "GuideSwitch"; //引导开关
  32. public const string c_guideCurrentKeyName = "CurrentGuide"; //当前执行完毕的引导
  33. bool m_isInit = false;
  34. bool m_isStart = false;
  35. bool m_isRegister = false;
  36. bool m_isOperationUI = false; //是否已经操作了UI
  37. protected GuideWindowBase m_guideWindowBase; //当前引导界面
  38. protected UIWindowBase m_currentOperationWindow; //当前操作的界面
  39. /// <summary>
  40. /// 新手引导记录表
  41. /// </summary>
  42. //Dictionary<string, string> m_guideRecord = new Dictionary<string, string>();
  43. DataTable m_guideData;
  44. protected SingleData m_currentGuideData;
  45. //int m_currentGuideIndex = 0;
  46. protected string m_currentGuideKey = "";
  47. protected string m_startGuideKey = "";
  48. public bool IsStart
  49. {
  50. get
  51. {
  52. return m_isStart;
  53. }
  54. }
  55. #region 外部调用
  56. /// <summary>
  57. /// 关闭新手引导
  58. /// </summary>
  59. public void Dispose()
  60. {
  61. if (m_isInit)
  62. {
  63. m_isInit = false;
  64. m_guideData = null;
  65. //清除操作
  66. ClearGuideLogic();
  67. EndGuide();
  68. }
  69. }
  70. /// <summary>
  71. /// 调用新手引导去下一步
  72. /// </summary>
  73. public void Next()
  74. {
  75. if ( IsStart && GetCallToNext(m_currentGuideData) && GuideCallFilter())
  76. {
  77. NextGuide();
  78. }
  79. }
  80. /// <summary>
  81. /// 新手引导开始点
  82. /// </summary>
  83. public void Start(string guideKey = null)
  84. {
  85. SingleData guideData;
  86. // Debug.Log("Guide Start!!!");
  87. if (!string.IsNullOrEmpty( guideKey ))
  88. {
  89. guideData = GetGuideDataByName(guideKey);
  90. }
  91. else
  92. {
  93. guideData = LoadFirstGuide();
  94. guideKey = guideData.m_SingleDataKey;
  95. }
  96. if (!IsStart
  97. && guideData != null
  98. && GuideStartCondition(guideKey,guideData)
  99. && GetGuideSwitch())
  100. {
  101. StartGuide(guideData);
  102. }
  103. }
  104. /// <summary>
  105. /// 检查是否满足启动引导的条件
  106. /// </summary>
  107. /// <param name="guideKey"></param>
  108. /// <returns></returns>
  109. public bool CanStartGuide(string guideKey)
  110. {
  111. if (string.IsNullOrEmpty(guideKey))
  112. return false;
  113. SingleData guideData = GetGuideDataByName(guideKey);
  114. if (!IsStart
  115. && guideData != null
  116. && GuideStartCondition(guideKey, guideData)
  117. && GetGuideSwitch())
  118. {
  119. return true;
  120. }
  121. return false;
  122. }
  123. #endregion
  124. #region 重载方法
  125. protected virtual void OnInit() { }
  126. /// <summary>
  127. /// 新手引导启动时调用
  128. /// </summary>
  129. protected virtual void OnStart()
  130. {
  131. }
  132. protected virtual void OnCloseGuide()
  133. {
  134. }
  135. protected virtual void OnEndGuide()
  136. {
  137. }
  138. /// <summary>
  139. /// 请求引导记录
  140. /// 可以根据情况选择是从本地读取还是从服务器请求
  141. /// </summary>
  142. protected virtual void GetGuideRecord()
  143. {
  144. m_currentGuideKey = RecordManager.GetStringRecord(c_guideRecordName, c_guideCurrentKeyName, "");
  145. }
  146. /// <summary>
  147. /// 保存引导记录
  148. /// 可以根据情况选择是保存在本地还是发往服务器
  149. /// </summary>
  150. protected virtual void SaveGuideRecord(string startKey,string currentKey)
  151. {
  152. RecordManager.SaveRecord(c_guideRecordName, startKey, true);
  153. RecordManager.SaveRecord(c_guideRecordName, c_guideCurrentKeyName, currentKey);
  154. }
  155. /// <summary>
  156. /// 判断是否满足引导开始条件,默认判断是不是开始点
  157. /// </summary>
  158. /// <returns></returns>
  159. protected virtual bool GuideStartCondition(string currentGuideKey ,SingleData data)
  160. {
  161. return GetGuideStartPoint(data);
  162. }
  163. /// <summary>
  164. /// 引导退出条件
  165. /// </summary>
  166. /// <returns></returns>
  167. protected virtual bool GuideEndCondition()
  168. {
  169. return GetGuideEndPoint(m_currentGuideData);
  170. }
  171. protected virtual bool GuideCloseCondition()
  172. {
  173. return GetGuideClosePoint(m_currentGuideData);
  174. }
  175. /// <summary>
  176. /// 判断是否满足引导的下一步条件
  177. /// </summary>
  178. /// <returns></returns>
  179. protected virtual bool GuideNextCondition()
  180. {
  181. return true;
  182. }
  183. /// <summary>
  184. /// 引导每步的表现(非UI的操作)
  185. /// </summary>
  186. protected virtual void GuideBehave()
  187. {
  188. //读取配置 设置摄像机
  189. }
  190. /// <summary>
  191. /// 引导表现 (对UI的操作)
  192. /// </summary>
  193. protected virtual void GuideBehaveByUI(UIWindowBase ui)
  194. {
  195. //高亮ObjectName
  196. string[] objNames = GetGuideObjectNames(m_currentGuideData);
  197. for (int i = 0; i < objNames.Length; i++)
  198. {
  199. ui.SetGuideMode(objNames[i]);
  200. }
  201. string[] items = GetGuideItemNames(m_currentGuideData);
  202. //高亮Item
  203. for (int i = 0; i < items.Length; i++)
  204. {
  205. ui.SetItemGuideMode(items[i]);
  206. }
  207. //显示文本
  208. m_guideWindowBase.ShowTips(GetTipContent(m_currentGuideData)
  209. , GetTipContentPos(m_currentGuideData));
  210. //调整背景遮罩Alpha
  211. m_guideWindowBase.SetMaskAlpha(GetMaskAlpha(m_currentGuideData));
  212. //创建特效
  213. //移动手指到目标位置
  214. }
  215. /// <summary>
  216. /// 清除对UI的操作
  217. /// </summary>
  218. /// <param name="ui"></param>
  219. protected virtual void ClearGuideBehaveByUI(UIWindowBase ui)
  220. {
  221. //清除高亮
  222. ui.ClearGuideModel();
  223. //清除特效
  224. m_guideWindowBase.ClearEffect();
  225. //清除手指
  226. m_guideWindowBase.HideAllGuideUI();
  227. //清除文本
  228. m_guideWindowBase.ClearTips();
  229. }
  230. /// <summary>
  231. /// 清除非UI操作
  232. /// </summary>
  233. protected virtual void ClearGuideBehave()
  234. {
  235. }
  236. protected virtual GuideWindowBase OpenGuideWindow()
  237. {
  238. return (GuideWindowBase)UIManager.OpenUIWindow(c_guideWindowName);
  239. }
  240. /// <summary>
  241. /// 引导点击过滤器,返回true通过
  242. /// </summary>
  243. protected virtual bool GuideClickFilter(InputUIOnClickEvent e)
  244. {
  245. string winName = GetGuideWindowName(m_currentGuideData);
  246. Debug.Log("e.EventKey :" + e.EventKey + " winName:" + winName);
  247. if (!string.IsNullOrEmpty(winName))
  248. {
  249. if (!e.EventKey.Contains(winName))
  250. {
  251. return false;
  252. }
  253. }
  254. string[] objnames = GetGuideObjectNames(m_currentGuideData);
  255. if (objnames.Length > 0)
  256. {
  257. bool isExist = false;
  258. for (int i = 0; i < objnames.Length; i++)
  259. {
  260. string objName = objnames[i];
  261. if (objName.Contains("."))
  262. {
  263. string[] tempArr = objName.Split('.');
  264. objName = tempArr[tempArr.Length - 1];
  265. }
  266. string endStr ="."+ objName+".";
  267. if (e.EventKey.Contains(objName))
  268. {
  269. isExist = true;
  270. }
  271. Debug.Log("e.EventKey :" + e.EventKey + " objName:" + objName + " endStr :" + endStr+ " isExist :"+ isExist);
  272. }
  273. if (!isExist)
  274. {
  275. return false;
  276. }
  277. }
  278. string[] itemNames = GetGuideItemNames(m_currentGuideData);
  279. //Debug.Log(" itemNames :" + itemNames.Length);
  280. if (itemNames.Length>0)
  281. {
  282. bool isExist = false;
  283. for (int i = 0; i < itemNames.Length; i++)
  284. {
  285. string itemName = GetObjName(itemNames[i]);
  286. if (e.EventKey.Contains(itemName))
  287. {
  288. isExist = true;
  289. }
  290. }
  291. if (!isExist)
  292. {
  293. return false;
  294. }
  295. }
  296. return true;
  297. }
  298. string GetObjName(string objName)
  299. {
  300. if(objName.Contains("."))
  301. {
  302. string[] temp = objName.Split('.');
  303. objName = temp[temp.Length - 1];
  304. }
  305. if(objName.Contains("["))
  306. {
  307. string[] temp = objName.Split('[');
  308. objName = temp[0];
  309. }
  310. return objName;
  311. }
  312. /// <summary>
  313. /// 引导调用过滤器,返回true通过
  314. /// </summary>
  315. protected virtual bool GuideCallFilter()
  316. {
  317. return true;
  318. }
  319. #endregion
  320. #region 事件接收
  321. void ReceviceClickEvent(InputUIOnClickEvent e)
  322. {
  323. Debug.Log(" ReceviceClickEvent ");
  324. if (IsStart && GetClickToNext(m_currentGuideData) && GuideClickFilter(e))
  325. {
  326. NextGuide();
  327. }
  328. }
  329. void ReceviceUIOpenEvent(UIWindowBase UI, params object[] objs)
  330. {
  331. if (IsStart && !m_isOperationUI && UI.UIName.Equals(GetGuideWindowName(m_currentGuideData)))
  332. {
  333. m_isOperationUI = true;
  334. m_currentOperationWindow = UI;
  335. try
  336. {
  337. GuideBehaveByUI(UI);
  338. }
  339. catch(Exception e)
  340. {
  341. Debug.LogError("ReceviceUIOpenEvent exception -> " + e.ToString());
  342. }
  343. }
  344. }
  345. void ReceviceUIShowEvent(UIWindowBase UI, params object[] objs)
  346. {
  347. if (IsStart && !m_isOperationUI && UI.UIName.Equals(GetGuideWindowName(m_currentGuideData)))
  348. {
  349. m_isOperationUI = true;
  350. m_currentOperationWindow = UI;
  351. try
  352. {
  353. GuideBehaveByUI(UI);
  354. }
  355. catch (Exception e)
  356. {
  357. Debug.LogError("ReceviceUIShowEvent exception -> " + e.ToString());
  358. }
  359. }
  360. }
  361. void ReceviceUICloseEvent(UIWindowBase UI, params object[] objs)
  362. {
  363. }
  364. void ReceviceGuideRecord(Dictionary<string, string> record)
  365. {
  366. //m_guideRecord = record;
  367. }
  368. protected virtual void ReceviceCustomEvent(IInputEventBase e)
  369. {
  370. }
  371. #endregion
  372. #region 引导逻辑
  373. protected void Init()
  374. {
  375. if (!m_isInit)
  376. {
  377. m_isInit = true;
  378. LoadGuideData();
  379. GetGuideRecord();
  380. OnInit();
  381. }
  382. }
  383. void StartGuide(SingleData guideData)
  384. {
  385. m_isStart = true;
  386. m_startGuideKey = guideData.m_SingleDataKey;
  387. Debug.Log(" 启动新手引导 : " + m_startGuideKey);
  388. SetCurrent(guideData);
  389. m_guideWindowBase = OpenGuideWindow();
  390. OnStart();
  391. GuideLogic();
  392. if(!m_isRegister)
  393. {
  394. // Debug.Log("StartGuide");
  395. m_isRegister = true;
  396. InputManager.AddAllEventListener<InputUIOnClickEvent>(ReceviceClickEvent);
  397. UISystemEvent.RegisterAllUIEvent(UIEvent.OnOpened, ReceviceUIOpenEvent);
  398. UISystemEvent.RegisterAllUIEvent(UIEvent.OnShow, ReceviceUIShowEvent);
  399. UISystemEvent.RegisterAllUIEvent(UIEvent.OnClose, ReceviceUICloseEvent);
  400. ApplicationManager.s_OnApplicationUpdate += Update;
  401. }
  402. }
  403. protected void EndGuide()
  404. {
  405. Debug.Log("EndGuide ");
  406. CloseGuide();
  407. OnCloseGuide();
  408. }
  409. /// <summary>
  410. /// 关闭引导逻辑,不调用OnCloseGuide
  411. /// </summary>
  412. protected void CloseGuide()
  413. {
  414. CloseGuideWindow(m_guideWindowBase);
  415. m_isStart = false;
  416. m_isOperationUI = false;
  417. m_guideWindowBase = null;
  418. if (m_isRegister)
  419. {
  420. Debug.Log("RemoveAllEventListener");
  421. m_isRegister = false;
  422. InputManager.RemoveAllEventListener<InputUIOnClickEvent>(ReceviceClickEvent);
  423. UISystemEvent.RemoveAllUIEvent(UIEvent.OnOpened, ReceviceUIOpenEvent);
  424. UISystemEvent.RemoveAllUIEvent(UIEvent.OnShow, ReceviceUIShowEvent);
  425. UISystemEvent.RemoveAllUIEvent(UIEvent.OnClose, ReceviceUICloseEvent);
  426. ApplicationManager.s_OnApplicationUpdate -= Update;
  427. }
  428. }
  429. protected virtual void CloseGuideWindow( GuideWindowBase m_guideWindowBase)
  430. {
  431. if (m_guideWindowBase != null)
  432. UIManager.CloseUIWindow(m_guideWindowBase);
  433. }
  434. protected void NextGuide()
  435. {
  436. Debug.Log("NextGuide m_currentGuideData " + m_currentGuideData.m_SingleDataKey + "");
  437. //
  438. OnEndGuide();
  439. //清除上一步的操作
  440. ClearGuideLogic();
  441. //如果是开始点点则讲开始点设为自身
  442. if (GetGuideStartPoint(m_currentGuideData))
  443. m_startGuideKey = m_currentGuideData.m_SingleDataKey;
  444. //如果是结束点则保存这一步
  445. if (GetGuideEndPoint(m_currentGuideData))
  446. SaveGuideRecord(m_startGuideKey,m_currentGuideData.m_SingleDataKey);
  447. SingleData nextGuideData = GetNextGuideData(m_currentGuideData);
  448. //Debug.Log("NextGuide m_currentGuideData " + m_currentGuideData.m_SingleDataKey + " " + GuideCloseCondition() + " nextGuideData " + nextGuideData);
  449. //退出判断
  450. if (!GuideCloseCondition()
  451. && nextGuideData != null)
  452. {
  453. //读取下一步引导
  454. SetCurrent(nextGuideData);
  455. //引导逻辑
  456. GuideLogic();
  457. }
  458. else
  459. {
  460. EndGuide();
  461. }
  462. }
  463. //引导逻辑
  464. void GuideLogic()
  465. {
  466. //Debug.Log("GuideLogic " + m_currentGuideData.m_SingleDataKey);
  467. if (m_currentGuideData != null)
  468. {
  469. //注册自定义事件监听
  470. AddCustomEventListener(GetCustomEvent(m_currentGuideData));
  471. //处理非UI逻辑
  472. GuideBehave();
  473. string uiName = GetGuideWindowName(m_currentGuideData);
  474. if(uiName != null)
  475. {
  476. //获取UI进行表现
  477. UIWindowBase ui = UIManager.GetUI(uiName);
  478. if (ui != null)
  479. {
  480. m_isOperationUI = true;
  481. m_currentOperationWindow = ui;
  482. try
  483. {
  484. GuideBehaveByUI(ui);
  485. }
  486. catch(Exception e)
  487. {
  488. Debug.LogError("GuideLogic GuideBehaveByUI Exception " + e.ToString());
  489. }
  490. }
  491. else
  492. {
  493. m_isOperationUI = false;
  494. }
  495. }
  496. }
  497. }
  498. protected void ClearGuideLogic()
  499. {
  500. if(m_currentOperationWindow != null)
  501. {
  502. ClearGuideBehaveByUI(m_currentOperationWindow);
  503. m_currentOperationWindow = null;
  504. }
  505. //取消自定义事件监听
  506. RemoveCustomEventListener(GetCustomEvent(m_currentGuideData));
  507. ClearGuideBehave();
  508. }
  509. void LoadGuideData()
  510. {
  511. if (m_guideData == null)
  512. {
  513. m_guideData = DataManager.GetData(c_guideDataName);
  514. }
  515. }
  516. //读取第一条引导
  517. protected SingleData LoadFirstGuide()
  518. {
  519. if(m_guideData.TableIDs.Count == 0)
  520. {
  521. Dispose();
  522. Debug.LogError("LoadFirstGuide :新手引导无记录!");
  523. return null;
  524. }
  525. SingleData guideData = null;
  526. //如果新手引导启动时没有为m_currentGuideKey赋值
  527. //则认为从第一条记录开始
  528. if (m_currentGuideKey == "")
  529. {
  530. guideData = m_guideData[m_guideData.TableIDs[0]];
  531. }
  532. else
  533. {
  534. //guideData = GetNextGuideData(m_guideData[m_currentGuideKey]);
  535. guideData = m_guideData[m_currentGuideKey];
  536. }
  537. return guideData;
  538. }
  539. //将一条记录设为当前要执行的引导记录
  540. void SetCurrent(SingleData data)
  541. {
  542. if (data != null)
  543. {
  544. //m_currentGuideIndex = m_guideData.TableIDs.IndexOf(data.m_SingleDataKey);
  545. m_currentGuideData = data;
  546. m_currentGuideKey = m_currentGuideData.m_SingleDataKey;
  547. }
  548. else
  549. {
  550. //m_currentGuideIndex = -1;
  551. m_currentGuideData = null;
  552. m_currentGuideKey = "";
  553. }
  554. }
  555. void AddCustomEventListener(string[] eventKey)
  556. {
  557. if (eventKey == null)
  558. {
  559. return;
  560. }
  561. for (int i = 0; i < eventKey.Length; i++)
  562. {
  563. Debug.Log("AddCustomEventListener");
  564. InputManager.AddListener(eventKey[i], eventKey[i], ReceviceCustomEvent);
  565. }
  566. }
  567. void RemoveCustomEventListener(string[] eventKey)
  568. {
  569. if(eventKey == null)
  570. {
  571. return;
  572. }
  573. for (int i = 0; i < eventKey.Length; i++)
  574. {
  575. InputManager.RemoveListener(eventKey[i], eventKey[i], ReceviceCustomEvent);
  576. }
  577. }
  578. #endregion
  579. #region 读取数据
  580. protected bool GetGuideSwitch()
  581. {
  582. return RecordManager.GetBoolRecord(c_guideRecordName, c_guideSwitchName,true);
  583. }
  584. protected string GetPremise(SingleData data)
  585. {
  586. return data.GetString(c_PremiseKey);
  587. }
  588. protected string GetNextGuideNeme(SingleData data)
  589. {
  590. return data.GetString(c_NextGuideNameKey);
  591. }
  592. protected bool GetGuideStartPoint(SingleData data)
  593. {
  594. return data.GetBool(c_guideStartPoint);
  595. }
  596. protected bool GetGuideEndPoint(SingleData data)
  597. {
  598. return data.GetBool(c_guideEndPoint);
  599. }
  600. protected bool GetGuideClosePoint(SingleData data)
  601. {
  602. //对旧项目做兼容
  603. if (!data.ContainsKey(c_guideClosePoint)
  604. && !data.data.m_defaultValue.ContainsKey(c_guideClosePoint))
  605. {
  606. return false;
  607. }
  608. return data.GetBool(c_guideClosePoint);
  609. }
  610. protected bool GetCallToNext(SingleData data)
  611. {
  612. return data.GetBool(c_CallToNextKey);
  613. }
  614. protected bool GetClickToNext(SingleData data)
  615. {
  616. return data.GetBool(c_ClickToNextKey);
  617. }
  618. protected string[] GetCustomEvent(SingleData data)
  619. {
  620. return data.GetStringArray(c_CustomEventKey);
  621. }
  622. protected bool GetConditionToNext(SingleData data)
  623. {
  624. //对旧项目做兼容
  625. if (!data.ContainsKey(c_ConditionToNextKey)
  626. && !data.data.m_defaultValue.ContainsKey(c_ConditionToNextKey))
  627. {
  628. return false;
  629. }
  630. return data.GetBool(c_ConditionToNextKey);
  631. }
  632. protected string GetGuideWindowName(SingleData data)
  633. {
  634. return data.GetString(c_GuideWindowNameKey);
  635. }
  636. protected string[] GetGuideObjectNames(SingleData data)
  637. {
  638. return data.GetStringArray(c_GuideObjectNameKey);
  639. }
  640. protected string[] GetGuideItemNames(SingleData data)
  641. {
  642. return data.GetStringArray(c_GuideItemNameKey);
  643. }
  644. protected virtual string GetTipContent(SingleData data)
  645. {
  646. return data.GetString(c_TipContentKey);
  647. }
  648. protected Vector3 GetTipContentPos(SingleData data)
  649. {
  650. return data.GetVector3(c_TipContentPosKey);
  651. }
  652. protected float GetMaskAlpha(SingleData data)
  653. {
  654. return data.GetFloat(c_MaskAlphaKey);
  655. }
  656. protected SingleData GetNextGuideData(SingleData data)
  657. {
  658. string next = GetNextGuideNeme(data);
  659. if (next == null)
  660. {
  661. int newIndex = m_guideData.TableIDs.IndexOf(data.m_SingleDataKey) + 1;
  662. return GetGuideDataByIndex(newIndex);
  663. }
  664. else
  665. {
  666. return GetGuideDataByName(next);
  667. }
  668. }
  669. protected SingleData GetGuideDataByIndex(int index)
  670. {
  671. if (m_guideData.TableIDs.Count > index)
  672. {
  673. string key = m_guideData.TableIDs[index];
  674. return GetGuideDataByName(key);
  675. }
  676. else
  677. {
  678. return null;
  679. }
  680. }
  681. protected SingleData GetGuideDataByName(string key)
  682. {
  683. if (!m_guideData.ContainsKey(key))
  684. {
  685. throw new System.Exception("GetGuideDataByName Exception: 没有找到 ->" + key + "<- 记录 ,请检查 " + c_guideDataName + " !");
  686. }
  687. return m_guideData[key];
  688. }
  689. #endregion
  690. #region Update
  691. void Update()
  692. {
  693. if (IsStart)
  694. {
  695. if (!DevelopReplayManager.IsReplay
  696. && ApplicationManager.AppMode == AppMode.Developing)
  697. {
  698. if (Input.GetKeyDown(KeyCode.F3))
  699. {
  700. Dispose();
  701. }
  702. }
  703. if (GetConditionToNext(m_currentGuideData))
  704. {
  705. //判断是否满足进行下一步的条件
  706. if (GuideNextCondition())
  707. {
  708. NextGuide();
  709. }
  710. }
  711. }
  712. }
  713. #endregion
  714. }
  715. }