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 = `挑战成功,\n你击败了【${g.battleData.enemyName}】的队伍`;
this.winBattleLabel.node.active = true;
this.okBtnNode.active = true;
// this.winBattleLabel.string = `你击败了【${g.battleData.enemyName}】的队伍`;
this.winInfoRichText.node.active = this.winGiftLabel.node.active = this.winGiftSprite.node.active = false;
return;
}
if (g.battleData.type == BattleType.avengeBattle) {
this.winInfoRichText.string = `恭喜复仇成功,获得双倍奖励`
} else {
this.winInfoRichText.string = `你击败了【${g.battleData.enemyName}】的队伍`;
}
// let img: SpriteFrame = await ResourcesUtils.load("prizeImg/prize1/spriteFrame", SpriteFrame, this.node);
// this.winGiftSprite.spriteFrame = img;
} else {
this.settlementSound.play(0);
this.loseInfoRichText.string = `你被【${g.battleData.enemyName}】的队伍打败了!`;
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();
}
}