super-hero/assets/cc-game/scripts/game_play/skill-active/SkillActiveItemUI.ts

54 lines
1.2 KiB
TypeScript

import { Sprite } from 'cc';
import { _decorator, Component, Node } from 'cc';
import { SkillUseInfo } from '../../global/GameInterface';
import { Color } from 'cc';
import { Button } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('SkillActiveItemUI')
export class SkillActiveItemUI extends Component {
@property(Button) btn: Button = null!;
@property(Sprite) theme: Sprite = null!;
@property(Node) activeFlag: Node = null!;
mana = 10;
isUsing = false;
tag = -1;
public onClicked: ((tag: number) => void) | undefined;
protected onLoad(): void {
this.btn?.node.on(Button.EventType.CLICK, this.onBtnClicked, this);
this.setActive(false);
}
onBtnClicked()
{
if (this.isUsing) return;
this.onClicked?.(this.tag);
}
setSkillInfo(tag, mana)
{
this.tag = tag;
this.mana = mana;
}
updateMana(heroMana)
{
this.setActive(heroMana >= this.mana);
}
setActive(isActive)
{
this.node?.setNodeActive(isActive);
}
showSkill(isShow: boolean)
{
this.isUsing = isShow;
this.activeFlag.setNodeActive(isShow);
this.node?.setNodeActive(isShow);
}
}