FEndSign.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import FF from "../../FF";
  2. import FSprite from "../../object/FSprite";
  3. import WOneByone from "./WOneByone";
  4. /**
  5. * 结束事件提示
  6. */
  7. const {ccclass, property} = cc._decorator;
  8. @ccclass
  9. export default class FEndSign extends cc.Component {
  10. @property(cc.Prefab)
  11. mMapDialog: cc.Prefab = null;
  12. @property(cc.Node)
  13. mD1: cc.Node = null;
  14. private ff:FF = null;
  15. private isOver = false;
  16. onBeginContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider){
  17. if(this.isOver){
  18. return
  19. }
  20. if(other.node.group == 'A'){
  21. let obj = other.node.getComponent(FSprite);
  22. this.ff = obj.ff;
  23. if(obj == this.ff.mainSprite){
  24. this.isOver = true;
  25. this.node.removeComponent(cc.PhysicsBoxCollider);
  26. this.run();
  27. }
  28. }
  29. }
  30. private run(){
  31. this.ff.pauseSprite(true);
  32. this.ff.mBlockInputEvents.active = true;
  33. let map = this.ff.mMap;
  34. let winSize = cc.winSize
  35. let camera = map.mCamera;
  36. let cx = this.node.x - winSize.width/2;
  37. let cy = this.node.y - winSize.height/2;
  38. cc.tween(camera.node).sequence(
  39. cc.moveTo(0.7,cc.v2(cx,cy)),
  40. cc.callFunc(()=>{
  41. this.run1();
  42. })
  43. ).start()
  44. }
  45. private run1(){
  46. this.mD1.active = true;
  47. let spine = this.mD1.getChildByName('chuansongmen1');
  48. spine.active = true;
  49. let monster = this.mD1.getChildByName('monster56');
  50. monster.active = true;
  51. monster.opacity = 0;
  52. cc.tween(monster).sequence(
  53. cc.fadeIn(1),
  54. cc.callFunc(()=>{
  55. this.d1();
  56. })
  57. ).start();
  58. }
  59. private d1(){
  60. let dialogs = [
  61. '看来你已经学会了基本的冒险方法,去吧,到了那边会有东西接应你的。',
  62. '加油,我的孩子,拯救众神的任务就交给你了',
  63. ];
  64. let node = cc.instantiate(this.mMapDialog);
  65. node.group = 'map'
  66. node.zIndex = 9999;
  67. node.x = this.mD1.x;
  68. node.y = this.mD1.y + this.mD1.height;
  69. node.parent = this.ff.mMap.mSprites;
  70. let obo = node.getComponent(WOneByone);
  71. obo.dialogs = dialogs;
  72. obo.setCallback(()=>{
  73. this.mD1.active = false;
  74. node.destroy();
  75. this.ff.setBlockInputCallback(null);
  76. this.ff.pauseSprite(false);
  77. this.ff.mBlockInputEvents.active = false;
  78. });
  79. this.ff.setBlockInputCallback(()=>{
  80. obo.jump();
  81. });
  82. obo._start();
  83. }
  84. }