mirror of
https://github.com/gongxh0901/kunpocc-behaviortree.git
synced 2025-12-26 16:48:56 +00:00
行为树节点参数添加复合类型参数,更新demo
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user