PunchInteract.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. let gameConfig = require("GameConfig");
  2. let library = require("../Library");
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. gameStates: {
  7. default: null,
  8. type: cc.Node,
  9. serializable: true,
  10. },
  11. playerController: {
  12. default: null,
  13. type: cc.Node,
  14. serializable: true,
  15. },
  16. actionPrefabs: {
  17. default: [],
  18. type: cc.Prefab,
  19. serializable: true,
  20. },
  21. bg: {
  22. default: null,
  23. type: cc.Node,
  24. serializable: true,
  25. },
  26. },
  27. onLoad () {
  28. this.gameStatesScp = this.gameStates.getComponent('GameStates');
  29. this.playerControllerScp = this.playerController.getComponent('PlayerController');
  30. this.delayTime = -1;
  31. },
  32. playActions()
  33. {
  34. let actionPlay = gameConfig.actionPlay[this.gameStatesScp.currentRound];
  35. // if(actionPlay.length == 0) return;
  36. for(let i=0;i<actionPlay.length;i++)
  37. {
  38. let c_act = actionPlay[i];
  39. this.spawnAction(c_act.name,c_act.offsetX,c_act.speed);
  40. }
  41. },
  42. spawnAction(name,offsetX,speed)
  43. {
  44. let tPrefab = cc.instantiate(this.actionPrefabs[name]);
  45. tPrefab.getComponent('ActionPlay').speed = speed;
  46. tPrefab.getComponent('ActionPlay').playerControllerScp = this.playerControllerScp;
  47. tPrefab.getComponent('ActionPlay').gameStatesScp = this.gameStatesScp;
  48. tPrefab.getComponent('ActionPlay').nameIndex = name;
  49. tPrefab.parent = this.node;
  50. tPrefab.setPosition(-720/2-offsetX,0);
  51. },
  52. });