RichCollectPanel.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import GameM, { AUDIO_TYPE } from "../manager/GameM";
  2. import GuideMng from "../manager/GuideMng";
  3. import BookItem from "../other/item/BookItem";
  4. import { PlayerPrefs } from "../tools/MyExtends";
  5. import BasePanel from "../uiFrames/BasePanel";
  6. const { ccclass, property } = cc._decorator;
  7. @ccclass
  8. export default class RichCollectPanel extends BasePanel {
  9. @property(cc.Node)
  10. panelNode: cc.Node = null;
  11. @property(cc.Node)
  12. content: cc.Node = null;
  13. @property(cc.Node)
  14. itemNode: cc.Node = null;
  15. private isInit: boolean = false;
  16. private data: any = null;
  17. private dataIndex: number = 0;
  18. /*
  19. fairyjadec: Array(2)
  20. 0: {id: 1, scripture: 100, rewardfairyJade: 50}
  21. 1:
  22. id: 2
  23. rewardfairyJade: 60
  24. scripture: 300
  25. */
  26. OnEnter(param: any) {
  27. this.Init(param);
  28. this.panelNode.scale = 0;
  29. this.node.active = true;
  30. cc.tween(this.panelNode).to(0.2, { scale: 1 }, { easing: "backOut" })
  31. .call(() => {
  32. if (GuideMng.Ins.CurGuideId == 23
  33. && PlayerPrefs.GetInt("GGuide23", 0) != 1) {
  34. //引导取经 大富翁
  35. GuideMng.Ins.ResumeGuide();
  36. }
  37. })
  38. .start();
  39. }
  40. Init(data) {
  41. this.data = data;
  42. this.content.removeAllChildren();
  43. this.dataIndex = 0;
  44. this.isInit = true;
  45. //if (!this.isInit) {
  46. // this.isInit = true;
  47. //for (let i = 0; i < data.length; i++) {
  48. // let copynode = cc.instantiate(this.itemNode);
  49. // this.content.addChild(copynode);
  50. // copynode.active = true;
  51. // copynode.getComponent(BookItem).Init(data[i].id, data[i].rewardfairyJade, data[i].scripture);
  52. //}
  53. //}
  54. }
  55. OnExit() {
  56. this.node.active = false;
  57. this.isInit = false;
  58. //引导取经 大富翁
  59. GuideMng.Ins.CheckRichGuide22();
  60. }
  61. update(dt) {
  62. if (this.isInit) {
  63. if (this.dataIndex < this.data.length) {
  64. let copynode = cc.instantiate(this.itemNode);
  65. this.content.addChild(copynode);
  66. copynode.active = true;
  67. copynode.getComponent(BookItem).Init(this.data[this.dataIndex].id, this.data[this.dataIndex].rewardfairyJade, this.data[this.dataIndex].scripture);
  68. this.dataIndex++;
  69. //console.log("DataIndex:"+this.dataIndex);
  70. }
  71. }
  72. }
  73. Click_CloseBtn() {
  74. this.OnExit();
  75. GameM.audioM.playEffect(AUDIO_TYPE.button);
  76. }
  77. }