You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
937 B
41 lines
937 B
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class RoleMergeScript extends cc.Component {
|
|
|
|
@property(cc.Node)
|
|
mergeNode: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
roleNodeList: cc.Node[] = [];
|
|
|
|
// onLoad () {}
|
|
|
|
start() {
|
|
for (const iterator of this.roleNodeList) {
|
|
iterator.addComponent(RoleScript);
|
|
iterator.attr({ scrRm: this });
|
|
}
|
|
}
|
|
|
|
mergeRoleNode(target) {
|
|
let mActive = true;
|
|
for (const iterator of this.roleNodeList) {
|
|
mActive = iterator.active ? mActive : false;
|
|
}
|
|
if (mActive) {
|
|
this.mergeNode.active = mActive;
|
|
for (const iterator of this.roleNodeList) {
|
|
iterator.active = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
class RoleScript extends cc.Component {
|
|
|
|
protected onEnable(): void {
|
|
(<any>this.node).scrRm.mergeRoleNode(this.node);
|
|
}
|
|
}
|
|
|