ArtistTrainCompletion.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. const DWTool = require("../utils/DWTool");
  2. const { ArtistTrainItemSkillStyle } = require('../utils/GameEnum');
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. content: cc.Node,
  7. subContent: cc.Node,
  8. },
  9. init(data) {
  10. this.data = data;
  11. this.setSkillLayout();
  12. },
  13. // LIFE-CYCLE CALLBACKS:
  14. onLoad () {},
  15. start () {
  16. this.content.scaleX = 0;
  17. this.content.scaleY = 0;
  18. this.content.runAction(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()));
  19. },
  20. setSkillLayout() {
  21. DWTool.loadResPrefab("./prefabs/artist_train_completion_skill")
  22. .then((prefab) => {
  23. if (this.data.addCharm != 0) {
  24. let item = cc.instantiate(prefab);
  25. this.subContent.addChild(item);
  26. item.getComponent('ArtistTrainCompletionSkill').init(this.data, ArtistTrainItemSkillStyle.Charm);
  27. }
  28. if (this.data.addAbility != 0) {
  29. let item = cc.instantiate(prefab);
  30. this.subContent.addChild(item);
  31. item.getComponent('ArtistTrainCompletionSkill').init(this.data, ArtistTrainItemSkillStyle.Ability);
  32. }
  33. if (this.data.addEffect != 0) {
  34. let item = cc.instantiate(prefab);
  35. this.subContent.addChild(item);
  36. item.getComponent('ArtistTrainCompletionSkill').init(this.data, ArtistTrainItemSkillStyle.Effect);
  37. }
  38. });
  39. },
  40. dissmiss() {
  41. let finish = cc.callFunc(() => {
  42. this.node.destroy();
  43. }, this);
  44. let sequence = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
  45. this.content.runAction(sequence);
  46. },
  47. close() {
  48. this.dissmiss();
  49. }
  50. // update (dt) {},
  51. });