Merge branch 'main' of http://10.27.16.144:3000/kawagiri/TH1
# Conflicts: # My project/Assets/Resources/BT/BT.asset # My project/Assets/Scripts/Logic/AI/AIActionBase.cs
This commit is contained in:
commit
bd073a74c4
File diff suppressed because one or more lines are too long
@ -38,6 +38,7 @@ namespace NodeCanvas.Tasks.Actions
|
||||
data.value.MaxAiAction.CheckIsActionInPlayerSight();
|
||||
data.value.IsInSight = data.value.MaxAiAction.IsInSight;
|
||||
data.value.Time = data.value.MaxAiAction.ActionLogic.GetAnimTime(data.value.MaxAiAction.Param);
|
||||
data.value.MaxAiAction.ActionLogic.CameraControl(data.value.MaxAiAction.Param);
|
||||
EndAction(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -344,7 +344,7 @@ namespace RuntimeData
|
||||
{
|
||||
Turn++;
|
||||
LastAttackPlayers.Clear();
|
||||
foreach (var id in CurAttackPlayers)LastAttackPlayers.Add(id);
|
||||
foreach (var id in CurAttackPlayers) LastAttackPlayers.Add(id);
|
||||
CurAttackPlayers.Clear();
|
||||
for (int i = Skills.Count - 1; i >= 0; i--)
|
||||
{
|
||||
@ -354,6 +354,7 @@ namespace RuntimeData
|
||||
Skills.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
skill.OnTurnStart(this, map);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ namespace Logic.AI
|
||||
EmergencyDefend,
|
||||
Retreat,
|
||||
Common,
|
||||
DefendAttack,
|
||||
None,
|
||||
}
|
||||
|
||||
@ -75,6 +76,7 @@ namespace Logic.AI
|
||||
CityLevelUp,
|
||||
TechGap,
|
||||
TechResource,
|
||||
CityTrainDefendAttack,
|
||||
}
|
||||
|
||||
|
||||
@ -1056,7 +1058,7 @@ namespace Logic.AI
|
||||
{
|
||||
if (target == Player) continue;
|
||||
if (ThreatScore[target.Id] < 10) continue;
|
||||
if (MilitaryGapScore[target.Id] < 2) continue;
|
||||
if (MilitaryGapScore[target.Id] > -5) continue;
|
||||
CountryStrategy = Strategy.Defend;
|
||||
return;
|
||||
}
|
||||
@ -1069,7 +1071,7 @@ namespace Logic.AI
|
||||
threatScore += ThreatScore[target.Id];
|
||||
militaryScore += MilitaryGapScore[target.Id];
|
||||
}
|
||||
if (threatScore >= 20 && militaryScore >= 10)
|
||||
if (threatScore >= 20 && militaryScore <= -10)
|
||||
{
|
||||
CountryStrategy = Strategy.Defend;
|
||||
return;
|
||||
@ -1354,6 +1356,17 @@ namespace Logic.AI
|
||||
selfCity.RemoveAt(i);
|
||||
}
|
||||
|
||||
if (CountryStrategy == Strategy.Defend)
|
||||
{
|
||||
for (int i = selfCity.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var city = selfCity[i];
|
||||
if (CityDefendScore[city.Id] >= 2) continue;
|
||||
CityStrategy[city] = Strategy.DefendAttack;
|
||||
selfCity.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var city in selfCity) CityStrategy.TryAdd(city, CountryStrategy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -698,6 +698,7 @@ namespace Logic.AI
|
||||
if (type == CalculateType.CityTrainDefend) CalculateCityTrainDefend(data, param, result);
|
||||
if (type == CalculateType.CityTrainAttack) CalculateCityTrainAttack(data, param, result);
|
||||
if (type == CalculateType.CityDevelopment) CalculateCityDevelopment(data, param, result);
|
||||
if (type == CalculateType.CityTrainDefendAttack) CalculateCityTrainDefendAttack(data, param, result);
|
||||
|
||||
if (type == CalculateType.LegionDefendKill) CalculateLegionDefendKill(data, param, result);
|
||||
if (type == CalculateType.LegionDefendMove) CalculateLegionDefendMove(data, param, result);
|
||||
@ -912,7 +913,7 @@ namespace Logic.AI
|
||||
|
||||
private static void CalculateCityTrainAttack(AICalculatorData data, CommonActionParams param, CalculateResult result)
|
||||
{
|
||||
float score = 0;
|
||||
if (data.AttackPlayer == null) return;
|
||||
var selfUnits = new HashSet<UnitData>();
|
||||
param.MapData.GetUnitDataListByPlayerId(param.PlayerData.Id, selfUnits);
|
||||
if (!param.MapData.GetGridDataByCityId(param.CityData.Id, out var cityGrid)) return;
|
||||
@ -923,8 +924,8 @@ namespace Logic.AI
|
||||
var targetScore = 0;
|
||||
foreach (var unit in param.MapData.UnitMap.UnitList)
|
||||
{
|
||||
if (!param.MapData.GetGridDataByUnitId(unit.Id, out var unitGrid)) continue;
|
||||
if (param.MapData.GridMap.CalcDistance(cityGrid, unitGrid) > 8) continue;
|
||||
if (!param.MapData.GetPlayerDataByUnitId(unit.Id, out var targetPlayer)) continue;
|
||||
if (!selfUnits.Contains(unit) && targetPlayer.Id != data.AttackPlayer.Id) continue;
|
||||
if (!Table.Instance.UnitTypeDataAssets.GetUnitTypeInfo(unit.UnitType, unit.GiantType, out var info))
|
||||
continue;
|
||||
if (selfUnits.Contains(unit))
|
||||
@ -939,7 +940,7 @@ namespace Logic.AI
|
||||
}
|
||||
}
|
||||
|
||||
score = selfScore - targetScore;
|
||||
float score = selfScore - targetScore;
|
||||
foreach (var selfUnit in units)
|
||||
{
|
||||
foreach (var target in targets)
|
||||
@ -951,6 +952,48 @@ namespace Logic.AI
|
||||
|
||||
result.Score[CalculateType.CityTrainAttack] = score;
|
||||
}
|
||||
|
||||
private static void CalculateCityTrainDefendAttack(AICalculatorData data, CommonActionParams param, CalculateResult result)
|
||||
{
|
||||
if (data.AttackPlayer == null) return;
|
||||
var selfUnits = new HashSet<UnitData>();
|
||||
param.MapData.GetUnitDataListByPlayerId(param.PlayerData.Id, selfUnits);
|
||||
if (!param.MapData.GetGridDataByCityId(param.CityData.Id, out var cityGrid)) return;
|
||||
|
||||
var units = new HashSet<UnitData>();
|
||||
var targets = new HashSet<UnitData>();
|
||||
var selfScore = 0;
|
||||
var targetScore = 0;
|
||||
foreach (var unit in param.MapData.UnitMap.UnitList)
|
||||
{
|
||||
if (!param.MapData.GetPlayerDataByUnitId(unit.Id, out var targetPlayer)) continue;
|
||||
if (!selfUnits.Contains(unit) && !data.Player.LastAttackPlayers.Contains(targetPlayer.Id)) continue;
|
||||
if (!Table.Instance.UnitTypeDataAssets.GetUnitTypeInfo(unit.UnitType, unit.GiantType, out var info))
|
||||
continue;
|
||||
if (selfUnits.Contains(unit))
|
||||
{
|
||||
units.Add(unit);
|
||||
selfScore += info.Cost;
|
||||
}
|
||||
else
|
||||
{
|
||||
targets.Add(unit);
|
||||
targetScore += info.Cost;
|
||||
}
|
||||
}
|
||||
|
||||
float score = selfScore - targetScore;
|
||||
foreach (var selfUnit in units)
|
||||
{
|
||||
foreach (var target in targets)
|
||||
{
|
||||
score += data.CalUnitCounterScore(selfUnit, target) * 2;
|
||||
score -= data.CalUnitCounterScore(target, selfUnit);
|
||||
}
|
||||
}
|
||||
|
||||
result.Score[CalculateType.CityTrainDefendAttack] = score;
|
||||
}
|
||||
|
||||
private static void CalculateCityTrainDefend(AICalculatorData data, CommonActionParams param, CalculateResult result)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user