squidGame/tgx-games-client/assets/module_basic/red/RedPointInfo.ts

85 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { _decorator, Component, Label, Node } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('RedPointInfo')
export class RedPointInfo extends Component {
// [1]
@property({
type: Node,
displayName: "红点",
})
redNode: Node = null;
@property({ type: Node, displayName: "红点New" })
newNode: Node = null;
@property({ type: Node, displayName: "红点带数字" })
numNode: Node = null;
@property({ type: Label, displayName: "红点数字" })
numNodeText: Label = null;
@property({ type: Node, displayName: "红点绿色" })
blueNode: Node = null;
@property({ type: Node, displayName: "红点满" })
fullNode: Node = null;
private showType: number = -1;
private showCount: number = 0;
start() {
this.updateRedPoint(this.showType, this.showCount);
console.log("RedPointInfo start");
}
/**
*
* @param type -1 不显示0 红点1 new 2数字展示3绿色4满
* @param count
* @param ctrl
*/
public updateRedPoint(type: number = -1, count: number = 0) {
this.showType = type;
this.showCount = count;
if (this.redNode == null) {
return;
}
this.redNode.active = false;
this.newNode.active = false;
this.numNode.active = false;
this.numNodeText.string = '';
this.blueNode.active = false;
this.fullNode.active = false;
switch (type) {
case 0:
this.redNode.active = true;
break;
case 1:
this.newNode.active = true;
break;
case 2:
this.numNode.active = true;
this.numNodeText.string = count.toString();
break;
case 3:
this.blueNode.active = true;
break;
case 4:
this.fullNode.active = true;
break;
}
if (count > 0) {
this.node.getChildByName("effect").active = true;
} else {
this.node.getChildByName("effect").active = false;
}
}
update(deltaTime: number) {
}
}