行为树节点参数添加复合类型参数,更新demo

This commit is contained in:
gongxh
2025-09-18 22:51:27 +08:00
parent f60bf869a1
commit 50e29feeb8
7 changed files with 141 additions and 171 deletions

View File

@@ -7,6 +7,33 @@
import { sp } from "cc";
import { BT } from "./Header";
@BT.ClassAction("BTTestNode", { name: "嵌套数据测试节点", group: "测试", desc: "测试节点" })
export class BTTestNode extends BT.LeafNode {
@BT.prop({
type: BT.ParamType.object,
properties: {
x: { type: BT.ParamType.int, min: 0 },
y: { type: BT.ParamType.int, min: 0 }
}
})
position: { x: number, y: number };
// 对象数组参数
@BT.prop({
type: BT.ParamType.array,
itemType: BT.ParamType.object,
itemProperties: {
name: { type: BT.ParamType.string },
value: { type: BT.ParamType.int }
}
})
configs: Array<{ name: string, value: number }>;
public tick(): BT.Status {
return BT.Status.SUCCESS;
}
}
@BT.ClassAction("BTAnimation", { name: "播放动画", group: "动画", desc: "通过动画名播放动画,播放完成后返回成功" })
export class BTAnimation extends BT.LeafNode {
@BT.prop({ type: BT.ParamType.string, description: "动画名" })
@@ -54,7 +81,7 @@ export class BTConditionRandom extends BT.Condition {
private _value: number = 0.5;
public isEligible(): boolean {
return Math.random() > this._value;
return Math.random() < this._value;
}
}