FDoorTips.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import BaseEvent from "../base/BaseEvent";
  2. import WOneByone from "../map1/WOneByone";
  3. /**
  4. * 门的提示
  5. */
  6. const {ccclass, property} = cc._decorator;
  7. @ccclass
  8. export default class FDoorTips extends BaseEvent {
  9. @property(cc.Prefab)
  10. mMapDialog: cc.Prefab = null;
  11. @property([cc.String])
  12. text: Array<string> = [];
  13. @property({
  14. displayName: '提示图标',
  15. type: cc.SpriteFrame
  16. })
  17. mTipsIcon: cc.SpriteFrame = null;
  18. @property({
  19. displayName: '出现的机关',
  20. type: cc.Node
  21. })
  22. mGearNode: cc.Node = null;
  23. onLoad() {
  24. super.onLoad()
  25. if(this.mGearNode){
  26. this.mGearNode.active = false
  27. }
  28. }
  29. onBegin(tag:number){
  30. if (tag == 1) {
  31. this.showOpt(this.mTipsIcon, () => {
  32. this.dialog(0)
  33. })
  34. }
  35. }
  36. onEnd(tag:number){
  37. if (tag == 1) {
  38. this.closeOpt()
  39. }
  40. }
  41. private dialog(index:number){
  42. if(index >= this.text.length){
  43. if(this.mGearNode){
  44. this.mGearNode.active = true
  45. }
  46. this.closeOpt()
  47. return;
  48. }
  49. let texts = this.text[index].split('|')
  50. let mid = parseInt(texts.shift());
  51. if(mid == -1){//主角
  52. let my = this.ff.mainSprite.node;
  53. this.showDialog(my,texts,()=>{
  54. index ++;
  55. this.dialog(index);
  56. });
  57. }
  58. }
  59. }