RichBookPanel.ts 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. import { RichData } from "../datas/RichData";
  2. import AdM from "../manager/AdM";
  3. import GameM, { AUDIO_TYPE } from "../manager/GameM";
  4. import GuideMng from "../manager/GuideMng";
  5. import BasePanel from "../uiFrames/BasePanel";
  6. import EffectNode from "./EffectNode";
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export default class RichBookPanel extends BasePanel {
  10. @property(cc.Node)
  11. panelNode: cc.Node = null;
  12. @property(cc.Node)
  13. panel_ask: cc.Node = null;
  14. @property(cc.Node)
  15. panel_result: cc.Node = null;
  16. @property(cc.Node)
  17. panel_result_panelNode: cc.Node = null;
  18. @property(cc.Node)
  19. panel_result_suc: cc.Node = null;
  20. @property(cc.Node)
  21. panel_result_fail: cc.Node = null;
  22. @property(cc.Node)
  23. panel_analysis: cc.Node = null;
  24. @property(cc.Label)
  25. txtSubject: cc.Label = null;
  26. @property(cc.Toggle)
  27. tog1: cc.Toggle = null;
  28. @property(cc.Toggle)
  29. tog2: cc.Toggle = null;
  30. @property(cc.Label)
  31. txtAnswer1: cc.Label = null;
  32. @property(cc.Label)
  33. txtAnswer2: cc.Label = null;
  34. @property(cc.Node)
  35. signSuc: cc.Node = null;
  36. @property(cc.Label)
  37. txtSucReward: cc.Label = null;
  38. @property(cc.Node)
  39. signFail: cc.Node = null;
  40. @property(cc.Label)
  41. txtFailReward: cc.Label = null;
  42. @property(cc.Label)
  43. txtResultSub: cc.Label = null;
  44. @property(cc.Label)
  45. txtResultAns: cc.Label = null;
  46. @property(cc.Label)
  47. txtAnalysis: cc.Label = null;
  48. /**题目*/
  49. question: any = null;
  50. /*
  51. answerFour: ""
  52. answerOne: "悟空"
  53. answerRemarkFour: ""
  54. answerRemarkOne: ""
  55. answerRemarkThree: ""
  56. answerRemarkTwo: ""
  57. answerThree: ""
  58. answerTwo: "悟净"
  59. appid: "wxef592f91d2d125f5"
  60. id: 97
  61. remark: ""
  62. standardAnswer: 2 标准答案 answerTwo是正确答案
  63. title: "沙和尚,法号____"
  64. type: 1
  65. */
  66. private isAnswerOk: boolean = false;
  67. OnEnter(question: any) {
  68. this.panel_ask.active = true;
  69. this.panel_result.active = false;
  70. this.question = question;
  71. this.txtSubject.string = question.title;
  72. this.txtAnswer1.string = question.answerOne;
  73. this.txtAnswer2.string = question.answerTwo;
  74. this.tog1.isChecked = false;
  75. this.tog2.isChecked = false;
  76. this.txtResultSub.string = question.title;
  77. //this.txtAnswer1.node.color = cc.color(255, 255, 255, 255);
  78. //this.txtAnswer2.node.color = cc.color(255, 255, 255, 255);
  79. this.txtAnalysis.string = question.remark;
  80. this.isCanClick = true;
  81. this.panelNode.scale = 0;
  82. this.node.active = true;
  83. cc.tween(this.panelNode).to(0.2, { scale: 1 }, { easing: "backOut" })
  84. .call(() => {
  85. })
  86. .start();
  87. }
  88. OnExit() {
  89. this.node.active = false;
  90. this.panel_result.active = false;
  91. }
  92. AnswerSure() {
  93. this.signSuc.active = false;
  94. this.isAnswerOk = true;
  95. this.panel_result_panelNode.scale = 0;
  96. this.panel_result.active = true;
  97. cc.tween(this.panel_result_panelNode).to(0.2, { scale: 1 }, { easing: "backOut" })
  98. .call(() => {
  99. })
  100. .start();
  101. this.txtSucReward.string = "x" + (RichData.Ins.doubleRemain > 0 ? 6 : 3);
  102. this.panel_result_suc.active = true;
  103. this.panel_result_fail.active = false;
  104. GameM.audioM.playEffect(AUDIO_TYPE.sutraanswersure);
  105. this.scheduleOnce(() => {
  106. this.signSuc.scale = 10;
  107. this.signSuc.active = true;
  108. cc.tween(this.signSuc).to(0.3, { scale: 1 }).start();
  109. }, 0.5);
  110. }
  111. AnswerFail() {
  112. this.signFail.active = false;
  113. this.isAnswerOk = false;
  114. this.panel_result_panelNode.scale = 0;
  115. this.panel_result.active = true;
  116. cc.tween(this.panel_result_panelNode).to(0.2, { scale: 1 }, { easing: "backOut" })
  117. .call(() => {
  118. })
  119. .start();
  120. this.txtFailReward.string = "x" + (RichData.Ins.doubleRemain > 0 ? 2 : 1);
  121. this.panel_result_suc.active = false;
  122. this.panel_result_fail.active = true;
  123. GameM.audioM.playEffect(AUDIO_TYPE.sutraanswererror);
  124. this.scheduleOnce(() => {
  125. this.signFail.scale = 10;
  126. this.signFail.active = true;
  127. cc.tween(this.signFail).to(0.3, { scale: 1 }).start();
  128. }, 0.5);
  129. }
  130. Click_Tog1() {
  131. //if (this.tog1.isChecked)
  132. // this.txtAnswer1.node.color = cc.color(92, 20, 20, 255);
  133. //else
  134. // this.txtAnswer1.node.color = cc.color(255, 255, 255, 255);
  135. //this.txtAnswer2.node.color = cc.color(255, 255, 255, 255);
  136. GameM.audioM.playEffect(AUDIO_TYPE.button);
  137. }
  138. Click_Tog2() {
  139. //if (this.tog2.isChecked)
  140. // this.txtAnswer2.node.color = cc.color(92, 20, 20, 255);
  141. //else
  142. // this.txtAnswer2.node.color = cc.color(255, 255, 255, 255);
  143. //this.txtAnswer1.node.color = cc.color(255, 255, 255, 255);
  144. GameM.audioM.playEffect(AUDIO_TYPE.button);
  145. }
  146. Click_CommitBtn() {
  147. if (!this.tog1.isChecked && !this.tog2.isChecked) {
  148. EffectNode.instance.PlayTip("请选择你的答案");
  149. return;
  150. }
  151. this.txtResultAns.string = (this.question.standardAnswer == 1 ? this.question.answerOne : this.question.answerTwo) + "(我的答案:" + (this.tog1.isChecked ? this.question.answerOne : this.question.answerTwo) + ")";
  152. if (this.question.standardAnswer == 1) {
  153. if (this.tog1.isChecked) {
  154. this.AnswerSure();
  155. } else {
  156. this.AnswerFail();
  157. }
  158. } else if (this.question.standardAnswer == 2) {
  159. if (this.tog2.isChecked) {
  160. this.AnswerSure();
  161. } else {
  162. this.AnswerFail();
  163. }
  164. }
  165. GameM.audioM.playEffect(AUDIO_TYPE.button);
  166. }
  167. Click_CloseBtn() {
  168. if (!this.isCanClick) return;
  169. this.isCanClick = false;
  170. this.OnExit();
  171. GameM.audioM.playEffect(AUDIO_TYPE.button);
  172. }
  173. isCanClick = true;
  174. Click_GetBtn() {
  175. if (!this.isCanClick) return;
  176. this.isCanClick = false;
  177. this.scheduleOnce(() => {
  178. this.OnExit();
  179. }, 0.3);
  180. if (this.isAnswerOk) {
  181. if (RichData.Ins.doubleRemain > 0) {
  182. RichData.Ins.UpdateItemCard(0, 0, 0, 0, 1, 3 * 2, -1, () => {
  183. RichData.Ins.PlayParticleEft(30004, 5, this.node);
  184. }, false);
  185. } else {
  186. RichData.Ins.UpdateItemCard(0, 0, 0, 0, 1, 3, 0, () => {
  187. RichData.Ins.PlayParticleEft(30004, 5, this.node);
  188. }, false);
  189. }
  190. AdM.onSendEvent('Qujing_Questions_True', '取经答题正确', "qujing");
  191. } else {
  192. if (RichData.Ins.doubleRemain > 0) {
  193. RichData.Ins.UpdateItemCard(0, 0, 0, 0, 1, 1 * 2, -1, () => {
  194. RichData.Ins.PlayParticleEft(30004, 5, this.node);
  195. }, false);
  196. } else {
  197. RichData.Ins.UpdateItemCard(0, 0, 0, 0, 1, 1, 0, () => {
  198. RichData.Ins.PlayParticleEft(30004, 5, this.node);
  199. }, false);
  200. }
  201. AdM.onSendEvent('Qujing_Questions_False', '取经答题错误', "qujing");
  202. }
  203. setTimeout(() => {
  204. //引导取经 大富翁
  205. GuideMng.Ins.CheckRichGuide23();
  206. }, 500);
  207. GameM.audioM.playEffect(AUDIO_TYPE.button);
  208. AdM.onSendEvent('Qujing_GetScriptures', '取经获得经书', "qujing");
  209. }
  210. Click_AnalysisBtn() {
  211. this.panel_analysis.active = true;
  212. }
  213. Click_AnalysisCloseBtn() {
  214. this.panel_analysis.active = false;
  215. }
  216. }
  217. /*
  218. IT 2.35
  219. Program Files 3.38
  220. Program Files 86 4.76
  221. ProgramData 1.42
  222. Windows 23.7
  223. Windows.old 34.7 (占用 28.9)
  224. 用户 31.5 (占用 25.9)
  225. hiberfil.sys 6.38
  226. pagefile.sys 10
  227. */