FOpenDoorVineEx.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import FqLogin from "../../../../login/FqLogin";
  2. import { AudioMgr } from "../../../../main/ViewManage";
  3. import BaseEvent from "../base/BaseEvent";
  4. /**
  5. * 打开机关
  6. */
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export default class FOpenDoorVineEx extends BaseEvent {
  10. @property({
  11. displayName: '提示图标',
  12. type: cc.SpriteFrame
  13. })
  14. mTipsIcon: cc.SpriteFrame = null;
  15. /**
  16. * 控制的栅栏
  17. */
  18. @property([cc.Node])
  19. mFenceTrigger: Array<cc.Node> = [];
  20. @property([cc.Node])
  21. guides: Array<cc.Node> = [];//引导标识
  22. private isOver = false;
  23. /**
  24. * 主角进入碰撞区域
  25. * @param tag 碰撞组件编号
  26. */
  27. public onBegin(tag: number) {
  28. if (this.isOver) {
  29. return
  30. }
  31. this.showOpt(this.mTipsIcon, () => {
  32. this.closeOpt()
  33. this.pause()
  34. let target = this.node.children[0].children[0]
  35. cc.tween(target).sequence(
  36. cc.moveBy(0.2, cc.v2(0, -20)),
  37. cc.moveBy(0.2, cc.v2(0, 20)),
  38. cc.moveBy(0.2, cc.v2(0, -20)),
  39. cc.moveBy(0.2, cc.v2(0, 20)),
  40. cc.moveBy(0.5, cc.v2(0, 200)),
  41. cc.callFunc(() => {
  42. this.moveCamera(this.mFenceTrigger[0].getPosition(), 1, () => {
  43. cc.tween(this.node).sequence(
  44. cc.callFunc(() => {
  45. for (let i = 0; i < this.mFenceTrigger.length; i++) {
  46. const element = this.mFenceTrigger[i];
  47. this.showFence(element, 'close');
  48. }
  49. this.ff.main.playerEffectByPath(AudioMgr.openDoor);
  50. }),
  51. cc.delayTime(1),
  52. cc.callFunc(() => {
  53. this.resume()
  54. FqLogin.commitEvent(this.node.name, '', '');
  55. for (let i = 0; i < this.mFenceTrigger.length; i++) {
  56. const element = this.mFenceTrigger[i];
  57. element.destroy()
  58. }
  59. this.node.destroy()
  60. })
  61. ).start();
  62. })
  63. })
  64. ).start()
  65. })
  66. }
  67. private showFence(element, action) {
  68. let nodes = element.children;
  69. for (let i = 0; i < nodes.length; i++) {
  70. const element = nodes[i];
  71. let spine = element.getComponent(sp.Skeleton);
  72. if (spine) {
  73. spine.setAnimation(0, action, false);
  74. }
  75. }
  76. }
  77. }