mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 10:46:17 +00:00
提交行为树
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using JNGame.Math;
|
||||
|
||||
namespace BehaviorTreeSlayer
|
||||
{
|
||||
public class EventCaller : ConditionalNode
|
||||
{
|
||||
[OutField]
|
||||
public string Event;
|
||||
public override void Enter(object args)
|
||||
{
|
||||
BehaviorTree tree = (BehaviorTree)args;
|
||||
if (!string.IsNullOrEmpty(Event))
|
||||
tree.Regist(Event, OnEvent);
|
||||
|
||||
}
|
||||
public override void Exit(object args)
|
||||
{
|
||||
|
||||
}
|
||||
private void OnEvent(object obj)
|
||||
{
|
||||
IsConditionOK = true;
|
||||
}
|
||||
public override TaskResult Tick(LFloat dt, object args = null)
|
||||
{
|
||||
return IsConditionOK ? TaskResult.Running : TaskResult.None;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 034fc570e45c74342bba94a7887014bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNGame.Math;
|
||||
|
||||
namespace BehaviorTreeSlayer
|
||||
{
|
||||
public class RandomCall : ConditionalNode
|
||||
{
|
||||
[OutField]
|
||||
public LFloat Rand = new LFloat("",200);
|
||||
[OutField]
|
||||
public LFloat Freq=1;
|
||||
[ShowMe]
|
||||
LFloat timer;
|
||||
public override bool Check(LFloat dt, object args)
|
||||
{
|
||||
timer += dt;
|
||||
if (timer > Freq)
|
||||
{
|
||||
timer = 0;
|
||||
IsConditionOK = (args as IBehaviorTree).RandomFloat() < Rand;
|
||||
}
|
||||
return base.Check(dt, args);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98c39464e2b77524492cfbcf228305fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user