JG0106_3.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import BaseEvent from "../fight/evnet/base/BaseEvent";
  2. /**
  3. * 摘果子
  4. */
  5. const { ccclass, property } = cc._decorator;
  6. @ccclass
  7. export default class JG0106_3 extends BaseEvent {
  8. @property({
  9. displayName: '摘取的道具id'
  10. })
  11. public id = 5001;
  12. @property({
  13. type: cc.ProgressBar,
  14. displayName: '进度条'
  15. })
  16. public mProgressBar: cc.ProgressBar = null;
  17. @property({
  18. type: cc.SpriteFrame,
  19. displayName: '图标'
  20. })
  21. public mTipsIcon: cc.SpriteFrame = null;
  22. onLoad() {
  23. super.onLoad()
  24. this.mProgressBar.node.active = false;
  25. }
  26. /**
  27. * 主角进入碰撞区域
  28. * @param tag 碰撞组件编号
  29. */
  30. public onBegin(tag: number) {
  31. this.showOpt(this.mTipsIcon, () => {
  32. this.pick();
  33. })
  34. }
  35. public onEnd(tag: number) {
  36. this.closeOpt()
  37. }
  38. /**
  39. * 摘取果子
  40. */
  41. public pick() {
  42. this.closeOpt()
  43. this.pause()
  44. this.mProgressBar.node.active = true;
  45. this.mProgressBar.progress = 0;
  46. this.ff.mBlockInputEvents.active = true;
  47. this.schedule(this.pupdate, 0.1);
  48. }
  49. public pupdate() {
  50. let progress = this.mProgressBar.progress;
  51. progress += 0.1;
  52. this.mProgressBar.progress = progress;
  53. if (progress >= 1) {
  54. this.ff.mBlockInputEvents.active = false;
  55. this.unschedule(this.pupdate);
  56. this.ff.mFFheader.addTmpGood(this.id, 1);
  57. this.node.removeComponent(cc.PhysicsBoxCollider);
  58. this.resume()
  59. cc.tween(this.node).sequence(
  60. cc.fadeOut(0.5),
  61. cc.destroySelf()
  62. ).start()
  63. }
  64. }
  65. }