(client) chore:Clean code
This commit is contained in:
@ -195,6 +195,8 @@ TilemapRenderer:
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_ForceMeshLod: -1
|
||||
m_MeshLodSelectionBias: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
@ -216,6 +218,7 @@ TilemapRenderer:
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_GlobalIlluminationMeshLod: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
@ -242,37 +245,6 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 613797070}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &309861628
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 309861630}
|
||||
m_Layer: 0
|
||||
m_Name: "\u5B9E\u4F53\u5C42"
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &309861630
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 309861628}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0.17242, y: 0.05575, z: 1}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &613797067
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -290,7 +262,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!114 &613797068
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -388,7 +360,6 @@ MonoBehaviour:
|
||||
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_RequiresDepthTexture: 0
|
||||
m_RequiresColorTexture: 0
|
||||
m_Version: 2
|
||||
m_TaaSettings:
|
||||
m_Quality: 3
|
||||
m_FrameInfluence: 0.1
|
||||
@ -396,6 +367,7 @@ MonoBehaviour:
|
||||
m_MipBias: 0
|
||||
m_VarianceClampScale: 0.9
|
||||
m_ContrastAdaptiveSharpening: 0
|
||||
m_Version: 2
|
||||
--- !u!81 &1057087088
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -546,6 +518,8 @@ TilemapRenderer:
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_ForceMeshLod: -1
|
||||
m_MeshLodSelectionBias: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
@ -567,6 +541,7 @@ TilemapRenderer:
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_GlobalIlluminationMeshLod: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
@ -593,51 +568,6 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 613797070}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1371068281
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1371068282}
|
||||
- component: {fileID: 1371068283}
|
||||
m_Layer: 0
|
||||
m_Name: Loader
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1371068282
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1371068281}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1371068283
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1371068281}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 147e91e6929d90a4fb877c0b0a6b608c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
entityManager: {fileID: 2036983433}
|
||||
--- !u!1 &2036983430
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -655,7 +585,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!4 &2036983432
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -684,8 +614,11 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
isGlobal: 1
|
||||
entityLevel: {fileID: 309861628}
|
||||
entityPrefab: {fileID: 3332598847335032684, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
characterPrefab: {fileID: 0}
|
||||
monsterPrefab: {fileID: 0}
|
||||
buildingPrefab: {fileID: 0}
|
||||
bulletPrefab: {fileID: 0}
|
||||
pickupPrefab: {fileID: 0}
|
||||
defaultEntityPrefab: {fileID: 7975757421877276383, guid: 89661daa5f100c64783f0ad9cd37a7ff, type: 3}
|
||||
--- !u!114 &2036983434
|
||||
MonoBehaviour:
|
||||
@ -716,7 +649,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &2104915507
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -751,6 +684,4 @@ SceneRoots:
|
||||
- {fileID: 1057087090}
|
||||
- {fileID: 613797070}
|
||||
- {fileID: 2104915508}
|
||||
- {fileID: 309861630}
|
||||
- {fileID: 2036983432}
|
||||
- {fileID: 1371068282}
|
||||
|
@ -1,9 +1,7 @@
|
||||
using Data;
|
||||
using Parsing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AI
|
||||
{
|
||||
@ -35,7 +33,7 @@ namespace AI
|
||||
{
|
||||
// 条件函数,返回 true 表示满足条件
|
||||
private Func<Entity.Entity, bool> condition;
|
||||
|
||||
|
||||
public override JobBase GetJob(Entity.Entity target)
|
||||
{
|
||||
// 检查条件是否满足
|
||||
@ -75,5 +73,5 @@ namespace AI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using AI;
|
||||
using Data;
|
||||
using System;
|
||||
|
||||
namespace Utils
|
||||
namespace AI
|
||||
{
|
||||
|
||||
public static class BehaviorTree
|
||||
{
|
||||
/// <summary>
|
@ -1,9 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Base;
|
||||
using Data;
|
||||
using Managers;
|
||||
using Prefab;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AI
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Base
|
||||
@ -8,7 +8,7 @@ namespace Base
|
||||
// 定义渐变方向枚举
|
||||
[AddComponentMenu("UI/Effects/Gradient")]
|
||||
public enum Dir
|
||||
{
|
||||
{
|
||||
Horizontal, // 水平方向
|
||||
Vertical, // 垂直方向
|
||||
}
|
||||
@ -71,7 +71,7 @@ namespace Base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 绘制垂直方向的渐变
|
||||
private void DrawVertical(VertexHelper vh, List<UIVertex> vertices, int count)
|
||||
{
|
||||
|
@ -1,8 +1,7 @@
|
||||
// C#
|
||||
using Managers; // 确保日志命名空间正确
|
||||
using System.Collections;
|
||||
using System.Collections.Generic; // 新增,用于List
|
||||
using Logging;
|
||||
using Managers; // 确保日志命名空间正确
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
@ -18,7 +17,7 @@ namespace Base
|
||||
public GameObject loadingUI;
|
||||
// 假设 CustomProgressBar 是一个自定义组件,其 API 与原代码使用方式一致
|
||||
// 如果这里是 UnityEngine.UI.Image,需要完全改变 Progress 和 Opacity 的实现
|
||||
public Gradient progressBar; // 自定义进度条组件
|
||||
public Gradient progressBar; // 自定义进度条组件
|
||||
public TMP_Text describeText; // 描述文本
|
||||
|
||||
public float duration = 0.5f; // 每个步骤的过渡时间
|
||||
@ -96,7 +95,7 @@ namespace Base
|
||||
// 在 Awake 中初始化管理器列表并注册,确保在 Start 之前完成
|
||||
_managersToLoad = new List<ILaunchManager>
|
||||
{
|
||||
new Logging.LoggerManagerWrapper(), // UnityLogger的包装器
|
||||
Logging.UnityLogger.Instance, // UnityLogger的包装器
|
||||
Managers.DefineManager.Instance,
|
||||
Managers.PackagesImageManager.Instance,
|
||||
Managers.TileManager.Instance,
|
||||
@ -187,7 +186,7 @@ namespace Base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 协程:按顺序加载所有管理器。
|
||||
/// </summary>
|
||||
@ -314,7 +313,7 @@ namespace Base
|
||||
SceneManager.LoadScene(scene);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Base
|
||||
{
|
||||
@ -72,7 +70,7 @@ namespace Base
|
||||
needUpdate = false;
|
||||
return;
|
||||
}
|
||||
if(_visibleWindows.Any(window => window.isInputOccupied))
|
||||
if (_visibleWindows.Any(window => window.isInputOccupied))
|
||||
return;
|
||||
foreach (var window in _allWindows)
|
||||
{
|
||||
@ -114,10 +112,10 @@ namespace Base
|
||||
|
||||
// 显示目标窗口并更新缓存与暂停状态
|
||||
windowToShow.Show();
|
||||
var itick=windowToShow as ITickUI;
|
||||
var itick = windowToShow as ITickUI;
|
||||
if (itick != null)
|
||||
Base.Clock.AddTickUI(itick);
|
||||
|
||||
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
@ -202,7 +200,7 @@ namespace Base
|
||||
protected override void OnStart()
|
||||
{
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
|
||||
|
||||
RegisterAllWindows();
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace CameraControl
|
||||
private bool _isDragging = false;
|
||||
|
||||
private Camera _camera;
|
||||
|
||||
|
||||
private int dimensionId;
|
||||
private string[] dimensionList;
|
||||
|
||||
@ -46,7 +46,7 @@ namespace CameraControl
|
||||
// 这确保了如果CameraControl是DontDestroyOnLoad,在切换场景后也能正确工作。
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Init()
|
||||
{
|
||||
@ -68,7 +68,7 @@ namespace CameraControl
|
||||
|
||||
// 初始化维度数据 (假设 Program.Instance 总是已初始化)
|
||||
dimensionId = 0; // 默认从第一个维度开始
|
||||
dimensionList = Program.Instance.Dimensions;
|
||||
dimensionList = Program.Instance.Dimensions;
|
||||
if (dimensionList != null && dimensionList.Length > 0)
|
||||
{
|
||||
SetCameraPositionForDimension(0);
|
||||
@ -78,7 +78,7 @@ namespace CameraControl
|
||||
Debug.LogWarning("Dimension list is empty or null from Program.Instance. Cannot set initial camera position for dimensions.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void NextDimension()
|
||||
{
|
||||
if (_camera == null)
|
||||
@ -94,10 +94,10 @@ namespace CameraControl
|
||||
|
||||
// 1. 保存当前相机的真实位置到当前维度 (假设 Program.Instance 总是已初始化)
|
||||
// 维度ID范围检查仍然保留,因为这是数组访问的安全保障
|
||||
if (dimensionId >= 0 && dimensionId < dimensionList.Length)
|
||||
if (dimensionId >= 0 && dimensionId < dimensionList.Length)
|
||||
{
|
||||
// Program.Instance 假设不会为 null
|
||||
var currentDimension = Program.Instance.GetDimension(dimensionList[dimensionId]);
|
||||
var currentDimension = Program.Instance.GetDimension(dimensionList[dimensionId]);
|
||||
if (currentDimension != null)
|
||||
{
|
||||
currentDimension.cameraPosition = _camera.transform.position;
|
||||
@ -135,7 +135,7 @@ namespace CameraControl
|
||||
// Program.Instance 假设不会为 null
|
||||
|
||||
// 确保获取到的 Dimension 对象不为 null
|
||||
var dimension = Program.Instance.GetDimension(dimensionList[id]);
|
||||
var dimension = Program.Instance.GetDimension(dimensionList[id]);
|
||||
if (dimension)
|
||||
{
|
||||
Vector3 cameraPosition = dimension.cameraPosition;
|
||||
@ -152,7 +152,7 @@ namespace CameraControl
|
||||
if (_camera == null) return; // 确保相机存在
|
||||
|
||||
// 假设 Program.Instance 总是已初始化
|
||||
if (Program.Instance.FocusedEntity)
|
||||
if (Program.Instance.FocusedEntity)
|
||||
{
|
||||
var targetPosition = new Vector3(
|
||||
Program.Instance.FocusedEntity.Position.x,
|
||||
@ -171,7 +171,7 @@ namespace CameraControl
|
||||
NextDimension();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void TickUI()
|
||||
{
|
||||
if (!_camera) // 确保相机存在
|
||||
@ -199,7 +199,7 @@ namespace CameraControl
|
||||
_dragOrigin = _camera.ScreenToWorldPoint(Input.mousePosition);
|
||||
_isDragging = true;
|
||||
// 假设 Program.Instance 总是已初始化
|
||||
if (Program.Instance.FocusedEntity)
|
||||
if (Program.Instance.FocusedEntity)
|
||||
{
|
||||
Program.Instance.FocusedEntity.PlayerControlled = false;
|
||||
Program.Instance.SetFocusedEntity(null);
|
||||
|
@ -1,13 +1,10 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using Formatting = Newtonsoft.Json.Formatting;
|
||||
|
||||
namespace Configs
|
||||
@ -182,7 +179,7 @@ namespace Configs
|
||||
var xmlFiles = Directory.GetFiles(dir, "*.xml", SearchOption.AllDirectories);
|
||||
xmlFilePaths.AddRange(xmlFiles);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -275,7 +272,7 @@ namespace Configs
|
||||
|
||||
// 加载指定路径下的所有资源
|
||||
var resources = Resources.LoadAll<T>(path);
|
||||
|
||||
|
||||
foreach (var resource in resources)
|
||||
{
|
||||
if (resource != null)
|
||||
|
@ -7,10 +7,10 @@ namespace Data
|
||||
public class BehaviorTreeDef : Define
|
||||
{
|
||||
public BehaviorTreeDef[] childTree;
|
||||
public string className= "ThinkNode_Selector";
|
||||
public string className = "ThinkNode_Selector";
|
||||
public string value;
|
||||
|
||||
|
||||
|
||||
|
||||
public override bool Init(XElement xmlDef)
|
||||
{
|
||||
base.Init(xmlDef);
|
||||
@ -23,7 +23,7 @@ namespace Data
|
||||
var xElements = nodes as XElement[] ?? nodes.ToArray();
|
||||
if (!xElements.Any())
|
||||
return true; // 没有子节点也是有效的
|
||||
|
||||
|
||||
List<BehaviorTreeDef> children = new();
|
||||
foreach (var node in xElements)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace Data
|
||||
{
|
||||
public class BulletDef:EntityDef
|
||||
public class BulletDef : EntityDef
|
||||
{
|
||||
public string className;
|
||||
public string value;
|
||||
|
@ -1,10 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public class CharacterDef : EntityDef
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
@ -1,3 +1,4 @@
|
||||
using Configs;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@ -5,9 +6,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using Configs;
|
||||
using UnityEngine;
|
||||
using Object = System.Object;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ namespace Data
|
||||
public DrawNodeDef rangedAttack_up;
|
||||
public DrawNodeDef rangedAttack_left;
|
||||
public DrawNodeDef rangedAttack_right;
|
||||
|
||||
|
||||
public DrawNodeDef GetDrawNodeDef(EntityState state, Orientation orientation,
|
||||
out Orientation? fallbackOrientation)
|
||||
{
|
||||
@ -237,7 +237,7 @@ namespace Data
|
||||
{
|
||||
base.Init(xmlDef);
|
||||
|
||||
nodeName = xmlDef.Attribute("name")?.Value??"noName";
|
||||
nodeName = xmlDef.Attribute("name")?.Value ?? "noName";
|
||||
position = StringToVector(xmlDef.Attribute("position")?.Value ?? "(0 0)");
|
||||
FPS = float.TryParse(xmlDef.Attribute("FPS")?.Value, out var result) ? result : 1.0f;
|
||||
return false;
|
||||
|
@ -1,8 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public class EntityDef : Define
|
||||
|
@ -46,5 +46,5 @@ namespace Data
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
namespace Data
|
||||
{
|
||||
public class MonsterDef:EntityDef
|
||||
public class MonsterDef : EntityDef
|
||||
{
|
||||
public WeaponDef weapon;
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ namespace Entity
|
||||
attackTargetCount = def.attackTargetCount;
|
||||
}
|
||||
public Attributes()
|
||||
{}
|
||||
{ }
|
||||
}
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
using Base;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity
|
||||
{
|
||||
public class Building:Entity
|
||||
public class Building : Entity
|
||||
{
|
||||
public override void SetTarget(Vector3 pos)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ using UnityEngine;
|
||||
|
||||
namespace Entity
|
||||
{
|
||||
public class BuildingOutline:Outline
|
||||
public class BuildingOutline : Outline
|
||||
{
|
||||
public BoxCollider2D boxCollider;
|
||||
override public void Init()
|
||||
|
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using Base;
|
||||
using Data;
|
||||
using Prefab;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity
|
||||
@ -10,7 +8,7 @@ namespace Entity
|
||||
{
|
||||
public Entity bulletSource;
|
||||
public float lifeTime = 10;
|
||||
|
||||
|
||||
public override void SetTarget(Vector3 pos)
|
||||
{
|
||||
base.SetTarget(pos);
|
||||
@ -20,7 +18,7 @@ namespace Entity
|
||||
protected override void AutoBehave()
|
||||
{
|
||||
TryMove();
|
||||
lifeTime-=Time.deltaTime;
|
||||
lifeTime -= Time.deltaTime;
|
||||
if (lifeTime <= 0)
|
||||
{
|
||||
Kill();
|
||||
@ -55,7 +53,7 @@ namespace Entity
|
||||
|
||||
// 计算当前向上方向与目标方向之间的角度
|
||||
var angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg;
|
||||
|
||||
|
||||
|
||||
// 应用旋转
|
||||
transform.rotation = Quaternion.Euler(0f, 0f, angle);
|
||||
|
@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Data;
|
||||
using Item;
|
||||
using Managers;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
// 添加 System 命名空间以使用 Action
|
||||
|
||||
namespace Entity
|
||||
@ -29,7 +25,7 @@ namespace Entity
|
||||
}
|
||||
|
||||
public Inventory Inventory { get; private set; }
|
||||
|
||||
|
||||
|
||||
public override void Init(EntityDef entityDef)
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AI;
|
||||
using Base;
|
||||
using Data;
|
||||
using Item;
|
||||
using Managers;
|
||||
using Prefab;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@ -177,7 +177,7 @@ namespace Entity
|
||||
public virtual void Init(EntityDef entityDef)
|
||||
{
|
||||
attributes = new Attributes(entityDef.attributes);
|
||||
aiTree = Utils.BehaviorTree.ConvertToAIBase(entityDef.behaviorTree);
|
||||
aiTree = AI.BehaviorTree.ConvertToAIBase(entityDef.behaviorTree);
|
||||
affiliation = entityDef.affiliation?.defName;
|
||||
InitBody(entityDef.drawingOrder);
|
||||
this.entityDef = entityDef;
|
||||
@ -219,7 +219,7 @@ namespace Entity
|
||||
// 实例化imagePrefab作为默认占位符
|
||||
targetObj = Instantiate(imagePrefab.gameObject, body.transform);
|
||||
targetObj.name = $"{state}_{orientation}_Default";
|
||||
targetObj.transform.localPosition=Vector3.zero;
|
||||
targetObj.transform.localPosition = Vector3.zero;
|
||||
var imagePrefabCom = targetObj.GetComponent<ImagePrefab>();
|
||||
if (imagePrefabCom != null)
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Item;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity
|
||||
|
@ -4,7 +4,7 @@ using Managers;
|
||||
|
||||
namespace Entity
|
||||
{
|
||||
public class Monster:Entity
|
||||
public class Monster : Entity
|
||||
{
|
||||
private WeaponResource weapon;
|
||||
public override void Init(EntityDef entityDef)
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Managers;
|
||||
using Prefab;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
@ -9,15 +9,15 @@ namespace Entity
|
||||
public class Outline : MonoBehaviour
|
||||
{
|
||||
public RightMenuPrefab rightMenuPrefab;
|
||||
|
||||
|
||||
public GameObject body;
|
||||
public SpriteRenderer outlineRenderer;
|
||||
public CapsuleCollider2D outlineCollider;
|
||||
public ProgressBarPrefab progressBarPrefab;
|
||||
|
||||
public Entity entity;
|
||||
|
||||
public static Vector3 minimum=new(0.5f,0.5f,0.5f);
|
||||
|
||||
public static Vector3 minimum = new(0.5f, 0.5f, 0.5f);
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
@ -116,7 +116,7 @@ namespace Entity
|
||||
private void BecomeDefault()
|
||||
{
|
||||
entity.Kill();
|
||||
EntityManage.Instance.GenerateDefaultEntity(Program.Instance.FocusedDimensionId,entity.Position);
|
||||
EntityManage.Instance.GenerateDefaultEntity(Program.Instance.FocusedDimensionId, entity.Position);
|
||||
}
|
||||
|
||||
private void StartControl()
|
||||
|
@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Base;
|
||||
using Data;
|
||||
using Item;
|
||||
using Prefab;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity
|
||||
{
|
||||
public class Pickup:Entity
|
||||
public class Pickup : Entity
|
||||
{
|
||||
public ItemResource itemResource;
|
||||
protected override void AutoBehave()
|
||||
@ -18,7 +18,7 @@ namespace Entity
|
||||
|
||||
public override void SetTarget(Vector3 pos)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Init(ItemDef itemDef)
|
||||
|
@ -1,12 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
public class ItemBase
|
||||
{
|
||||
public ItemResource resource;
|
||||
|
||||
public int count=0;
|
||||
|
||||
public int count = 0;
|
||||
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Data;
|
||||
using Managers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Item
|
||||
|
@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq; // Added for LINQ
|
||||
using Base;
|
||||
using Data;
|
||||
using Entity;
|
||||
using Prefab;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@ -15,11 +14,11 @@ namespace Item
|
||||
public Attributes Attributes { get; private set; }
|
||||
public BulletDef Bullet { get; private set; }
|
||||
public WeaponType Type { get; private set; }
|
||||
|
||||
public DrawNodeDef AttackAnimationDef { get; private set; }
|
||||
public float AttackAnimationTime{get; private set;}
|
||||
|
||||
public float AttackDetectionTime{get;private set;}
|
||||
|
||||
public DrawNodeDef AttackAnimationDef { get; private set; }
|
||||
public float AttackAnimationTime { get; private set; }
|
||||
|
||||
public float AttackDetectionTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数:通过 WeaponDef 对象初始化 WeaponResource。
|
||||
@ -76,12 +75,12 @@ namespace Item
|
||||
Debug.LogError("InstantiateAttackAnimation: 无法加载 Prefab/Animation.");
|
||||
return (null, Array.Empty<ITick>());
|
||||
}
|
||||
|
||||
|
||||
// 逻辑修改说明 2:调用修改后的私有辅助方法来创建 GameObject 层次结构。
|
||||
var animationRoot = _CreateBodyPartGameObject(
|
||||
AttackAnimationDef,
|
||||
parent,
|
||||
imagePrefab,
|
||||
AttackAnimationDef,
|
||||
parent,
|
||||
imagePrefab,
|
||||
animatorPrefab);
|
||||
|
||||
if (animationRoot == null)
|
||||
@ -91,9 +90,9 @@ namespace Item
|
||||
}
|
||||
|
||||
// 逻辑修改说明 3:收集所有实现了 ITick 接口的组件。
|
||||
var tickComponents = animationRoot.GetComponentsInChildren<ITick>(true);
|
||||
var tickComponents = animationRoot.GetComponentsInChildren<ITick>(true);
|
||||
// GetComponentsInChildren(true) 会查找包括自身在内的所有子对象上的组件,即使它们是处于非活动状态。
|
||||
|
||||
|
||||
return (animationRoot, tickComponents);
|
||||
}
|
||||
|
||||
@ -112,7 +111,7 @@ namespace Item
|
||||
|
||||
if (parent == null)
|
||||
{
|
||||
// 逻辑修改说明:这里直接返回 null 更合适,因为没有父节点无法创建实例。
|
||||
// 逻辑修改说明:这里直接返回 null 更合适,因为没有父节点无法创建实例。
|
||||
Debug.LogWarning($"CreateBodyPartGameObject: 父节点为null (节点名: {drawNode.nodeName ?? "Unnamed DrawNode"})");
|
||||
return null;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace Logging
|
||||
public string StackTrace;
|
||||
|
||||
public override string ToString() =>
|
||||
$"[{Timestamp:HH:mm:ss}] [{Type}] {Message}" +
|
||||
$"[{Timestamp:HH:mm:ss}] [{Type}] {Message}" +
|
||||
(Type == LogType.Exception ? $"\n{StackTrace}" : "");
|
||||
}
|
||||
|
||||
@ -27,8 +27,10 @@ namespace Logging
|
||||
public static int MaxLogs
|
||||
{
|
||||
get => _maxLogs;
|
||||
set {
|
||||
lock (_lock) {
|
||||
set
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_maxLogs = Mathf.Max(value, 1); // 最小值为1
|
||||
TrimExcess();
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
using Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Logging
|
||||
{
|
||||
public class LoggerManagerWrapper : ILaunchManager
|
||||
{
|
||||
public string StepDescription => "初始化日志";
|
||||
public void Init()
|
||||
{
|
||||
Logging.UnityLogger.Init();
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffa9f8b447ee49f486398248d438f7ca
|
||||
timeCreated: 1756128101
|
@ -1,57 +1,66 @@
|
||||
using Managers;
|
||||
using Serilog;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
using SerilogLogger = Serilog.Core.Logger;
|
||||
|
||||
namespace Logging
|
||||
{
|
||||
public static class UnityLogger
|
||||
public class UnityLogger : Singleton<UnityLogger>, ILaunchManager
|
||||
{
|
||||
private static readonly SerilogLogger Logger = new LoggerConfiguration()
|
||||
private bool _initialized = false;
|
||||
private readonly SerilogLogger _logger = new LoggerConfiguration()
|
||||
.WriteTo.File("Logs/UnityLog.txt")
|
||||
.CreateLogger();
|
||||
private static bool _initialized = false;
|
||||
public static void Init()
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if(_initialized)
|
||||
return;
|
||||
Application.logMessageReceived += OnLogMessageReceived;
|
||||
if (_initialized) return;
|
||||
|
||||
Application.logMessageReceivedThreaded += OnLogMessageReceived;
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
private static void OnLogMessageReceived(string logString, string stackTrace, LogType type)
|
||||
public void Clear()
|
||||
{
|
||||
}
|
||||
|
||||
public string StepDescription => "初始化日志";
|
||||
|
||||
private void OnLogMessageReceived(string logString, string stackTrace, LogType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case LogType.Assert:
|
||||
{
|
||||
Logger.Warning("\nContent: {0}", logString);
|
||||
break;
|
||||
}
|
||||
{
|
||||
_logger.Warning("\nContent: {0}", logString);
|
||||
break;
|
||||
}
|
||||
case LogType.Log:
|
||||
{
|
||||
Logger.Information("\nContent: {0}", logString);
|
||||
break;
|
||||
}
|
||||
{
|
||||
_logger.Information("\nContent: {0}", logString);
|
||||
break;
|
||||
}
|
||||
case LogType.Warning:
|
||||
{
|
||||
Logger.Warning("\nContent: {0}", logString);
|
||||
break;
|
||||
}
|
||||
{
|
||||
_logger.Warning("\nContent: {0}", logString);
|
||||
break;
|
||||
}
|
||||
case LogType.Error:
|
||||
{
|
||||
Logger.Error("\nContent: {0}\nStackTrace:\n{1}", logString, stackTrace[..^1]);
|
||||
break;
|
||||
}
|
||||
{
|
||||
_logger.Error("\nContent: {0}\nStackTrace:\n{1}", logString, stackTrace[..^1]);
|
||||
break;
|
||||
}
|
||||
case LogType.Exception:
|
||||
{
|
||||
Logger.Fatal("\nContent: {0}\nStackTrace:\n{1}", logString, stackTrace[..^1]);
|
||||
break;
|
||||
}
|
||||
{
|
||||
_logger.Fatal("\nContent: {0}\nStackTrace:\n{1}", logString, stackTrace[..^1]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Logger.Information("\nContent: {0}", logString);
|
||||
break;
|
||||
}
|
||||
{
|
||||
_logger.Information("\nContent: {0}", logString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Managers
|
||||
@ -10,7 +10,7 @@ namespace Managers
|
||||
/// 阵营管理器,负责管理游戏中的所有阵营定义及其相互关系。
|
||||
/// 继承自 <see cref="Utils.Singleton{T}"/> ,确保全局只有一个实例。
|
||||
/// </summary>
|
||||
public class AffiliationManager:Utils.Singleton<AffiliationManager>,ILaunchManager
|
||||
public class AffiliationManager : Utils.Singleton<AffiliationManager>, ILaunchManager
|
||||
{
|
||||
/// <summary>
|
||||
/// 存储所有已加载的阵营定义,键为阵营的唯一名称,值为对应的 <see cref="AffiliationDef"/> 对象。
|
||||
@ -28,7 +28,7 @@ namespace Managers
|
||||
// 如果管理器已经初始化,则直接返回,避免重复加载。
|
||||
if (_affiliations.Count > 0)
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
var affiliationList = Managers.DefineManager.Instance.QueryDefinesByType<AffiliationDef>();
|
||||
@ -80,7 +80,7 @@ namespace Managers
|
||||
// 如果任一阵营定义为空,则返回中立关系。
|
||||
if (affiliation1 == null || affiliation2 == null)
|
||||
{
|
||||
return Relation.Neutral;
|
||||
return Relation.Neutral;
|
||||
}
|
||||
return GetRelation(affiliation1.defName, affiliation2.defName);
|
||||
}
|
||||
@ -136,7 +136,7 @@ namespace Managers
|
||||
// 如果 faction1 没有明确设置与 faction2 的关系,则使用 faction1 的默认关系。
|
||||
return faction1.defaultRelation;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置两个阵营之间的关系。
|
||||
/// </summary>
|
||||
@ -187,7 +187,7 @@ namespace Managers
|
||||
throw new ArgumentOutOfRangeException(nameof(relation), relation, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检查并修复所有阵营之间的关系,以确保没有冲突。
|
||||
/// 修复遵循优先级规则:友好关系优先于敌对关系,敌对关系优先于中立关系。
|
||||
|
@ -1,9 +1,9 @@
|
||||
using Data;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
@ -16,7 +16,7 @@ namespace Managers
|
||||
/// 该管理器是一个单例,用于在应用程序中集中管理各种游戏或系统定义,
|
||||
/// 包括从不同数据包(Mods)加载定义,处理定义之间的引用,以及提供多种查询方法。
|
||||
/// </remarks>
|
||||
public class DefineManager : Singleton<DefineManager>,ILaunchManager
|
||||
public class DefineManager : Singleton<DefineManager>, ILaunchManager
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据集文件路径数组,用于指定定义包的根目录。
|
||||
@ -84,7 +84,7 @@ namespace Managers
|
||||
// 存储需要进行链接的定义引用信息。
|
||||
// Tuple的元素依次代表:被引用的定义(Define),引用该定义的字段(FieldInfo),以及引用占位符(Define)。
|
||||
List<Tuple<Define, FieldInfo, Define>> defineCache = new();
|
||||
|
||||
|
||||
string currentPackID;
|
||||
|
||||
// 递归处理定义对象及其内部的嵌套定义和引用。
|
||||
@ -100,7 +100,7 @@ namespace Managers
|
||||
{
|
||||
// 获取所有公共实例字段。
|
||||
defineFields = def.GetType()
|
||||
.GetFields(BindingFlags.Public | BindingFlags.Instance);
|
||||
.GetFields(BindingFlags.Public | BindingFlags.Instance);
|
||||
|
||||
// 缓存当前类型的字段信息。
|
||||
fieldCache[def.GetType()] = defineFields;
|
||||
@ -181,7 +181,7 @@ namespace Managers
|
||||
{
|
||||
if (!defines.ContainsKey(typeName))
|
||||
defines[typeName] = new Dictionary<string, Define>();
|
||||
|
||||
|
||||
foreach (var def in defList)
|
||||
{
|
||||
defines[typeName][def.defName] = def;
|
||||
@ -321,7 +321,7 @@ namespace Managers
|
||||
}
|
||||
return defineList.ToArray();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询指定类型下的所有 <see cref="Define"/> 对象(包括命名定义和匿名定义)。
|
||||
/// </summary>
|
||||
@ -399,7 +399,7 @@ namespace Managers
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询指定类型下的所有命名 <see cref="Define"/> 对象(不包括匿名定义)。
|
||||
/// </summary>
|
||||
@ -481,9 +481,9 @@ namespace Managers
|
||||
if (packs == null || packs.Count == 0)
|
||||
{
|
||||
// 如果集合为空或为 null,返回默认信息。
|
||||
return "No packs available";
|
||||
return "No packs available";
|
||||
}
|
||||
|
||||
|
||||
var result = new System.Text.StringBuilder();
|
||||
|
||||
foreach (var definePack in packs)
|
||||
@ -492,7 +492,7 @@ namespace Managers
|
||||
result.AppendLine(definePack.ToString());
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Base;
|
||||
using Data;
|
||||
using Entity;
|
||||
using Prefab;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
@ -45,7 +45,7 @@ namespace Managers
|
||||
|
||||
/// <summary> 子弹实体的预制体。 </summary>
|
||||
public EntityPrefab bulletPrefab;
|
||||
|
||||
|
||||
public EntityPrefab pickupPrefab;
|
||||
|
||||
/// <summary> 默认实体的预制体,用于生成失败时的回退。 </summary>
|
||||
@ -269,7 +269,7 @@ namespace Managers
|
||||
throw new InvalidOperationException(
|
||||
$"在 '{instantiatedEntity.name}' 上缺少 EntityPrefab 组件,无法完成实体初始化。");
|
||||
}
|
||||
entityComponent.entity.currentDimensionId=dimensionId;
|
||||
entityComponent.entity.currentDimensionId = dimensionId;
|
||||
entityComponent.Init(def);
|
||||
extraInit?.Invoke(entityComponent);
|
||||
|
||||
@ -504,14 +504,14 @@ namespace Managers
|
||||
Debug.LogError($"实体管理器:无法在维度 '{dimensionId}' 中获取或创建实体的父层。");
|
||||
return;
|
||||
}
|
||||
|
||||
var result=Instantiate(pickupPrefab, pos, Quaternion.identity);
|
||||
|
||||
var result = Instantiate(pickupPrefab, pos, Quaternion.identity);
|
||||
var pickup = result.GetComponent<Pickup>();
|
||||
result.transform.SetParent(parentLayer);
|
||||
pickup.Init(itemDef);
|
||||
if (result == null) GenerateDefaultEntity(dimensionId, pos);
|
||||
_pendingAdditions.Add(Tuple.Create(dimensionId, "default", result));
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 在指定维度和位置生成一个默认实体(通常作为回退选项)。
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Data;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using EventType = Data.EventType;
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Data;
|
||||
using Item;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
public class ItemResourceManager : Utils.Singleton<ItemResourceManager>,ILaunchManager
|
||||
public class ItemResourceManager : Utils.Singleton<ItemResourceManager>, ILaunchManager
|
||||
{
|
||||
private ItemResource defaultItem;
|
||||
private readonly Dictionary<string, Item.ItemResource> _items = new();
|
||||
@ -16,7 +16,7 @@ namespace Managers
|
||||
|
||||
public void Init()
|
||||
{
|
||||
defaultItem=ItemResource.GetDefault();
|
||||
defaultItem = ItemResource.GetDefault();
|
||||
var baseItemDefs = Managers.DefineManager.Instance.QueryDefinesByType<ItemDef>();
|
||||
var weaponDefs = Managers.DefineManager.Instance.QueryDefinesByType<WeaponDef>();
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Managers
|
||||
$"ItemResourceManager: Duplicate itemDef.defName found: {def.defName}. Skipping this item.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Item.ItemResource itemResource;
|
||||
|
||||
if (def is WeaponDef currentWeaponDef)
|
||||
|
@ -1,8 +1,8 @@
|
||||
using Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Managers
|
||||
@ -51,7 +51,7 @@ namespace Managers
|
||||
{
|
||||
// 如果已经加载过,直接返回。
|
||||
StepDescription = "包图像管理器已初始化。";
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
StepDescription = "正在加载默认精灵..."; // 更新加载步骤描述
|
||||
@ -73,7 +73,7 @@ namespace Managers
|
||||
{
|
||||
var textureCache = new Dictionary<string, Texture2D>();
|
||||
var imageDef = Managers.DefineManager.Instance.QueryDefinesByType<ImageDef>();
|
||||
|
||||
|
||||
if (imageDef == null || !imageDef.Any())
|
||||
{
|
||||
Debug.Log($"在 DefineManager 中未找到任何 ImageDef 定义。({typeof(ImageDef).Name})");
|
||||
@ -91,9 +91,9 @@ namespace Managers
|
||||
try
|
||||
{
|
||||
string cacheKey;
|
||||
Texture2D texture = null;
|
||||
|
||||
if (ima.path.StartsWith("res:"))
|
||||
Texture2D texture = null;
|
||||
|
||||
if (ima.path.StartsWith("res:"))
|
||||
{
|
||||
// 处理 Resources 路径
|
||||
var resPath = ima.path.Substring(4).Replace('\\', '/').TrimStart('/');
|
||||
@ -243,7 +243,7 @@ namespace Managers
|
||||
Debug.LogError($"包 '{packId}' 中 '{baseName}' 的纹理尺寸 ({textureWidth}x{textureHeight}) 不能被指定的行数 ({rows}) 和列数 ({cols}) 完美整除。子精灵将不会生成或可能不正确。仅显示完整精灵。");
|
||||
return; // 终止子精灵分割,只保留完整的精灵
|
||||
}
|
||||
|
||||
|
||||
var tileWidth = textureWidth / cols;
|
||||
var tileHeight = textureHeight / rows;
|
||||
|
||||
@ -251,11 +251,11 @@ namespace Managers
|
||||
{
|
||||
for (var col = 0; col < cols; col++)
|
||||
{
|
||||
Rect spriteRect = new(col * tileWidth, row * tileHeight, tileWidth, tileHeight);
|
||||
Rect spriteRect = new(col * tileWidth, row * tileHeight, tileWidth, tileHeight);
|
||||
var sprite = Sprite.Create(texture, spriteRect, new Vector2(0.5f, 0.5f), pixelsPerUnit);
|
||||
|
||||
// 精灵索引计算方式
|
||||
var index = (rows - row - 1) * cols + col;
|
||||
var index = (rows - row - 1) * cols + col;
|
||||
var spriteName = $"{baseName}_{index}";
|
||||
sprite.name = spriteName;
|
||||
|
||||
@ -268,7 +268,7 @@ namespace Managers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有已加载的纹理和精灵数据。
|
||||
/// </summary>
|
||||
@ -291,8 +291,8 @@ namespace Managers
|
||||
/// </remarks>
|
||||
public void Reload()
|
||||
{
|
||||
Clear();
|
||||
Init();
|
||||
Clear();
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@ -303,7 +303,7 @@ namespace Managers
|
||||
/// <returns>如果找到对应的精灵,则返回该精灵;否则返回 <see cref="defaultSprite"/>。</returns>
|
||||
public Sprite GetSprite(ImageDef ima)
|
||||
{
|
||||
if (ima == null) return defaultSprite;
|
||||
if (ima == null) return defaultSprite;
|
||||
return GetSprite(ima.packID, ima.name);
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using Prefab;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
public class RightMenuManager:Utils.MonoSingleton<RightMenuManager>
|
||||
public class RightMenuManager : Utils.MonoSingleton<RightMenuManager>
|
||||
{
|
||||
[SerializeField]
|
||||
[SerializeField]
|
||||
private GameObject _canvas;
|
||||
|
||||
[SerializeField]
|
||||
|
||||
[SerializeField]
|
||||
private RightMenuPrefab _rightMenuPrefab;
|
||||
|
||||
public GameObject Canvas
|
||||
@ -35,7 +35,7 @@ namespace Managers
|
||||
{
|
||||
if (_rightMenuPrefab == null)
|
||||
{
|
||||
_rightMenuPrefab = Resources.Load<RightMenuPrefab>("Prefab/RightMenu");
|
||||
_rightMenuPrefab = Resources.Load<RightMenuPrefab>("Prefab/RightMenu");
|
||||
if (_rightMenuPrefab == null)
|
||||
{
|
||||
Debug.LogError("RightMenuPrefab not found in Resources!");
|
||||
@ -45,11 +45,11 @@ namespace Managers
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateRightMenu(List<(string name, UnityAction callback)> buttons,Vector3 position)
|
||||
public static void GenerateRightMenu(List<(string name, UnityAction callback)> buttons, Vector3 position)
|
||||
{
|
||||
var rightMenuObj = Instantiate(RightMenuManager.Instance.RightMenuPrefab.gameObject,
|
||||
RightMenuManager.Instance.Canvas.transform);
|
||||
var rightMenu=rightMenuObj.GetComponent<RightMenuPrefab>();
|
||||
var rightMenu = rightMenuObj.GetComponent<RightMenuPrefab>();
|
||||
rightMenu.Init(buttons);
|
||||
rightMenu.transform.position = position;
|
||||
rightMenu.Show();
|
||||
@ -57,7 +57,7 @@ namespace Managers
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Data;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Tilemaps;
|
||||
using Utils;
|
||||
@ -35,15 +35,15 @@ namespace Managers
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 确保依赖的 PackagesImageManager 已初始化。
|
||||
// 虽然 Launcher 会按顺序初始化,但这里做一次检查和调用,
|
||||
// 可以防止其他地方直接调用 TileManager.Instance.Init() 时,
|
||||
// 其依赖未准备好的情况。PackagesImageManager 也应该是幂等的。
|
||||
PackagesImageManager.Instance.Init();
|
||||
|
||||
|
||||
var imagePack = Managers.PackagesImageManager.Instance;
|
||||
|
||||
|
||||
// 获取所有瓦片定义
|
||||
var tileDefs = DefineManager.Instance.QueryDefinesByType<TileDef>();
|
||||
for (var i = 0; i < tileDefs.Length; i++)
|
||||
@ -54,7 +54,7 @@ namespace Managers
|
||||
Debug.LogWarning($"<color=orange>瓦片定义 '{tileDefs[i].name}' 的名称重复。</color> 将忽略后续定义。");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 处理瓦片纹理映射表定义
|
||||
var tileTextureMappingDefs = DefineManager.Instance.QueryDefinesByType<TileMappingTableDef>();
|
||||
foreach (var mappingTableDef in tileTextureMappingDefs)
|
||||
@ -94,9 +94,9 @@ namespace Managers
|
||||
continue;
|
||||
}
|
||||
// 创建瓦片实例并存储到映射表中
|
||||
var newTile = CreateTileInstance(sprite);
|
||||
var newTile = CreateTileInstance(sprite);
|
||||
tileToTileBaseMapping[tileKey] = newTile;
|
||||
|
||||
|
||||
// 同样检查 tileBaseMapping 的重复性
|
||||
if (tileBaseMapping.ContainsKey(spriteName))
|
||||
{
|
||||
@ -139,29 +139,29 @@ namespace Managers
|
||||
Object.Destroy(tile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tileBaseMapping.Clear();
|
||||
tileToTileBaseMapping.Clear();
|
||||
tileID.Clear();
|
||||
}
|
||||
// ------------- ILaunchManager 接口实现结束 -------------
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 存储瓦片名称与 <see cref="TileBase"/> 对象的映射关系。
|
||||
/// </summary>
|
||||
public Dictionary<string, TileBase> tileBaseMapping = new();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 存储瓦片组合索引与 <see cref="TileBase"/> 对象的映射关系。
|
||||
/// 索引由四个整数组成,表示瓦片的组合方式。
|
||||
/// </summary>
|
||||
public Dictionary<(int, int, int, int), TileBase> tileToTileBaseMapping = new();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 存储瓦片名称与唯一 ID 的映射关系。
|
||||
/// </summary>
|
||||
public Dictionary<string, int> tileID = new();
|
||||
|
||||
|
||||
// 移除了 TileManager 内部的 Reload() 方法,因为它将被 Launcher 的 Clear() + Init() 流程取代。
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,5 +1,3 @@
|
||||
using System;
|
||||
using Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Map
|
||||
@ -12,11 +10,12 @@ namespace Map
|
||||
{
|
||||
[SerializeField] private bool defaultOpen = false;
|
||||
|
||||
[SerializeField] [Tooltip("此维度的唯一标识符。如果为空,将使用GameObject的名称。")]
|
||||
[SerializeField]
|
||||
[Tooltip("此维度的唯一标识符。如果为空,将使用GameObject的名称。")]
|
||||
private string _dimensionId;
|
||||
|
||||
[SerializeField] public MapGenerator mapGenerator;
|
||||
|
||||
|
||||
public Vector3 cameraPosition;
|
||||
/// <summary>
|
||||
/// 获取此维度的唯一标识符。
|
||||
@ -43,7 +42,7 @@ namespace Map
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
||||
|
||||
// 1. 确保 DimensionId 已初始化,这会触发 DimensionId 属性的 getter 逻辑
|
||||
var id = DimensionId;
|
||||
// 2. 创建一个用于存放此维度下所有实体的根GameObject,方便管理
|
||||
@ -60,7 +59,7 @@ namespace Map
|
||||
Debug.LogError(
|
||||
"[Dimension] Program.Instance is null during Dimension Awake. Cannot register dimension.", this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 5. 处理 defaultOpen 逻辑,设置Program的焦点维度
|
||||
// 确保在自身注册到 Program 之后再设置焦点,这样 Program 内部才能找到它
|
||||
@ -74,7 +73,7 @@ namespace Map
|
||||
private void Start()
|
||||
{
|
||||
var size = mapGenerator.baseMap.GetSize();
|
||||
cameraPosition = new Vector3(size.x / 2f, size.y / 2f, -10)+transform.position;
|
||||
cameraPosition = new Vector3(size.x / 2f, size.y / 2f, -10) + transform.position;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using Managers;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Data;
|
||||
using Managers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Tilemaps;
|
||||
|
||||
@ -13,7 +11,7 @@ namespace Map
|
||||
public List<List<int>> mapData = new();
|
||||
public Tilemap textureLevel;
|
||||
// public Vector2Int dataOffset = Vector2Int.zero; // 数据起始点偏移变量 - 已删除
|
||||
|
||||
|
||||
|
||||
// 初始化地图数据大小
|
||||
public void InitializeData(int width, int height, int defaultValue = 0)
|
||||
|
@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Tilemaps;
|
||||
|
||||
namespace Map
|
||||
{
|
||||
public class MapGenerator:MonoBehaviour
|
||||
public class MapGenerator : MonoBehaviour
|
||||
{
|
||||
public DoubleMap baseMap;
|
||||
|
||||
@ -29,6 +28,6 @@ namespace Map
|
||||
baseMap.RefreshAllTiles();
|
||||
CameraControl.CameraControl.Instance.SetPosition(new Vector3(size * 0.5f, size * 0.5f, -10));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace Map
|
||||
{
|
||||
public class MiniMap : MonoBehaviour,ITickUI
|
||||
public class MiniMap : MonoBehaviour, ITickUI
|
||||
{
|
||||
public Image background;
|
||||
public RawImage texture;
|
||||
|
@ -1,8 +1,9 @@
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Grpc.Net.Client;
|
||||
using Grpc.Net.Client.Web;
|
||||
using Protocol;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
namespace Network
|
||||
@ -18,21 +19,17 @@ namespace Network
|
||||
|
||||
public GrpcClient()
|
||||
{
|
||||
var httpHandler = new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler());
|
||||
var channelOptions = new GrpcChannelOptions
|
||||
{
|
||||
HttpHandler = httpHandler
|
||||
HttpHandler = new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler())
|
||||
};
|
||||
|
||||
_channel = GrpcChannel.ForAddress(ServerAddress, channelOptions);
|
||||
|
||||
_general = new GeneralService.GeneralServiceClient(_channel);
|
||||
_game = new GameService.GameServiceClient(_channel);
|
||||
}
|
||||
|
||||
~GrpcClient()
|
||||
{
|
||||
_channel.ShutdownAsync().Wait();
|
||||
Application.quitting += () => _channel.ShutdownAsync().Wait();
|
||||
}
|
||||
|
||||
public async Task<ServerInfo> GetServerInfo()
|
||||
|
8
Client/Assets/Scripts/Parsing.meta
Normal file
8
Client/Assets/Scripts/Parsing.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef7f384f3b5dc0049ba97561d579cd03
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -5,7 +5,7 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace AI
|
||||
namespace Parsing
|
||||
{
|
||||
public static class ConditionDelegateFactory
|
||||
{
|
@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using Data;
|
||||
using Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AI
|
||||
namespace Parsing
|
||||
{
|
||||
public static class ConditionFunctions
|
||||
{
|
||||
@ -11,11 +6,10 @@ namespace AI
|
||||
{
|
||||
return entity.attributes.health >= minHealth;
|
||||
}
|
||||
|
||||
|
||||
public static bool HasEnemyInSight(Entity.Entity entity)
|
||||
{
|
||||
return Managers.EntityManage.Instance.ExistsHostile(entity.currentDimensionId,entity.entityPrefab);
|
||||
return Managers.EntityManage.Instance.ExistsHostile(entity.currentDimensionId, entity.entityPrefab);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace Utils
|
||||
namespace Parsing
|
||||
{
|
||||
public static class Resolver
|
||||
{
|
@ -5,15 +5,15 @@ using UnityEngine.UI;
|
||||
|
||||
namespace Prefab
|
||||
{
|
||||
public class ButtonPrefab:MonoBehaviour
|
||||
public class ButtonPrefab : MonoBehaviour
|
||||
{
|
||||
public Button button;
|
||||
public TMP_Text text;
|
||||
|
||||
public string Label
|
||||
{
|
||||
get{return text.text;}
|
||||
set{text.text = value;}
|
||||
get { return text.text; }
|
||||
set { text.text = value; }
|
||||
}
|
||||
|
||||
public void AddListener(UnityAction callback)
|
||||
|
@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AI;
|
||||
using Base;
|
||||
using Data;
|
||||
using Entity;
|
||||
using Unity.VisualScripting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Prefab
|
||||
|
@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@ -6,7 +5,7 @@ using UnityEngine.UI;
|
||||
namespace Prefab
|
||||
{
|
||||
// [RequireComponent(typeof(CircleCollider2D))]
|
||||
public class HoverButtonPrefab:MonoBehaviour
|
||||
public class HoverButtonPrefab : MonoBehaviour
|
||||
{
|
||||
public TMP_Text text;
|
||||
public Button button;
|
||||
@ -23,8 +22,8 @@ namespace Prefab
|
||||
|
||||
public void OnMouseOver()
|
||||
{
|
||||
var dir= (Input.mousePosition - transform.position).magnitude;
|
||||
|
||||
var dir = (Input.mousePosition - transform.position).magnitude;
|
||||
|
||||
var color = button.image.color;
|
||||
color.a = Mathf.Min((startRadius - dir) / (startRadius - endRadius), 1);
|
||||
button.image.color = color;
|
||||
|
@ -1,10 +1,9 @@
|
||||
using Base;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Prefab
|
||||
{
|
||||
|
||||
[RequireComponent(typeof(SpriteRenderer))]
|
||||
[RequireComponent(typeof(SpriteRenderer))]
|
||||
public class ImagePrefab : MonoBehaviour
|
||||
{
|
||||
public Sprite defaultSprite;
|
||||
|
@ -2,7 +2,7 @@ using UnityEngine;
|
||||
|
||||
namespace Prefab
|
||||
{
|
||||
public class ProgressBarPrefab:MonoBehaviour
|
||||
public class ProgressBarPrefab : MonoBehaviour
|
||||
{
|
||||
public GameObject _progress;
|
||||
public float Progress
|
||||
@ -10,7 +10,7 @@ namespace Prefab
|
||||
get => _progress.transform.localScale.x;
|
||||
set
|
||||
{
|
||||
var x=Mathf.Clamp01(value);
|
||||
var x = Mathf.Clamp01(value);
|
||||
_progress.transform.localScale = new Vector3(x, _progress.transform.localScale.y, _progress.transform.localScale.z);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ using UnityEngine.EventSystems;
|
||||
|
||||
namespace Prefab
|
||||
{
|
||||
public class RightMenuPrefab: MonoBehaviour,IPointerExitHandler
|
||||
public class RightMenuPrefab : MonoBehaviour, IPointerExitHandler
|
||||
{
|
||||
public GameObject menu;
|
||||
public ButtonPrefab buttonPrefab;
|
||||
|
@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using Base;
|
||||
using UnityEngine;
|
||||
|
||||
@ -26,7 +25,7 @@ namespace Prefab
|
||||
// ITick接口实现
|
||||
public void Tick()
|
||||
{
|
||||
var deltaTime=Time.deltaTime;
|
||||
var deltaTime = Time.deltaTime;
|
||||
if (_isPaused)
|
||||
{
|
||||
HandlePausedState();
|
||||
|
@ -6,11 +6,11 @@ namespace Prefab
|
||||
public class TextPrefab : MonoBehaviour
|
||||
{
|
||||
public TMP_Text text;
|
||||
|
||||
|
||||
public string Label
|
||||
{
|
||||
get{return text.text;}
|
||||
set{text.text = value;}
|
||||
get { return text.text; }
|
||||
set { text.text = value; }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Map;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Map;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
@ -33,12 +33,12 @@ public class Program : Singleton<Program>
|
||||
/// 变更为属性,并私有化setter,确保通过 SetFocusedDimension 方法集中管理其更新。
|
||||
/// </summary>
|
||||
// 逻辑修改1:修正属性名 'focuseDimensionId' 为 'focusedDimensionId'
|
||||
public string FocusedDimensionId { get; private set; } = null;
|
||||
public string FocusedDimensionId { get; private set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// 当前聚焦的维度对象实例。当 <see cref="FocusedDimensionId"/> 不为空时,此属性指向对应的维度实例。
|
||||
/// </summary>
|
||||
public Dimension FocusedDimension { get; private set; }
|
||||
public Dimension FocusedDimension { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 维护所有已注册的维度实例的字典,键是维度的唯一标识符 (ID)。
|
||||
@ -82,7 +82,7 @@ public class Program : Singleton<Program>
|
||||
return;
|
||||
}
|
||||
_registeredDimensions.Add(id, dimension);
|
||||
|
||||
|
||||
// 逻辑修改:此处不需要if语句包裹_registeredDimensions.Add,因为前置的ContainsKey已确保不会抛异常。
|
||||
// 确保任何对焦点的潜在更新都通过 SetFocusedDimension 进行,
|
||||
// 从而集中管理焦点状态的同步和事件的触发。
|
||||
@ -179,7 +179,7 @@ public class Program : Singleton<Program>
|
||||
// 3. 更新内部状态
|
||||
FocusedDimensionId = newFocusedDimensionId; // 逻辑修改1:修正属性名
|
||||
FocusedDimension = newFocusedDimension;
|
||||
|
||||
|
||||
// 逻辑修改2:功能缺失修复 - 切换维度时,焦点实体应该置为空
|
||||
// 确保功能一致性:当维度焦点改变(或被清除)时,任何实体焦点也应被清除。
|
||||
SetFocusedEntity(null);
|
||||
@ -187,7 +187,7 @@ public class Program : Singleton<Program>
|
||||
// 4. 触发事件
|
||||
OnFocusedDimensionChanged?.Invoke(FocusedDimension);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前聚焦的实体。
|
||||
/// 这是更改焦点实体的唯一官方入口,并会在实体改变时触发 OnFocusedEntityChanged 事件。
|
||||
|
@ -3,7 +3,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class BarUI:MonoBehaviour
|
||||
public class BarUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image image;
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace UI
|
||||
var button = InstantiatePrefab(buttonTemplate, menuContent.transform);
|
||||
button.Label = buttonTextSelector(def);
|
||||
// 确保 lambda 捕获的是循环当前迭代的 def 变量,而不是循环变量本身
|
||||
var currentDef = def;
|
||||
var currentDef = def;
|
||||
button.AddListener(() => buttonAction(currentDef));
|
||||
}
|
||||
}
|
||||
@ -78,8 +78,8 @@ namespace UI
|
||||
"事件菜单",
|
||||
"未定义任何事件",
|
||||
// 假设 EventDef 也有 label 字段作为按钮文本
|
||||
def => def.label,
|
||||
eventDef =>
|
||||
def => def.label,
|
||||
eventDef =>
|
||||
{
|
||||
// TODO: 在这里实现事件触发逻辑
|
||||
Debug.Log($"触发事件: {eventDef.label}");
|
||||
@ -165,7 +165,7 @@ namespace UI
|
||||
{
|
||||
entityPlacementUI.currentAction = () =>
|
||||
{
|
||||
Managers.EntityManage.Instance.GenerateEntity(Program.Instance.FocusedDimensionId,entityDef, Utils.MousePosition.GetWorldPosition());
|
||||
Managers.EntityManage.Instance.GenerateEntity(Program.Instance.FocusedDimensionId, entityDef, Utils.MousePosition.GetWorldPosition());
|
||||
};
|
||||
entityPlacementUI.Prompt = $"当前生成器:\n名称:{entityDef.label}\n描述:{entityDef.description}";
|
||||
entityPlacementUI.snapEnabled = false;
|
||||
@ -175,7 +175,7 @@ namespace UI
|
||||
{
|
||||
entityPlacementUI.currentAction = () =>
|
||||
{
|
||||
Managers.EntityManage.Instance.GenerateMonsterEntity(Program.Instance.FocusedDimensionId,monsterDef, Utils.MousePosition.GetWorldPosition());
|
||||
Managers.EntityManage.Instance.GenerateMonsterEntity(Program.Instance.FocusedDimensionId, monsterDef, Utils.MousePosition.GetWorldPosition());
|
||||
};
|
||||
entityPlacementUI.Prompt = $"当前生成器:\n名称:{monsterDef.label}\n描述:{monsterDef.description}";
|
||||
entityPlacementUI.snapEnabled = false;
|
||||
@ -185,7 +185,7 @@ namespace UI
|
||||
{
|
||||
entityPlacementUI.currentAction = () =>
|
||||
{
|
||||
Managers.EntityManage.Instance.GenerateBuildingEntity(Program.Instance.FocusedDimensionId,def, Utils.MousePosition.GetSnappedWorldPosition());
|
||||
Managers.EntityManage.Instance.GenerateBuildingEntity(Program.Instance.FocusedDimensionId, def, Utils.MousePosition.GetSnappedWorldPosition());
|
||||
};
|
||||
entityPlacementUI.Prompt = $"当前生成器:\n名称:{def.label}\n描述:{def.description}";
|
||||
entityPlacementUI.snapEnabled = true;
|
||||
@ -195,7 +195,7 @@ namespace UI
|
||||
{
|
||||
entityPlacementUI.currentAction = () =>
|
||||
{
|
||||
Managers.EntityManage.Instance.GeneratePickupEntity(Program.Instance.FocusedDimensionId,itemDef, Utils.MousePosition.GetWorldPosition());
|
||||
Managers.EntityManage.Instance.GeneratePickupEntity(Program.Instance.FocusedDimensionId, itemDef, Utils.MousePosition.GetWorldPosition());
|
||||
};
|
||||
entityPlacementUI.Prompt = $"当前生成器:\n名称:{itemDef.label}\n描述:{itemDef.description}";
|
||||
entityPlacementUI.snapEnabled = false;
|
||||
|
@ -1,16 +1,15 @@
|
||||
using Base;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
|
||||
|
||||
public delegate void NonReturnCallback();
|
||||
public class EntityPlacementUI:UIBase,ITickUI
|
||||
public class EntityPlacementUI : UIBase, ITickUI
|
||||
{
|
||||
public TMP_Text promptText;
|
||||
|
||||
|
||||
public NonReturnCallback currentAction;
|
||||
|
||||
public GameObject focusBox;
|
||||
@ -29,7 +28,7 @@ namespace UI
|
||||
{
|
||||
Base.UIInputControl.Instance.Hide(this);
|
||||
}
|
||||
if (currentAction!=null&&Input.GetMouseButtonDown(0))
|
||||
if (currentAction != null && Input.GetMouseButtonDown(0))
|
||||
{
|
||||
currentAction();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Base;
|
||||
using Entity;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
// 确保 Character 类在此命名空间下
|
||||
|
||||
@ -103,7 +103,7 @@ namespace UI
|
||||
|
||||
// 立即更新UI以反映新的关注实体(或没有关注实体)的状态。
|
||||
UpdateUI();
|
||||
|
||||
|
||||
// 在更新UI后,确保UI的选中状态与角色当前选中字段同步
|
||||
// 只有当有焦点角色且库存不为空时才更新选中状态
|
||||
if (focusedEntity != null && focusedEntity.Inventory != null && focusedEntity.Inventory.Capacity > 0)
|
||||
@ -187,7 +187,7 @@ namespace UI
|
||||
}
|
||||
}
|
||||
uiParent.SetActive(true);
|
||||
|
||||
|
||||
// 首次更新UI时,或者当Inventory改变时,需要确保 CurrentSelected 的UI状态是正确的
|
||||
// 但如果 UpdateFocusedEntity 已经处理了,这里可以省略,或者确保只在必要时调用
|
||||
// 考虑到 UpdateUI 也会被 Inventory.OnInventoryChanged 调用,这里再次确保同步是合理的。
|
||||
|
@ -1,10 +1,9 @@
|
||||
using Base;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class EscUI:UIBase
|
||||
public class EscUI : UIBase
|
||||
{
|
||||
public void ContinueButton()
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using Base;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@ -7,20 +7,20 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class ItemUI:MonoBehaviour,IPointerEnterHandler,IPointerExitHandler,IPointerClickHandler,ITick
|
||||
public class ItemUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler, ITick
|
||||
{
|
||||
[SerializeField] private Image textureUI;
|
||||
[SerializeField] private TMP_Text countUI;
|
||||
[SerializeField] private TMP_Text nameUI;
|
||||
[SerializeField] private GameObject selectedOutline;
|
||||
|
||||
|
||||
private Entity.InventorySlot _item;
|
||||
private float timer = 0;
|
||||
private float switchTime = 0;
|
||||
private int texturePtr = 0;
|
||||
|
||||
|
||||
public event Action OnPlayerSelect;
|
||||
|
||||
|
||||
public bool Select
|
||||
{
|
||||
get => selectedOutline.activeSelf;
|
||||
@ -29,7 +29,7 @@ namespace UI
|
||||
|
||||
public int SlotIndex { get; private set; } = -1;
|
||||
|
||||
public void Init(Entity.InventorySlot item,int index)
|
||||
public void Init(Entity.InventorySlot item, int index)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
@ -75,17 +75,17 @@ namespace UI
|
||||
{
|
||||
if (switchTime > 0)
|
||||
{
|
||||
timer+=Time.deltaTime;
|
||||
timer += Time.deltaTime;
|
||||
if (timer >= switchTime)
|
||||
{
|
||||
timer-=switchTime;
|
||||
timer -= switchTime;
|
||||
texturePtr++;
|
||||
texturePtr%=_item.Item.Icon.Count;
|
||||
textureUI.sprite=_item.Item.Icon[texturePtr];
|
||||
texturePtr %= _item.Item.Icon.Count;
|
||||
textureUI.sprite = _item.Item.Icon[texturePtr];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using Prefab;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Prefab;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -1,14 +1,12 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class PlayerStateUI:MonoBehaviour,Base.ITick
|
||||
public class PlayerStateUI : MonoBehaviour, Base.ITick
|
||||
{
|
||||
[SerializeField] private BarUI focusedEntityHP;
|
||||
[SerializeField] private BarUI lastEntityHP;
|
||||
|
||||
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
@ -19,6 +17,6 @@ namespace UI
|
||||
(float)focusedEntity.attributes.health / focusedEntity.entityDef.attributes.health;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
using System.Globalization;
|
||||
using Base;
|
||||
using System.Globalization;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
@ -2,20 +2,18 @@ using System;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
public class PerlinNoise : Utils.Singleton<PerlinNoise>
|
||||
public class PerlinNoise : Singleton<PerlinNoise>
|
||||
{
|
||||
private int[] _p; // 混淆表
|
||||
private const int DefaultSeed = 0; // 默认种子
|
||||
private readonly int[] _p = new int[512]; // 混淆表
|
||||
|
||||
public PerlinNoise()
|
||||
{
|
||||
Initialize(DefaultSeed);
|
||||
Initialize();
|
||||
}
|
||||
|
||||
// 初始化混淆表
|
||||
private void Initialize(int seed)
|
||||
private void Initialize(int seed = 0)
|
||||
{
|
||||
_p = new int[512]; // 混淆表加倍以方便使用
|
||||
var permutation = new int[256];
|
||||
var random = new Random(seed);
|
||||
|
||||
@ -26,9 +24,8 @@ namespace Utils
|
||||
for (var i = 0; i < 256; i++)
|
||||
{
|
||||
var swapIndex = random.Next(256);
|
||||
var temp = permutation[i];
|
||||
permutation[i] = permutation[swapIndex];
|
||||
permutation[swapIndex] = temp;
|
||||
|
||||
(permutation[i], permutation[swapIndex]) = (permutation[swapIndex], permutation[i]);
|
||||
}
|
||||
|
||||
// 将打乱后的数组复制两次,生成512个元素的混淆表
|
||||
@ -86,7 +83,7 @@ namespace Utils
|
||||
/// 为给定的(x, y, z)坐标生成3D Perlin噪声。
|
||||
/// 输出值通常在-1到1之间。
|
||||
/// </summary>
|
||||
public double Noise(double x, double y=0, double z = 0)
|
||||
public double Noise(double x, double y = 0, double z = 0)
|
||||
{
|
||||
var X = (int)Math.Floor(x) & 255;
|
||||
var Y = (int)Math.Floor(y) & 255;
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user