FCageSign.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 FCageSign extends cc.Component {
  10. @property(cc.Prefab)
  11. mMapDialog: cc.Prefab = null;
  12. @property(cc.Node)
  13. mD1: cc.Node = null;
  14. @property(cc.Node)
  15. mD2: cc.Node = null;
  16. @property({
  17. type:cc.Node,
  18. displayName: '摄像机移动的目标位置'
  19. })
  20. mCameraPos: cc.Node = null;
  21. private ff:FF = null;
  22. onBeginContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider){
  23. if(other.node.group == 'A'){
  24. let obj = other.node.getComponent(FSprite);
  25. this.ff = obj.ff;
  26. if(obj == this.ff.mainSprite){
  27. this.node.removeComponent(cc.PhysicsBoxCollider);
  28. this.run();
  29. }
  30. }
  31. }
  32. private run(){
  33. this.ff.pauseSprite(true);
  34. this.ff.mBlockInputEvents.active = true;
  35. let map = this.ff.mMap;
  36. let winSize = cc.winSize
  37. let camera = map.mCamera;
  38. let cx = this.node.x + this.mCameraPos.x - winSize.width/2;
  39. let cy = this.node.y + this.mCameraPos.y - winSize.height/2;
  40. cc.tween(camera.node).sequence(
  41. cc.moveTo(0.7,cc.v2(cx,cy)),
  42. cc.callFunc(()=>{
  43. this.d1();
  44. })
  45. ).start()
  46. }
  47. private d1(){
  48. let dialogs = [
  49. '救…救……,SOS',
  50. ];
  51. let node = cc.instantiate(this.mMapDialog);
  52. node.group = 'map'
  53. node.zIndex = 9999;
  54. node.x = this.mD1.x;
  55. node.y = this.mD1.y + this.mD1.height;
  56. node.parent = this.ff.mMap.mSprites;
  57. let obo = node.getComponent(WOneByone);
  58. obo.dialogs = dialogs;
  59. obo.setCallback(()=>{
  60. node.destroy();
  61. this.ff.setBlockInputCallback(null);
  62. this.d2();
  63. });
  64. this.ff.setBlockInputCallback(()=>{
  65. obo.jump();
  66. });
  67. obo._start();
  68. }
  69. private d2(){
  70. let dialogs = [
  71. '别喊了,你就是叫破喉咙也没用的',
  72. ];
  73. let node = cc.instantiate(this.mMapDialog);
  74. node.group = 'map'
  75. node.zIndex = 9999;
  76. node.x = this.mD2.x;
  77. node.y = this.mD2.y + this.mD2.height;
  78. node.parent = this.ff.mMap.mSprites;
  79. let obo = node.getComponent(WOneByone);
  80. obo.dialogs = dialogs;
  81. obo.setCallback(()=>{
  82. node.destroy();
  83. this.ff.setBlockInputCallback(null);
  84. this.ff.pauseSprite(false);
  85. this.ff.mBlockInputEvents.active = false;
  86. });
  87. this.ff.setBlockInputCallback(()=>{
  88. obo.jump();
  89. });
  90. obo._start();
  91. }
  92. }