AI科技接入

This commit is contained in:
wuwenbo 2025-05-15 18:00:16 +08:00
parent ba3d2eb63f
commit b2b3e998c9
4 changed files with 37 additions and 4 deletions

View File

@ -25,6 +25,7 @@ MonoBehaviour:
UnitExploreTreasureScore: 10
UnitExploreStarfishScore: 5
FutureScoreTransformValue: 0.5
MilitaryConstructionRatioValue: 0
TechInfoList:
- TechType: 1
Ratio: 1

View File

@ -82,7 +82,9 @@ namespace Logic.AI
private HashSet<UnitData> _unitOnCity;
private UnitTargetMap _unitTargetMap;
private List<CommonActionId> _actionList;
private AITechScoreCalculator _techCalculator;
public AITechScoreCalculator TechScoreCalculator => _techCalculator;
public HashSet<GridData> CanMoveGrid => _canMoveGrid;
public Dictionary<UnitData, float> UnitScore => _unitScore;
public Dictionary<CityData, float> CityScore => _cityScore;
@ -536,8 +538,15 @@ namespace Logic.AI
public void CalculateTechScore(MapData mapData, PlayerData playerData, CalculateResult result, TechType techType)
{
var ratio = _cfg.GetTechInfo(techType).Ratio;
result.ScoreDict[AICalculatorType.TechScore] = AITechScoreCalculator.CalculateTechScore(mapData, playerData, techType) * ratio;
_techCalculator ??= new AITechScoreCalculator();
var techInfo = _cfg.GetTechInfo(techType);
if (techInfo == null)
{
Debug.LogWarning($"找不到科技信息,科技类型:{techType}");
return;
}
result.ScoreDict[AICalculatorType.TechScore] = _techCalculator.CalculateTechScorePro(mapData, playerData, techType, _cfg) * techInfo.Ratio;
}
}

View File

@ -16,7 +16,7 @@ namespace RuntimeData
{
public class AchievementDataManager
{
public static AchievementDataManager Instance;
public static AchievementDataManager Instance = new AchievementDataManager();
public AchievementAsset Achievement;
public List<uint> FinishedCache;

View File

@ -35,9 +35,12 @@ namespace Logic.Editor
private AIConfigAsset _asset;
private AIActionScoreCalculator _calculator;
private Main _main;
private PlayerData _player;
private CalculateResult _result;
private uint _curPlayerId;
private EditorType _editorType;
private bool _isShowTechScore;
private AITechScoreCalculator _techCalculator;
[MenuItem("Tools/AI 编辑器")]
@ -232,6 +235,7 @@ namespace Logic.Editor
{
_curPlayerId = player.Id;
_result = _calculator.CalculateScore(_main.MapData, player, _asset);
_player = player;
}
}
else
@ -240,6 +244,7 @@ namespace Logic.Editor
{
_curPlayerId = player.Id;
_result = _calculator.CalculateScore(_main.MapData, player, _asset);
_player = player;
}
}
}
@ -288,6 +293,24 @@ namespace Logic.Editor
EditorGUILayout.BeginHorizontal();
InspectorUtils.InspectorTextWidthRich($"策略总评分: {_result.GetAllScore()}");
EditorGUILayout.EndHorizontal();
_isShowTechScore = EditorGUILayout.Toggle(_isShowTechScore, GUILayout.Width(16));
if (_isShowTechScore) OnGUITechScore();
}
private void OnGUITechScore()
{
InspectorUtils.InspectorTextWidthRich($"----------------------------------------------------");
InspectorUtils.InspectorTextWidthRich($"----------------------------------------------------");
_techCalculator ??= new AITechScoreCalculator();
foreach (TechType t in System.Enum.GetValues(typeof(TechType)))
{
if (t == TechType.None) continue;
var score = _techCalculator.CalculateTechScorePro(_main.MapData, _player, t, _asset);
EditorGUILayout.BeginHorizontal();
InspectorUtils.InspectorTextWidthRich($"科技 {t} 学习后得分为: {score * _asset.GetTechInfo(t).Ratio}");
EditorGUILayout.EndHorizontal();
}
}
}
}