58 lines
1.7 KiB
C#
58 lines
1.7 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 AIParamAroundOtherCity : BaseActionTask
|
|
{
|
|
protected override string desc => $"(移动力+射程)周围有敌方城市";
|
|
|
|
|
|
protected override void OnExecute()
|
|
{
|
|
base.OnExecute();
|
|
// 直接从Blackboard获取AICalculatorData
|
|
var data = blackboard.GetVariable<AICalculatorData>("Data");
|
|
if (data?.value?.TargetParam.UnitData == null)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
var map = data.value.TargetParam.MapData;
|
|
var selfUnit = data.value.TargetParam.UnitData;
|
|
var selfGrid = selfUnit.Grid(map);
|
|
var selfPlayer = selfUnit.Player(map);
|
|
if (selfGrid != null && selfPlayer != null)
|
|
{
|
|
var range = selfUnit.GetMoveRange(map) + selfUnit.GetAttackRange(map);
|
|
var arounds = data.value.TargetParam.MapData.GridMap.GetAroundGridData(range, range, selfGrid);
|
|
foreach (var around in arounds)
|
|
{
|
|
if (around == selfGrid) continue;
|
|
var city = around.City(map);
|
|
if (city == null) continue;
|
|
if (map.IsLeagueUnitByCity(city.Id, selfUnit.Id)) continue;
|
|
EndAction(true);
|
|
return;
|
|
}
|
|
}
|
|
|
|
EndAction(false);
|
|
}
|
|
}
|
|
} |