BCBMPanelEnd.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. player1: cc.Node,
  5. player2: cc.Node,
  6. player3: cc.Node,
  7. player4: cc.Node,
  8. player5: cc.Node,
  9. player6: cc.Node,
  10. },
  11. initData(baseScript) {
  12. this.baseScript = baseScript;
  13. this.spine_bg = cc.find("rootNode/layer_bg/spine_bg", this.node);
  14. this.label_rate = cc.find("rootNode/label_rate", this.node);
  15. let spine = this.spine_bg.getComponent(sp.Skeleton);
  16. spine.setCompleteListener((event) => {
  17. let type1 = event.animation.name[0];
  18. let type2 = event.animation.name[1];
  19. if (type2 == "a") {
  20. spine.getComponent(sp.Skeleton).setAnimation(0, type1 + "b", false);
  21. } else if (type2 == "c") {
  22. spine.getComponent(sp.Skeleton).setAnimation(0, type1 + "d", false);
  23. }
  24. });
  25. },
  26. showPanel(data) {
  27. this.node.active = true;
  28. let nextType = data.lPlayerWinScore >= 0 ? "a" : "c";
  29. let itemSpineIndex = this.baseScript.layer_itemSpine.children[data.cbWinIndex].itemType + 1;
  30. data.lPlayerWinScore >= 0 ? this.node.parent.BCBMAudioManager.playWin() : this.node.parent.BCBMAudioManager.playFail();
  31. let spine = this.spine_bg.getComponent(sp.Skeleton);
  32. spine.setAnimation(0, ["", 1, 5, 2, 6, 3, 8, 4, 7][itemSpineIndex] + nextType, false);
  33. this.label_rate.getComponent(cc.Label).string = ["x40", "x5", "x30", "x5", "x20", "x5", "x10", "x5"][itemSpineIndex - 1];
  34. for (let i = 1; i < 7; i += 1) {
  35. let node = this["player" + i];
  36. if (i == 1) {
  37. let winscore = parseInt((data.lPlayerWinScore / 100).toFixed(0));
  38. node.setChildString("label_name", cc.vv.globalUserInfo.getNickName())
  39. node.setChildString("label_score", (winscore >= 0 ? "+" : "") + winscore);
  40. } else {
  41. let winscore = parseInt((data.lPlayerScoreInfo[i - 2].lWinScore / 100).toFixed(0));
  42. node.setChildString("label_name", data.lPlayerScoreInfo[i - 2].szNickName);
  43. node.setChildString("label_score", (winscore >= 0 ? "+" : "") + winscore);
  44. }
  45. node.opacity = 0;
  46. this.scheduleOnce(() => {
  47. node.runAction(cc.fadeTo(0.1, 255))
  48. }, 0.3 + i * 0.05);
  49. }
  50. },
  51. closePanel() {
  52. this.node.parent.BCBMAudioManager.playButton();
  53. this.node.active = false;
  54. this.baseScript.wait_start.opacity = 255;
  55. },
  56. });