FOpenDoorVine.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import BaseEvent from "../base/BaseEvent";
  2. /**
  3. * 藤蔓控制的门
  4. */
  5. const {ccclass, property} = cc._decorator;
  6. @ccclass
  7. export default class FOpenDoorVine extends BaseEvent {
  8. @property(cc.Prefab)
  9. mMapDialog: cc.Prefab = null;
  10. @property([cc.String])
  11. text: Array<string> = [];
  12. @property({
  13. displayName: '靠近的提示',
  14. type: cc.Node
  15. })
  16. mNearTips: cc.Node = null;
  17. @property({
  18. displayName: '藤蔓出现的提示',
  19. type: cc.Node
  20. })
  21. mFindTips: cc.Node = null;
  22. @property({
  23. displayName: '提示图标',
  24. type: cc.SpriteFrame
  25. })
  26. mTipsIcon: cc.SpriteFrame = null;
  27. @property({
  28. displayName: '出现的藤蔓',
  29. type: cc.Node
  30. })
  31. mGearNode: cc.Node = null;
  32. private isOver = false
  33. onLoad() {
  34. super.onLoad()
  35. if(this.mGearNode){
  36. this.mGearNode.active = false
  37. }
  38. if(this.mNearTips){
  39. this.mNearTips.active = false
  40. }
  41. if(this.mFindTips){
  42. this.mFindTips.active = false
  43. }
  44. }
  45. onBegin(tag:number){
  46. if(this.isOver){
  47. return
  48. }
  49. if (tag == 1) {
  50. if(this.mNearTips){
  51. this.mNearTips.active = false
  52. }
  53. this.showOpt(this.mTipsIcon, () => {
  54. this.closeOpt()
  55. this.pause()
  56. this.dialog(0)
  57. })
  58. }else if(tag == 2){
  59. if(this.mNearTips){
  60. this.mNearTips.active = true
  61. }
  62. }
  63. }
  64. onEnd(tag:number){
  65. if (tag == 1) {
  66. this.closeOpt()
  67. }else if (tag == 2) {
  68. if(this.mNearTips){
  69. this.mNearTips.active = false
  70. }
  71. }
  72. }
  73. private dialog(index:number){
  74. if(index >= this.text.length){
  75. if(this.mGearNode){
  76. this.vine()
  77. }
  78. return;
  79. }
  80. let texts = this.text[index].split('|')
  81. let mid = parseInt(texts.shift());
  82. if(mid == -1){//主角
  83. let my = this.ff.mainSprite.node;
  84. this.showDialog(my,texts,()=>{
  85. index ++;
  86. this.dialog(index);
  87. });
  88. }
  89. }
  90. /**
  91. * 藤蔓出现
  92. */
  93. private vine(){
  94. let pos = this.mGearNode.getPosition()
  95. let target = this.mGearNode.children[0].children[0]
  96. this.mGearNode.active = true
  97. target.y += 100
  98. this.moveCamera(pos,1,()=>{
  99. cc.tween(target).sequence(
  100. cc.moveBy(1,cc.v2(0,-100)),
  101. cc.callFunc(()=>{
  102. this.isOver = true
  103. this.resume()
  104. if(this.mFindTips){
  105. this.mFindTips.active = true
  106. }
  107. })
  108. ).start()
  109. })
  110. }
  111. }