mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
29 lines
665 B
C#
29 lines
665 B
C#
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);
|
|
}
|
|
}
|
|
}
|