FGetSkill.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /**
  2. * 获取职业技能
  3. */
  4. import ViewObject from "../../../../../main/ViewObject";
  5. import BaseEvent from "../../base/BaseEvent";
  6. import { AudioMgr, GameViewType } from "../../../../../main/ViewManage";
  7. import FSjpPanel from "./FSjpPanel";
  8. import FqLogin from "../../../../../login/FqLogin";
  9. const { ccclass, property } = cc._decorator;
  10. @ccclass
  11. export default class FGetSkill extends BaseEvent {
  12. @property(cc.Prefab)
  13. mMapDialog: cc.Prefab = null;
  14. @property({
  15. displayName: '对话内容',
  16. type: [cc.String]
  17. })
  18. text: Array<string> = [];
  19. @property({
  20. displayName: '完成后的对话',
  21. type: [cc.String]
  22. })
  23. finish: Array<string> = [];//完成后的对话
  24. @property({
  25. displayName: '靠近的提示',
  26. type: cc.Node
  27. })
  28. icon: cc.Node = null;
  29. @property({
  30. displayName: '提示图标',
  31. type: cc.SpriteFrame
  32. })
  33. mTipsIcon: cc.SpriteFrame = null;
  34. @property({
  35. displayName: '需要的物品id'
  36. })
  37. public goodId = 2006;
  38. @property({
  39. displayName: '需要存储的ID'
  40. })
  41. public saveId: string = "";
  42. @property({
  43. displayName: '需要打开的门',
  44. type: cc.Node
  45. })
  46. mOpenDoor: cc.Node = null;
  47. private isEnd = false
  48. onLoad() {
  49. super.onLoad()
  50. let stage = this.ff.main.player.stage;
  51. if (stage.element.indexOf(this.saveId) > -1) {
  52. this.mOpenDoor.active = false;
  53. }
  54. }
  55. onBegin(tag: number) {
  56. if (this.isEnd) {
  57. return
  58. }
  59. if (tag == 1) {
  60. this.showOpt(this.mTipsIcon, () => {
  61. this.startDialog()
  62. })
  63. }
  64. }
  65. onEnd(tag: number) {
  66. if (tag == 1) {
  67. this.closeOpt()
  68. }
  69. }
  70. public startDialog() {
  71. this.closeOpt()
  72. let head = this.ff.mFFheader;
  73. let count = head.getTmpCount(this.goodId);
  74. if (count > 0) {
  75. head.removeTmpGood(this.goodId, 1);
  76. //已经打开了技能
  77. let role = this.ff.main.player.role
  78. if (role.openSkill) {
  79. this.pause()
  80. this.moveCamera(this.mOpenDoor.getPosition(), 1, () => {
  81. this.openGear()
  82. })
  83. } else {
  84. // this.showDialog2();
  85. this.showDialog(this.node, this.finish, ()=>{
  86. this.pause()
  87. this.moveCamera(this.mOpenDoor.getPosition(), 1, () => {
  88. this.openGear()
  89. })
  90. this.getMapObject(this.saveId, null);
  91. FqLogin.commitEvent(this.node.name,'','');
  92. })
  93. }
  94. } else {
  95. this.showDialog1(0);
  96. }
  97. }
  98. // private showDialog2() {
  99. // this.showDialog(this.node, this.finish, () => {
  100. // this.openSjpPanel()
  101. // });
  102. // }
  103. private showDialog1(index: number) {
  104. if (index >= this.text.length) {
  105. return;
  106. }
  107. let texts = this.text[index].split('|')
  108. let mid = parseInt(texts.shift());
  109. if (mid == -1) {//主角
  110. let my = this.ff.mainSprite.node;
  111. this.showDialog(my, texts, () => {
  112. index++;
  113. this.showDialog1(index);
  114. });
  115. } else {
  116. let my = this.node;
  117. this.showDialog(my, texts, () => {
  118. index++;
  119. this.showDialog1(index);
  120. });
  121. }
  122. }
  123. private openGear() {
  124. this.isEnd = true
  125. if (this.icon) {
  126. this.icon.active = false;
  127. }
  128. let nodes = this.mOpenDoor.children;
  129. nodes.forEach(element => {
  130. let spine = element.getComponent(sp.Skeleton);
  131. if (spine) {
  132. spine.setCompleteListener(() => {
  133. element.active = false;
  134. });
  135. spine.setAnimation(0, 'close', false);
  136. this.ff.main.playerEffectByPath(AudioMgr.openDoor);
  137. }
  138. });
  139. cc.tween(this.ff.mMap.node).sequence(
  140. cc.delayTime(1),
  141. cc.callFunc(() => {
  142. this.mOpenDoor.active = false;
  143. this.resume()
  144. })
  145. ).start()
  146. }
  147. /**
  148. * 打开水晶瓶界面
  149. */
  150. // private openSjpPanel() {
  151. // let main = this.ff.main
  152. // main.viewManage.loadFunc(GameViewType.fight_map_sjp_tips, (viewObject: ViewObject) => {
  153. // viewObject.show();
  154. // let sjp = viewObject as FSjpPanel;
  155. // sjp.setCallback(() => {
  156. // this.pause()
  157. // this.ff.control.showSkill2()
  158. // this.openGear()
  159. // // this.moveCamera(this.mOpenDoor.getPosition(), 1, () => {
  160. // // this.openGear()
  161. // // })
  162. // })
  163. // });
  164. // }
  165. }