60 lines
1.4 KiB
C#
60 lines
1.4 KiB
C#
/*
|
|
* @Author: 白哉
|
|
* @Description:
|
|
* @Date: 2025年06月06日 星期五 19:06:16
|
|
* @Modify:
|
|
*/
|
|
|
|
|
|
using System;
|
|
using Logic.AI;
|
|
using NodeCanvas.Framework;
|
|
using ParadoxNotion.Design;
|
|
|
|
|
|
namespace NodeCanvas.Tasks.Actions
|
|
{
|
|
[Name("回合数限制")]
|
|
[Category("AI节点")]
|
|
[Serializable]
|
|
public class AIParamPlayerTurn : BaseActionTask
|
|
{
|
|
public bool GreaterThan = true;
|
|
public int TargetTurn = 5;
|
|
|
|
protected override string desc
|
|
{
|
|
get
|
|
{
|
|
if (GreaterThan) return $"回合数大于等于 {TargetTurn}";
|
|
return $"回合数小于等于 {TargetTurn}";
|
|
}
|
|
}
|
|
|
|
protected override void OnExecute()
|
|
{
|
|
base.OnExecute();
|
|
// 直接从Blackboard获取AICalculatorData
|
|
var data = blackboard.GetVariable<AICalculatorData>("Data");
|
|
if (data?.value?.TargetParam?.PlayerData == null)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
var player = data.value.TargetParam.PlayerData;
|
|
if (GreaterThan && player.Turn >= TargetTurn)
|
|
{
|
|
EndAction(true);
|
|
return;
|
|
}
|
|
if (!GreaterThan && player.Turn <= TargetTurn)
|
|
{
|
|
EndAction(true);
|
|
return;
|
|
}
|
|
|
|
EndAction(false);
|
|
}
|
|
}
|
|
} |