本文整理汇总了Java中com.badlogic.gdx.ai.btree.branch.Selector类的典型用法代码示例。如果您正苦于以下问题:Java Selector类的具体用法?Java Selector怎么用?Java Selector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Selector类属于com.badlogic.gdx.ai.btree.branch包,在下文中一共展示了Selector类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDogBehavior
import com.badlogic.gdx.ai.btree.branch.Selector; //导入依赖的package包/类
private static Task<Dog> createDogBehavior () {
Selector<Dog> selector = new Selector<Dog>();
Parallel<Dog> parallel = new Parallel<Dog>();
selector.addChild(parallel);
CareTask care = new CareTask();
care.urgentProb = 0.8f;
parallel.addChild(care);
parallel.addChild(new AlwaysFail<Dog>(new RestTask()));
Sequence<Dog> sequence = new Sequence<Dog>();
selector.addChild(sequence);
BarkTask bark1 = new BarkTask();
bark1.times = new TriangularIntegerDistribution(1, 5, 2);
sequence.addChild(bark1);
sequence.addChild(new WalkTask());
sequence.addChild(new BarkTask());
sequence.addChild(new MarkTask());
return selector;
}
示例2: createTask
import com.badlogic.gdx.ai.btree.branch.Selector; //导入依赖的package包/类
@SuppressWarnings("unchecked")
Task<T> createTask(String type, String name, String args) {
switch(type) {
case "leaf":
BhLeafTask<T> leaf;// = new RcLeafTask<T>();
//相同的name会缓存
if(name != null) {
leaf = tasksMap.get(name);
if(leaf != null) {
CCLog.debug(TAG, "find same leaf task : " + name);
return leaf;
}
if("debug".equals(args)) {
leaf = new DebugTask(name);
} else {
leaf = new BhLeafTask<T>();
}
tasksMap.put(name, leaf);
return leaf;
} else {
if("debug".equals(args)) {
leaf = new DebugTask(name);
} else {
leaf = new BhLeafTask<T>();
}
}
return leaf;
case "parallel":
if(args == null) {
return new Parallel<T>();
} else {
switch(args) {
case "selector":
return new Parallel<T>(Policy.Selector);
case "sequence":
return new Parallel<T>(Policy.Sequence);
}
CCLog.error(TAG, "pattern fail args = " + args + " need selector or sequence");
return null;
}
case "selector":
return new Selector<T>();
case "sequence":
return new Sequence<T>();
}
CCLog.error(TAG, "not found type : " + type);
return null;
}