DJ0102.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { AudioMgr } from "../../main/ViewManage";
  2. import EventListener from "../../util/EventListener";
  3. import BaseEvent from "../fight/evnet/base/BaseEvent";
  4. /**
  5. * 要是开启宝箱
  6. */
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export default class DJ0102 extends BaseEvent {
  10. @property({
  11. displayName: '宝箱ID'
  12. })
  13. boxId: string = '28';
  14. @property({
  15. displayName: "钥匙ID"
  16. })
  17. keyID: number = 2001;
  18. @property(sp.Skeleton)
  19. spine: sp.Skeleton = null;
  20. @property({
  21. displayName: '靠近提示',
  22. type: cc.Node
  23. })
  24. closeTips: cc.Node = null;
  25. @property({
  26. displayName: '开启提示',
  27. type: cc.SpriteFrame
  28. })
  29. mTipsIcon: cc.SpriteFrame = null;
  30. /**
  31. * 控制的栅栏机关
  32. */
  33. @property({
  34. displayName: '控制的机关',
  35. type: [cc.Node],
  36. })
  37. mFenceTrigger: Array<cc.Node> = [];
  38. private isOpen = false;
  39. onLoad() {
  40. super.onLoad()
  41. // this.closeTips.active = false;
  42. // let stage = this.ff.main.player.stage;
  43. // if (stage.element.indexOf(this.boxId) >= 0) {
  44. // this.node.destroy();
  45. // for (let i = 0; i < this.mFenceTrigger.length; i++) {
  46. // const element = this.mFenceTrigger[i];
  47. // element.destroy()
  48. // }
  49. // }
  50. }
  51. /**
  52. * 主角进入碰撞区域
  53. */
  54. public onBegin(tag: number) {
  55. if (this.isOpen) {
  56. return
  57. }
  58. if (tag == 1) {
  59. // this.closeTips.active = true;
  60. this.showOpt(this.mTipsIcon, () => {
  61. let head = this.ff.mFFheader;
  62. let count = head.getTmpCount(this.keyID);
  63. if (count > 0) {
  64. // this.closeTips.active = false;
  65. this.pause();
  66. this.openBox();
  67. } else {
  68. EventListener.dispatchEvent("step_2_1");
  69. console.log("===没有钥匙==")
  70. }
  71. })
  72. }
  73. }
  74. /**
  75. * 主角离开碰撞区域
  76. */
  77. public onEnd(tag: number) {
  78. if (tag == 1) {
  79. this.closeOpt()
  80. // this.closeTips.active = false;
  81. }
  82. }
  83. private openBox() {
  84. this.isOpen = true;
  85. this.closeOpt();
  86. this.spine.setAnimation(0, 'open', false);
  87. this.ff.main.playerEffectByPath(AudioMgr.box);
  88. this.spine.setCompleteListener(() => {
  89. this.resume();
  90. EventListener.dispatchEvent("step_2_2");
  91. // FqLogin.commitEvent(this.node.name, '', '');
  92. // this.spine.setCompleteListener(null);
  93. // //与服务器通讯
  94. // this.getMapObject(this.boxId, () => {
  95. // })
  96. });
  97. }
  98. }