mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
临时提交
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
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(double 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,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BehaviorTreeSlayer
|
||||
{
|
||||
public class RandomCall : ConditionalNode
|
||||
{
|
||||
[OutField]
|
||||
public double Rand=0.2;
|
||||
[OutField]
|
||||
public double Freq=1;
|
||||
[ShowMe]
|
||||
double timer;
|
||||
public override bool Check(double dt, object args)
|
||||
{
|
||||
timer += dt;
|
||||
if (timer > Freq)
|
||||
{
|
||||
timer = 0;
|
||||
IsConditionOK = (args as BehaviorTree).MyRandom.NextDouble() < 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