BattleSettlementWindow.ts 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { _decorator, Component, Node, Label, Sprite, SpriteFrame, RichText } from 'cc';
  2. import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils';
  3. import { Sound } from '../../core/sound/Sound';
  4. import { WindowManager } from '../../core/ui/window/WindowManager';
  5. import { g } from '../../Data/g';
  6. import { FsUtils } from '../../FsUtils/FsUtils';
  7. import { SoundSystem } from '../../Main/SoundSystem';
  8. import { BattleType } from './BattleUIWindow';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('BattleSettlementWindow')
  11. export class BattleSettlementWindow extends Component {
  12. @property({ type: Node, tooltip: "战斗胜利节点" })
  13. winNode: Node;
  14. @property({ type: RichText, tooltip: "战斗胜利信息文本" })
  15. winInfoRichText: RichText;
  16. @property({ type: Node, tooltip: "战斗失败节点" })
  17. loseNode: Node;
  18. @property({ type: Node, tooltip: "背景特效" })
  19. bgEffectNode: Node;
  20. @property({ type: Label, tooltip: "战斗胜利奖励文本" })
  21. winGiftLabel: Label;
  22. @property({ type: Sprite, tooltip: "战斗胜利奖励图片" })
  23. winGiftSprite: Sprite;
  24. @property({ type: RichText, tooltip: "战斗失败信息文本" })
  25. loseInfoRichText: RichText;
  26. @property({ type: Label, tooltip: "战斗失败奖励文本" })
  27. loseGiftLabel: Label;
  28. @property({ type: Node, tooltip: "战斗失败奖励文本" })
  29. LoseGiftNode: Node;
  30. @property({ type: Node, tooltip: "确定按钮" })
  31. okBtnNode: Node;
  32. @property({ type: Sound, tooltip: "战斗结算音效" })
  33. settlementSound: Sound;
  34. @property({ type: RichText, tooltip: "挑战好友战胜利奖励文本" })
  35. winBattleLabel: RichText;
  36. start() {
  37. }
  38. private async onOpenHandler() {
  39. SoundSystem.stop();
  40. g.battleData.isWin;
  41. if (g.battleData.isWin) {
  42. this.settlementSound.play(1);
  43. this.bgEffectNode.active = this.winNode.active = true;
  44. this.winGiftLabel.string = FsUtils.moneyFormat(g.battleData.addMoney);//目前只奖励money
  45. g.userData.money += g.battleData.addMoney;
  46. if (g.battleData.type == BattleType.ChallengeBattle) {
  47. this.winBattleLabel.string = `<color=#AA343D>挑战成功,\n你击败了<color=#F3033D>【${g.battleData.enemyName}】</color>的队伍</color>`;
  48. this.winBattleLabel.node.active = true;
  49. this.okBtnNode.active = true;
  50. // this.winBattleLabel.string = `<color=#AA343D>你击败了<color=#F3033D>【${g.battleData.enemyName}】</color>的队伍</color>`;
  51. this.winInfoRichText.node.active = this.winGiftLabel.node.active = this.winGiftSprite.node.active = false;
  52. return;
  53. }
  54. if (g.battleData.type == BattleType.avengeBattle) {
  55. this.winInfoRichText.string = `<color=#8f5748>恭喜复仇成功,获得双倍奖励</color>`
  56. } else {
  57. this.winInfoRichText.string = `<color=#AA343D>你击败了<color=#F3033D>【${g.battleData.enemyName}】</color>的队伍</color>`;
  58. }
  59. // let img: SpriteFrame = await ResourcesUtils.load("prizeImg/prize1/spriteFrame", SpriteFrame, this.node);
  60. // this.winGiftSprite.spriteFrame = img;
  61. } else {
  62. this.settlementSound.play(0);
  63. this.loseInfoRichText.string = `<color=#8f5748>你被<color=#ff3401>【${g.battleData.enemyName}】</color>的队伍打败了!</color>`;
  64. this.loseNode.active = true;
  65. if (g.battleData.addMoney > 0) {
  66. g.userData.money += g.battleData.addMoney;
  67. } else {
  68. this.okBtnNode.active = true;
  69. }
  70. this.loseGiftLabel.string = FsUtils.moneyFormat(g.battleData.addMoney);//目前只奖励money
  71. }
  72. }
  73. onClose() {
  74. g.gameData.hasBattleOver = true;
  75. this.node.destroy();
  76. WindowManager.close();
  77. }
  78. }