85 lines
2.2 KiB
TypeScript
85 lines
2.2 KiB
TypeScript
|
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) {
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|