| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import { _decorator, Component, Node, Label, Sprite, SpriteFrame, RichText } from 'cc';
- import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils';
- import { Sound } from '../../core/sound/Sound';
- import { WindowManager } from '../../core/ui/window/WindowManager';
- import { g } from '../../Data/g';
- import { FsUtils } from '../../FsUtils/FsUtils';
- import { SoundSystem } from '../../Main/SoundSystem';
- import { BattleType } from './BattleUIWindow';
- const { ccclass, property } = _decorator;
- @ccclass('BattleSettlementWindow')
- export class BattleSettlementWindow extends Component {
- @property({ type: Node, tooltip: "战斗胜利节点" })
- winNode: Node;
- @property({ type: RichText, tooltip: "战斗胜利信息文本" })
- winInfoRichText: RichText;
- @property({ type: Node, tooltip: "战斗失败节点" })
- loseNode: Node;
- @property({ type: Node, tooltip: "背景特效" })
- bgEffectNode: Node;
- @property({ type: Label, tooltip: "战斗胜利奖励文本" })
- winGiftLabel: Label;
- @property({ type: Sprite, tooltip: "战斗胜利奖励图片" })
- winGiftSprite: Sprite;
- @property({ type: RichText, tooltip: "战斗失败信息文本" })
- loseInfoRichText: RichText;
- @property({ type: Label, tooltip: "战斗失败奖励文本" })
- loseGiftLabel: Label;
- @property({ type: Node, tooltip: "战斗失败奖励文本" })
- LoseGiftNode: Node;
- @property({ type: Node, tooltip: "确定按钮" })
- okBtnNode: Node;
- @property({ type: Sound, tooltip: "战斗结算音效" })
- settlementSound: Sound;
- @property({ type: RichText, tooltip: "挑战好友战胜利奖励文本" })
- winBattleLabel: RichText;
- start() {
- }
- private async onOpenHandler() {
- SoundSystem.stop();
- g.battleData.isWin;
- if (g.battleData.isWin) {
- this.settlementSound.play(1);
- this.bgEffectNode.active = this.winNode.active = true;
- this.winGiftLabel.string = FsUtils.moneyFormat(g.battleData.addMoney);//目前只奖励money
- g.userData.money += g.battleData.addMoney;
- if (g.battleData.type == BattleType.ChallengeBattle) {
- this.winBattleLabel.string = `<color=#AA343D>挑战成功,\n你击败了<color=#F3033D>【${g.battleData.enemyName}】</color>的队伍</color>`;
- this.winBattleLabel.node.active = true;
- this.okBtnNode.active = true;
- // this.winBattleLabel.string = `<color=#AA343D>你击败了<color=#F3033D>【${g.battleData.enemyName}】</color>的队伍</color>`;
- this.winInfoRichText.node.active = this.winGiftLabel.node.active = this.winGiftSprite.node.active = false;
- return;
- }
- if (g.battleData.type == BattleType.avengeBattle) {
- this.winInfoRichText.string = `<color=#8f5748>恭喜复仇成功,获得双倍奖励</color>`
- } else {
- this.winInfoRichText.string = `<color=#AA343D>你击败了<color=#F3033D>【${g.battleData.enemyName}】</color>的队伍</color>`;
- }
- // let img: SpriteFrame = await ResourcesUtils.load("prizeImg/prize1/spriteFrame", SpriteFrame, this.node);
- // this.winGiftSprite.spriteFrame = img;
- } else {
- this.settlementSound.play(0);
- this.loseInfoRichText.string = `<color=#8f5748>你被<color=#ff3401>【${g.battleData.enemyName}】</color>的队伍打败了!</color>`;
- this.loseNode.active = true;
- if (g.battleData.addMoney > 0) {
- g.userData.money += g.battleData.addMoney;
- } else {
- this.okBtnNode.active = true;
- }
- this.loseGiftLabel.string = FsUtils.moneyFormat(g.battleData.addMoney);//目前只奖励money
- }
- }
- onClose() {
- g.gameData.hasBattleOver = true;
- this.node.destroy();
- WindowManager.close();
- }
- }
|