增加自动调试版本
This commit is contained in:
parent
4b91f841dc
commit
9e9da24d1d
@ -27,7 +27,7 @@ MonoBehaviour:
|
|||||||
_version: 3.33
|
_version: 3.33
|
||||||
_category:
|
_category:
|
||||||
_comments:
|
_comments:
|
||||||
_translation: {x: 443, y: 169}
|
_translation: {x: -215, y: 43}
|
||||||
_zoomFactor: 1
|
_zoomFactor: 1
|
||||||
_haltSerialization: 0
|
_haltSerialization: 0
|
||||||
_externalSerializationFile: {fileID: 0}
|
_externalSerializationFile: {fileID: 0}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* @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
|
||||||
|
{
|
||||||
|
[Category("AIAction")]
|
||||||
|
[Serializable]
|
||||||
|
public class AIParamCityUnitCountLimit : ActionTask
|
||||||
|
{
|
||||||
|
public bool IsGreater;
|
||||||
|
public int Count;
|
||||||
|
|
||||||
|
protected override string info
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsGreater) return string.Format($" 城市人数大于 {Count}");
|
||||||
|
return string.Format($" 城市人数小于 {Count}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnExecute()
|
||||||
|
{
|
||||||
|
// 直接从Blackboard获取AICalculatorData
|
||||||
|
var data = blackboard.GetVariable<AICalculatorData>("Data");
|
||||||
|
if (data?.value?.TargetParam.CityData == null)
|
||||||
|
{
|
||||||
|
EndAction(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var city = data.value.TargetParam.CityData;
|
||||||
|
var count = data.value.TargetParam.MapData.GetUnitCount(city.Id);
|
||||||
|
if (IsGreater) EndAction(count > Count);
|
||||||
|
else EndAction(count < Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 29d035e4d96c480f8094efcdb6370f03
|
||||||
|
timeCreated: 1752045507
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* @Author: 白哉
|
||||||
|
* @Description:
|
||||||
|
* @Date: 2025年06月06日 星期五 19:06:16
|
||||||
|
* @Modify:
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Logic.AI;
|
||||||
|
using NodeCanvas.Framework;
|
||||||
|
using ParadoxNotion.Design;
|
||||||
|
using RuntimeData;
|
||||||
|
|
||||||
|
|
||||||
|
namespace NodeCanvas.Tasks.Actions
|
||||||
|
{
|
||||||
|
[Category("AIAction")]
|
||||||
|
[Serializable]
|
||||||
|
public class AIParamCityUnitRatio : ActionTask
|
||||||
|
{
|
||||||
|
public bool IsGreater;
|
||||||
|
public float Ratio;
|
||||||
|
|
||||||
|
protected override string info
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsGreater) return string.Format($" 城市人数大于 {Ratio}%");
|
||||||
|
return string.Format($" 城市人数小于 {Ratio}%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnExecute()
|
||||||
|
{
|
||||||
|
// 直接从Blackboard获取AICalculatorData
|
||||||
|
var data = blackboard.GetVariable<AICalculatorData>("Data");
|
||||||
|
if (data?.value?.TargetParam.CityData == null)
|
||||||
|
{
|
||||||
|
EndAction(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var city = data.value.TargetParam.CityData;
|
||||||
|
var ratio = data.value.TargetParam.MapData.GetUnitCount(city.Id) / city.Level;
|
||||||
|
if (IsGreater) EndAction(ratio > Ratio);
|
||||||
|
else EndAction(ratio < Ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: abb10756c33f47afb2658b47439ba2c7
|
||||||
|
timeCreated: 1752045263
|
||||||
@ -1536,8 +1536,8 @@ namespace Logic.AI
|
|||||||
var dis = Map.GridMap.CalcDistance(unitGrid, cityGrid);
|
var dis = Map.GridMap.CalcDistance(unitGrid, cityGrid);
|
||||||
ratio = dis switch
|
ratio = dis switch
|
||||||
{
|
{
|
||||||
0 => 3,
|
0 => 4,
|
||||||
1 => 2,
|
1 => 3,
|
||||||
2 => 1,
|
2 => 1,
|
||||||
3 => 0,
|
3 => 0,
|
||||||
_ => ratio
|
_ => ratio
|
||||||
@ -1553,8 +1553,8 @@ namespace Logic.AI
|
|||||||
var dis = Map.GridMap.CalcDistance(unitGrid, cityGrid);
|
var dis = Map.GridMap.CalcDistance(unitGrid, cityGrid);
|
||||||
ratio = dis switch
|
ratio = dis switch
|
||||||
{
|
{
|
||||||
0 => 3,
|
0 => 4,
|
||||||
1 => 2,
|
1 => 3,
|
||||||
2 => 1,
|
2 => 1,
|
||||||
3 => 0,
|
3 => 0,
|
||||||
_ => ratio
|
_ => ratio
|
||||||
|
|||||||
47
My project/Assets/Scripts/Logic/Editor/BuildManager.cs
Normal file
47
My project/Assets/Scripts/Logic/Editor/BuildManager.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Logic.Editor
|
||||||
|
{
|
||||||
|
public class BuildManager
|
||||||
|
{
|
||||||
|
// 定义宏名称
|
||||||
|
public const string GAME_AUTO_DEBUG = "GAME_AUTO_DEBUG";
|
||||||
|
|
||||||
|
|
||||||
|
// 添加宏定义
|
||||||
|
[MenuItem("Build/开启全自动模式")]
|
||||||
|
public static void AddMacro()
|
||||||
|
{
|
||||||
|
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone);
|
||||||
|
|
||||||
|
if (!defines.Contains(GAME_AUTO_DEBUG))
|
||||||
|
{
|
||||||
|
defines = string.IsNullOrEmpty(defines)
|
||||||
|
? GAME_AUTO_DEBUG
|
||||||
|
: defines + ";" + GAME_AUTO_DEBUG;
|
||||||
|
|
||||||
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, defines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 移除宏定义
|
||||||
|
[MenuItem("Build/关闭全自动模式")]
|
||||||
|
public static void RemoveMacro()
|
||||||
|
{
|
||||||
|
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone);
|
||||||
|
|
||||||
|
if (defines.Contains(GAME_AUTO_DEBUG))
|
||||||
|
{
|
||||||
|
defines = defines.Replace($"{GAME_AUTO_DEBUG};", "")
|
||||||
|
.Replace($";{GAME_AUTO_DEBUG}", "")
|
||||||
|
.Replace(GAME_AUTO_DEBUG, "")
|
||||||
|
.Replace(";;", ";")
|
||||||
|
.Trim(';');
|
||||||
|
|
||||||
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, defines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8640a67a3b834c90bf7ce4a9063fc7c1
|
||||||
|
timeCreated: 1752049414
|
||||||
@ -111,6 +111,8 @@ namespace Logic
|
|||||||
|
|
||||||
public class PlayerRoundState : GameStateBase
|
public class PlayerRoundState : GameStateBase
|
||||||
{
|
{
|
||||||
|
private AILogic _aiLogic;
|
||||||
|
|
||||||
public PlayerRoundState(GameLogic gameLogic) : base(gameLogic)
|
public PlayerRoundState(GameLogic gameLogic) : base(gameLogic)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -131,8 +133,6 @@ namespace Logic
|
|||||||
_gameLogic.Main.MapData.CityMap.OnTurnStart(_gameLogic.Main.MapData, _curPlayer);
|
_gameLogic.Main.MapData.CityMap.OnTurnStart(_gameLogic.Main.MapData, _curPlayer);
|
||||||
_gameLogic.Main.MapData.UnitMap.OnTurnStart(_gameLogic.Main.MapData, _curPlayer);
|
_gameLogic.Main.MapData.UnitMap.OnTurnStart(_gameLogic.Main.MapData, _curPlayer);
|
||||||
_gameLogic.Main.MapData.GridMap.OnTurnStart(_gameLogic.Main.MapData);
|
_gameLogic.Main.MapData.GridMap.OnTurnStart(_gameLogic.Main.MapData);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_gameLogic.Main.UIManager.EndTurn();
|
_gameLogic.Main.UIManager.EndTurn();
|
||||||
_gameLogic.Main.UIManager.AIPlayingHint.SetActive(false);
|
_gameLogic.Main.UIManager.AIPlayingHint.SetActive(false);
|
||||||
@ -143,6 +143,10 @@ namespace Logic
|
|||||||
//uiManager.EndTurn();
|
//uiManager.EndTurn();
|
||||||
PlayerPrefs.SetInt("Archive", 1);
|
PlayerPrefs.SetInt("Archive", 1);
|
||||||
MapData.SaveMapData(_gameLogic.Main.MapData);
|
MapData.SaveMapData(_gameLogic.Main.MapData);
|
||||||
|
|
||||||
|
#if GAME_AUTO_DEBUG
|
||||||
|
_aiLogic = new AILogic();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -154,7 +158,6 @@ namespace Logic
|
|||||||
// TODO endturn逻辑要重新梳理
|
// TODO endturn逻辑要重新梳理
|
||||||
Main.PlayerLogic.EndThisTurn(_gameLogic.Main.MapData, _gameLogic.Main.MapData.PlayerMap.SelfPlayerData);
|
Main.PlayerLogic.EndThisTurn(_gameLogic.Main.MapData, _gameLogic.Main.MapData.PlayerMap.SelfPlayerData);
|
||||||
|
|
||||||
|
|
||||||
//处理当前每一个unit的回合结束前自动行为。每一个选手回合结束自动回血是在这个阶段出发的
|
//处理当前每一个unit的回合结束前自动行为。每一个选手回合结束自动回血是在这个阶段出发的
|
||||||
foreach (var unitData in _gameLogic.Main.MapData.UnitMap.UnitList)
|
foreach (var unitData in _gameLogic.Main.MapData.UnitMap.UnitList)
|
||||||
if(_gameLogic.Main.MapData.GetPlayerDataByUnitId(unitData.Id,out var player)
|
if(_gameLogic.Main.MapData.GetPlayerDataByUnitId(unitData.Id,out var player)
|
||||||
@ -169,7 +172,25 @@ namespace Logic
|
|||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
#if GAME_AUTO_DEBUG
|
||||||
|
if (_aiLogic.AILogicState == AILogicState.Finished)
|
||||||
|
{
|
||||||
|
_gameLogic.ChangeState(GameState.AIRound);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_aiLogic.AILogicState == AILogicState.Prepare)
|
||||||
|
{
|
||||||
|
_curPlayer.PlayerWealth += (int)_curPlayer.Turn / 10;
|
||||||
|
_gameLogic.Main.MapData.PlayerMap.OnTurnStart(_gameLogic.Main.MapData, _curPlayer);
|
||||||
|
_gameLogic.Main.MapData.CityMap.OnTurnStart(_gameLogic.Main.MapData, _curPlayer);
|
||||||
|
_gameLogic.Main.MapData.UnitMap.OnTurnStart(_gameLogic.Main.MapData, _curPlayer);
|
||||||
|
_gameLogic.Main.MapData.GridMap.OnTurnStart(_gameLogic.Main.MapData);
|
||||||
|
_aiLogic.StartAILogic(_gameLogic.Main.MapData, _curPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
_aiLogic.Update();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user