rp_11001/assets/Game/scripts/game/IconMsg.ts
TJH 166a896c3e
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m15s
iconmsg修改
2025-12-29 11:00:56 +08:00

173 lines
6.5 KiB
TypeScript

import { _decorator, Component, instantiate, Label, Node, sp, Sprite, SpriteFrame, UITransform } from 'cc';
import { I18nManager } from '../../../Loading/scripts/manager/I18nManager';
import { Icon } from './Icon';
import { ICON_RATE } from './Define';
import { AudioManager } from 'db://assets/Loading/scripts/manager/AudioManager';
const { ccclass, property } = _decorator;
@ccclass('IconMsg')
export class IconMsg extends Component {
@property(Node)
leftNode: Node = null;
@property(Node)
rightNode: Node = null;
@property([SpriteFrame])
zxkFrames: SpriteFrame[] = [];
iconComponent: Icon = null;
ui_payout: Node = null;
ui_payout_wild: Node = null;
ui_payout_scatter: Node = null;
multi: Node = null;
sprite_wild: Node = null;
sprite_scatter: Node = null;
right_ui_payout: Node = null;
right_ui_payout_wild: Node = null;
right_ui_payout_scatter: Node = null;
right_multi: Node = null;
right_sprite_wild: Node = null;
right_sprite_scatter: Node = null;
// 高度映射表 - 减少重复计算
HEIGHT_MAP = {
1: 190,
2: 190 + 170,
3: 190 + 170 * 2,
4: 200 + 170 * 3
};
show(isLeft: boolean, iconComponent: Icon) {
AudioManager.instance.playSFX('Appear_Window_Sound');
this.iconComponent = iconComponent;
this.leftNode.active = false;
this.rightNode.active = false;
this.ui_payout = this.leftNode.getChildByName('ui_payout');
this.ui_payout_wild = this.leftNode.getChildByName('ui_payout_wild');
this.ui_payout_scatter = this.leftNode.getChildByName('ui_payout_scatter');
this.multi = this.leftNode.getChildByName('multi');
this.sprite_wild = this.leftNode.getChildByName('sprite_wild');
this.sprite_scatter = this.leftNode.getChildByName('sprite_scatter');
this.ui_payout.getComponent(UITransform).height = this.HEIGHT_MAP[iconComponent.lHeight];
this.ui_payout_wild.getComponent(UITransform).height = this.HEIGHT_MAP[iconComponent.lHeight];
this.ui_payout_scatter.getComponent(UITransform).height = this.HEIGHT_MAP[iconComponent.lHeight];
this.ui_payout.getComponent(Sprite).spriteFrame = this.zxkFrames[iconComponent.lHeight - 1]
this.ui_payout_wild.getComponent(Sprite).spriteFrame = this.zxkFrames[iconComponent.lHeight - 1]
this.ui_payout_scatter.getComponent(Sprite).spriteFrame = this.zxkFrames[iconComponent.lHeight - 1]
this.right_ui_payout = this.rightNode.getChildByName('ui_payout');
this.right_ui_payout_wild = this.rightNode.getChildByName('ui_payout_wild');
this.right_ui_payout_scatter = this.rightNode.getChildByName('ui_payout_scatter');
this.right_multi = this.rightNode.getChildByName('multi');
this.right_sprite_wild = this.rightNode.getChildByName('sprite_wild');
this.right_sprite_scatter = this.rightNode.getChildByName('sprite_scatter');
this.right_ui_payout.getComponent(UITransform).height = this.HEIGHT_MAP[iconComponent.lHeight];
this.right_ui_payout_wild.getComponent(UITransform).height = this.HEIGHT_MAP[iconComponent.lHeight];
this.right_ui_payout_scatter.getComponent(UITransform).height = this.HEIGHT_MAP[iconComponent.lHeight];
this.right_ui_payout.getComponent(Sprite).spriteFrame = this.zxkFrames[iconComponent.lHeight - 1]
this.right_ui_payout_wild.getComponent(Sprite).spriteFrame = this.zxkFrames[iconComponent.lHeight - 1]
this.right_ui_payout_scatter.getComponent(Sprite).spriteFrame = this.zxkFrames[iconComponent.lHeight - 1]
this.ui_payout.active = false;
this.ui_payout_wild.active = false;
this.ui_payout_scatter.active = false;
this.right_ui_payout.active = false;
this.right_ui_payout_wild.active = false;
this.right_ui_payout_scatter.active = false;
this.multi.active = false;
this.sprite_wild.active = false;
this.sprite_scatter.active = false;
this.right_multi.active = false;
this.right_sprite_wild.active = false;
this.right_sprite_scatter.active = false;
if (iconComponent.index == 0) {
this.ui_payout_wild.active = true;
this.sprite_wild.active = true;
this.right_ui_payout_wild.active = true;
this.right_sprite_wild.active = true;
} else if (iconComponent.index == 1) {
this.ui_payout_scatter.active = true;
this.sprite_scatter.active = true;
this.right_ui_payout_scatter.active = true;
this.right_sprite_scatter.active = true;
} else {
this.ui_payout.active = true;
this.multi.active = true;
this.right_ui_payout.active = true;
this.right_multi.active = true;
}
if (isLeft) {
this.leftNode.active = true;
this.setLeftMsg();
} else {
this.rightNode.active = true;
this.setRightMsg();
}
}
setLeftMsg() {
let iconNode = instantiate(this.iconComponent.node);
iconNode.setParent(this.leftNode.getChildByName('node'));
iconNode.setPosition(0, 0, 0);
this.scheduleOnce(() => {
iconNode.getComponent(Icon).index = this.iconComponent.index;
iconNode.getComponent(Icon).hideNormalSprite();
iconNode.getComponent(Icon).playSpawnAni();
})
this.multi.children.forEach((child, index) => {
let multi = ICON_RATE[this.iconComponent.index][index];
child.getChildByName('multi').getComponent(Label).string = multi.toString();
})
}
setRightMsg() {
let iconNode = instantiate(this.iconComponent.node);
iconNode.setParent(this.rightNode.getChildByName('node'));
iconNode.setPosition(0, 0, 0);
this.scheduleOnce(() => {
iconNode.getComponent(Icon).index = this.iconComponent.index;
iconNode.getComponent(Icon).hideNormalSprite();
iconNode.getComponent(Icon).playSpawnAni();
})
this.right_multi.children.forEach((child, index) => {
let multi = ICON_RATE[this.iconComponent.index][index];
child.getChildByName('multi').getComponent(Label).string = multi.toString();
})
}
hide() {
this.leftNode.getChildByName('node').children.forEach(child => {
child.destroy();
})
this.rightNode.getChildByName('node').children.forEach(child => {
child.destroy();
})
}
}