diff --git a/Client/Assets/Prefab/EntityPrefab.prefab b/Client/Assets/Prefab/EntityPrefab.prefab new file mode 100644 index 0000000..e3c84b4 --- /dev/null +++ b/Client/Assets/Prefab/EntityPrefab.prefab @@ -0,0 +1,326 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &564740215097623485 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1697214530303839877} + - component: {fileID: 3992139212329961548} + - component: {fileID: 2782869455480213302} + - component: {fileID: 478384147413774568} + m_Layer: 0 + m_Name: Outline + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1697214530303839877 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 564740215097623485} + 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: 5.3333335} + m_ConstrainProportionsScale: 1 + m_Children: [] + m_Father: {fileID: 697189026367054479} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &3992139212329961548 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 564740215097623485} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 9dfc825aed78fcd4ba02077103263b40, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 811d3d3bfa653494784ee8ed56956471, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 1 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!114 &2782869455480213302 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 564740215097623485} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: acf99b9aa18d4ab9b4ce796d513d476b, type: 3} + m_Name: + m_EditorClassIdentifier: + body: {fileID: 2838206730318674270} + outlineRenderer: {fileID: 3992139212329961548} + outlineCollider: {fileID: 478384147413774568} +--- !u!70 &478384147413774568 +CapsuleCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 564740215097623485} + m_Enabled: 1 + serializedVersion: 3 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_CompositeOperation: 0 + m_CompositeOrder: 0 + m_Offset: {x: 0, y: 0} + m_Size: {x: 1, y: 1} + m_Direction: 0 +--- !u!1 &887327274103887133 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 697189026367054479} + - component: {fileID: 3332598847335032684} + - component: {fileID: 7300440714681954677} + m_Layer: 0 + m_Name: EntityPrefab + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &697189026367054479 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 887327274103887133} + 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: + - {fileID: 1697214530303839877} + - {fileID: 5549544358816209289} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &3332598847335032684 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 887327274103887133} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b20b1846b9ef47db83c2ac8c4c4e82cb, type: 3} + m_Name: + m_EditorClassIdentifier: + entity: {fileID: 7300440714681954677} + outline: {fileID: 2782869455480213302} +--- !u!114 &7300440714681954677 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 887327274103887133} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fbde354e0bcc4409b3378ee9b698ddc0, type: 3} + m_Name: + m_EditorClassIdentifier: + direction: {x: 0, y: 0, z: 0} + body: {fileID: 2838206730318674270} + canSelect: 1 +--- !u!1 &2838206730318674270 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5549544358816209289} + m_Layer: 0 + m_Name: Body + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5549544358816209289 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2838206730318674270} + 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: + - {fileID: 1715998378632490765} + m_Father: {fileID: 697189026367054479} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &3562938223049611414 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1715998378632490765} + - component: {fileID: 2346928675516876702} + m_Layer: 0 + m_Name: Square + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1715998378632490765 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3562938223049611414} + 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: 5549544358816209289} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &2346928675516876702 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3562938223049611414} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 9dfc825aed78fcd4ba02077103263b40, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 diff --git a/Client/Assets/Prefab/EntityPrefab.prefab.meta b/Client/Assets/Prefab/EntityPrefab.prefab.meta new file mode 100644 index 0000000..2ed2546 --- /dev/null +++ b/Client/Assets/Prefab/EntityPrefab.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6cd8b01a0f57372438dc30c864ae1530 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scenes/Start.unity b/Client/Assets/Scenes/Start.unity index 072fa55..6c6eff9 100644 --- a/Client/Assets/Scenes/Start.unity +++ b/Client/Assets/Scenes/Start.unity @@ -336,38 +336,6 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &382708044 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 382708045} - m_Layer: 0 - m_Name: Body - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &382708045 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 382708044} - 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: - - {fileID: 788852947} - m_Father: {fileID: 1109852279} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &603423466 GameObject: m_ObjectHideFlags: 0 @@ -440,234 +408,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: isGlobal: 1 ---- !u!1 &661053190 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 661053191} - - component: {fileID: 661053192} - - component: {fileID: 661053193} - - component: {fileID: 661053194} - m_Layer: 0 - m_Name: Outline - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &661053191 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 661053190} - 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: 5.3333335} - m_ConstrainProportionsScale: 1 - m_Children: [] - m_Father: {fileID: 1109852279} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &661053192 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 661053190} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RayTracingAccelStructBuildFlagsOverride: 0 - m_RayTracingAccelStructBuildFlags: 1 - m_SmallMeshCulling: 1 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: 9dfc825aed78fcd4ba02077103263b40, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: 811d3d3bfa653494784ee8ed56956471, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 1 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!114 &661053193 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 661053190} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: acf99b9aa18d4ab9b4ce796d513d476b, type: 3} - m_Name: - m_EditorClassIdentifier: - body: {fileID: 382708044} - outlineRenderer: {fileID: 661053192} - outlineCollider: {fileID: 0} ---- !u!70 &661053194 -CapsuleCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 661053190} - m_Enabled: 1 - serializedVersion: 3 - m_Density: 1 - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_LayerOverridePriority: 0 - m_ForceSendLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_ForceReceiveLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_ContactCaptureLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_CallbackLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_CompositeOperation: 0 - m_CompositeOrder: 0 - m_Offset: {x: 0, y: 0} - m_Size: {x: 1, y: 1} - m_Direction: 0 ---- !u!1 &788852946 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 788852947} - - component: {fileID: 788852948} - m_Layer: 0 - m_Name: Square - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &788852947 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 788852946} - 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: 382708045} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &788852948 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 788852946} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RayTracingAccelStructBuildFlagsOverride: 0 - m_RayTracingAccelStructBuildFlags: 1 - m_SmallMeshCulling: 1 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: 9dfc825aed78fcd4ba02077103263b40, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 --- !u!1001 &1002040475 PrefabInstance: m_ObjectHideFlags: 0 @@ -802,70 +542,6 @@ RectTransform: m_CorrespondingSourceObject: {fileID: 1690722858018107951, guid: f0afd08be12de0d43af753af4f618da4, type: 3} m_PrefabInstance: {fileID: 1002040475} m_PrefabAsset: {fileID: 0} ---- !u!1 &1109852278 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1109852279} - - component: {fileID: 1109852280} - - component: {fileID: 1109852281} - m_Layer: 0 - m_Name: CharacterPrefab - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1109852279 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1109852278} - 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: - - {fileID: 661053191} - - {fileID: 382708045} - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1109852280 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1109852278} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 757576bb4354ac54da09868e1be02eec, type: 3} - m_Name: - m_EditorClassIdentifier: - direction: {x: 0, y: 0, z: 0} - canSelect: 1 - body: {fileID: 382708044} ---- !u!114 &1109852281 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1109852278} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: b20b1846b9ef47db83c2ac8c4c4e82cb, type: 3} - m_Name: - m_EditorClassIdentifier: - entity: {fileID: 1109852280} - outline: {fileID: 661053193} --- !u!1001 &1147017152 PrefabInstance: m_ObjectHideFlags: 0 @@ -1704,4 +1380,3 @@ SceneRoots: - {fileID: 323725409} - {fileID: 1236970686} - {fileID: 603423468} - - {fileID: 1109852279} diff --git a/Client/Assets/Scenes/Test.unity b/Client/Assets/Scenes/Test.unity index 4907eac..157e8ca 100644 --- a/Client/Assets/Scenes/Test.unity +++ b/Client/Assets/Scenes/Test.unity @@ -242,6 +242,37 @@ 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: 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!1 &613797067 GameObject: m_ObjectHideFlags: 0 @@ -272,7 +303,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5e7ec2149bca47f42965dd01c01116cd, type: 3} m_Name: m_EditorClassIdentifier: - dataLevel: {fileID: 1236360967} textureLevel: {fileID: 9462741} --- !u!156049354 &613797069 Grid: @@ -317,7 +347,7 @@ GameObject: - component: {fileID: 1057087087} m_Layer: 0 m_Name: Camera - m_TagString: Untagged + m_TagString: MainCamera m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -607,7 +637,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 147e91e6929d90a4fb877c0b0a6b608c, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1 &1485465860 + entityManager: {fileID: 2036983433} +--- !u!1 &2036983430 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -615,42 +646,58 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1485465861} - - component: {fileID: 1485465862} + - component: {fileID: 2036983432} + - component: {fileID: 2036983433} + - component: {fileID: 2036983434} m_Layer: 0 - m_Name: Character + m_Name: "\u5168\u5C40" m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &1485465861 +--- !u!4 &2036983432 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1485465860} + m_GameObject: {fileID: 2036983430} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 0.17242, y: 0.05575, 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 &1485465862 +--- !u!114 &2036983433 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1485465860} + m_GameObject: {fileID: 2036983430} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 757576bb4354ac54da09868e1be02eec, type: 3} + m_Script: {fileID: 11500000, guid: aa378b7511b04429b8b6b0efbcce825a, type: 3} m_Name: m_EditorClassIdentifier: + entityLevel: {fileID: 309861628} + entityPrefab: {fileID: 3332598847335032684, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3} +--- !u!114 &2036983434 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2036983430} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cd0367766d04d8c4db80bcfe0202e619, type: 3} + m_Name: + m_EditorClassIdentifier: + isGlobal: 1 --- !u!1 &2104915506 GameObject: m_ObjectHideFlags: 0 @@ -699,8 +746,9 @@ Transform: SceneRoots: m_ObjectHideFlags: 0 m_Roots: - - {fileID: 1371068282} - {fileID: 1057087090} - {fileID: 613797070} - - {fileID: 1485465861} - {fileID: 2104915508} + - {fileID: 309861630} + - {fileID: 2036983432} + - {fileID: 1371068282} diff --git a/Client/Assets/Scripts/AI/AIBase.cs b/Client/Assets/Scripts/AI/AIBase.cs index a51f57b..ccafb88 100644 --- a/Client/Assets/Scripts/AI/AIBase.cs +++ b/Client/Assets/Scripts/AI/AIBase.cs @@ -8,7 +8,12 @@ namespace AI { public List children = new(); - public virtual JobBase GetJob(Entity.Entity target) + public abstract JobBase GetJob(Entity.Entity target); + } + + public class Selector : AIBase + { + public override JobBase GetJob(Entity.Entity target) { foreach (var aiBase in children) { @@ -19,28 +24,7 @@ namespace AI return null; } } - - public class ContinuousMove : AIBase - { - override public JobBase GetJob(Entity.Entity target) - { - - return null; - } - } - - public class TrackPlayer : AIBase - { - - } - public class RandomWander : AIBase - { - public override JobBase GetJob(Entity.Entity target) - { - return new WanderJob(); - } - } - public class ConditionalAI : AIBase + public class ConditionalAI : Selector { // 条件函数,返回 true 表示满足条件 private Func condition; @@ -64,4 +48,56 @@ namespace AI return null; } } + public class SequentialAI : Selector + { + private int currentIndex = 0; // 当前正在尝试的子节点索引 + + public override JobBase GetJob(Entity.Entity target) + { + // 如果当前索引超出了子节点范围,重置索引并返回 null + if (currentIndex >= children.Count) + { + ResetIndex(); + return null; + } + + // 获取当前子节点的任务 + var currentChild = children[currentIndex]; + var job = currentChild.GetJob(target); + + // 移动到下一个子节点 + currentIndex++; + + return job; + } + + // 重置当前索引(用于重新开始遍历) + private void ResetIndex() + { + currentIndex = 0; + } + } + public class ContinuousMove : AIBase + { + public override JobBase GetJob(Entity.Entity target) + { + return new MoveJob(); + } + } + + public class TrackPlayer : AIBase + { + public override JobBase GetJob(Entity.Entity target) + { + throw new NotImplementedException(); + } + } + public class RandomWander : AIBase + { + public override JobBase GetJob(Entity.Entity target) + { + return new WanderJob(); + } + } + } \ No newline at end of file diff --git a/Client/Assets/Scripts/AI/JobBase.cs b/Client/Assets/Scripts/AI/JobBase.cs index 34609e5..af7531b 100644 --- a/Client/Assets/Scripts/AI/JobBase.cs +++ b/Client/Assets/Scripts/AI/JobBase.cs @@ -7,7 +7,7 @@ namespace AI public abstract class JobBase { public Entity.Entity entity; - private int timeoutTicks = 100; + protected int timeoutTicks = 300; public bool Running=>timeoutTicks > 0; public virtual void StartJob(Entity.Entity target) @@ -57,5 +57,22 @@ namespace AI } } - + public class IdleJob:JobBase + { + override public void StartJob(Entity.Entity target) + { + base.StartJob(target); + timeoutTicks = 500; + } + protected override void UpdateJob() + { + } + } + public class MoveJob : JobBase + { + protected override void UpdateJob() + { + entity.TryMove(); + } + } } \ No newline at end of file diff --git a/Client/Assets/Scripts/Base/Clock.cs b/Client/Assets/Scripts/Base/Clock.cs index ec17ad2..6ba6772 100644 --- a/Client/Assets/Scripts/Base/Clock.cs +++ b/Client/Assets/Scripts/Base/Clock.cs @@ -105,5 +105,40 @@ namespace Base if (obj is ITickUI uiObj) tickUIs.Add(uiObj); } } + public static void AddTick(ITick tick) + { + if (Instance != null && !Instance.ticks.Contains(tick)) + Instance.ticks.Add(tick); + } + + public static void RemoveTick(ITick tick) + { + if (Instance != null) + Instance.ticks.Remove(tick); + } + + public static void AddTickPhysics(ITickPhysics physics) + { + if (Instance != null && !Instance.tickPhysics.Contains(physics)) + Instance.tickPhysics.Add(physics); + } + + public static void RemoveTickPhysics(ITickPhysics physics) + { + if (Instance != null) + Instance.tickPhysics.Remove(physics); + } + + public static void AddTickUI(ITickUI ui) + { + if (Instance != null && !Instance.tickUIs.Contains(ui)) + Instance.tickUIs.Add(ui); + } + + public static void RemoveTickUI(ITickUI ui) + { + if (Instance != null) + Instance.tickUIs.Remove(ui); + } } } \ No newline at end of file diff --git a/Client/Assets/Scripts/Data/Define.cs b/Client/Assets/Scripts/Data/Define.cs index 11940b5..3b638ca 100644 --- a/Client/Assets/Scripts/Data/Define.cs +++ b/Client/Assets/Scripts/Data/Define.cs @@ -15,7 +15,7 @@ namespace Data public string label; public string packID; - public bool isReferene=false; + public bool isReferene = false; /// /// 初始化方法,根据传入的 XML 元素 () 进行处理。 @@ -50,69 +50,93 @@ namespace Data { var sb = new StringBuilder(); - // 使用反射获取当前类的所有字段和属性 - var fieldsAndProperties = GetAllFieldsAndProperties(this); + // 显示基类中的基本信息 + sb.AppendLine($"Define {{"); + sb.AppendLine($"\tdefName: {defName}"); + sb.AppendLine($"\tdescription: {description}"); + sb.AppendLine($"\tlabel: {label}"); - foreach (var member in fieldsAndProperties) + // 获取当前对象的所有字段 + var fields = GetType().GetFields(BindingFlags.Public | BindingFlags.Instance); + + foreach (var field in fields) { - var name = member.Name; - var value = GetValue(member, this); + if (field.Name == "defName" || field.Name == "description" || field.Name == "label") + continue; // 已经显示过的基本信息跳过 - if (value is IList list && list.Count > 0) // 如果是列表类型 - { - sb.AppendLine($"{name}:"); - foreach (var item in list) sb.AppendLine($" - {FormatValue(item)}"); - } - else if (value is Define defineObject) // 如果是继承自 Define 的子类 - { - if (!string.IsNullOrEmpty(defineObject.defName)) - { - sb.AppendLine($"{name}: {defineObject.defName}"); - } - else - { - sb.AppendLine($"{name}:"); - sb.AppendLine(Indent(defineObject.ToString(), " ")); - } - } - else - { - sb.AppendLine($"{name}: {FormatValue(value)}"); - } + sb.Append("\t"); + sb.Append(field.Name); + sb.Append(": "); + + AppendFieldInfo(sb, field.GetValue(this), "\t\t"); + + sb.AppendLine(); } + sb.Append("}"); + return sb.ToString(); } - private static IEnumerable GetAllFieldsAndProperties(object obj) + private void AppendFieldInfo(StringBuilder sb, object value, string indent) { - var type = obj.GetType(); - return type.GetFields(BindingFlags.Public | BindingFlags.Instance) - .Concat(type.GetProperties(BindingFlags.Public | BindingFlags.Instance).Cast()); - } - - private static object GetValue(MemberInfo member, object obj) - { - switch (member) + if (value == null) { - case FieldInfo field: - return field.GetValue(obj); - case PropertyInfo property: - return property.GetValue(obj); - default: - throw new ArgumentException("Unsupported member type."); + sb.Append("null"); + return; + } + + var type = value.GetType(); + + // 如果是简单类型(如 int, string, bool 等) + if (type.IsPrimitive || type == typeof(string) || type == typeof(decimal)) + { + sb.Append(value); + } + // 如果是集合类型(如 List, Dictionary 等) + else if (typeof(IEnumerable).IsAssignableFrom(type) && !(value is string)) + { + sb.AppendLine(" ["); + var isFirst = true; + foreach (var item in (IEnumerable)value) + { + if (!isFirst) + sb.AppendLine(","); + isFirst = false; + + sb.Append(indent); + AppendFieldInfo(sb, item, indent + "\t"); + } + + if (!isFirst) // 如果集合不为空,则添加逗号后的换行 + sb.AppendLine(); + sb.Append(indent.TrimEnd('\t')); // 回退一级缩进 + sb.Append("]"); + } + // 如果是自定义对象类型 + else + { + sb.AppendLine(" {"); + var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance); + var isFirst = true; + foreach (var field in fields) + { + if (!isFirst) + sb.AppendLine(","); + isFirst = false; + + sb.Append(indent); + sb.Append(field.Name); + sb.Append(": "); + AppendFieldInfo(sb, field.GetValue(value), indent + "\t"); + } + + if (!isFirst) // 如果对象有字段,则添加逗号后的换行 + sb.AppendLine(); + sb.Append(indent.TrimEnd('\t')); // 回退一级缩进 + sb.Append("}"); } } - - private static string FormatValue(object value) - { - return value?.ToString() ?? "null"; - } - - private static string Indent(string text, string prefix) - { - return string.Join(Environment.NewLine, text.Split('\n').Select(line => prefix + line)); - } } - + } \ No newline at end of file diff --git a/Client/Assets/Scripts/Data/ItemDefine.cs b/Client/Assets/Scripts/Data/ItemDefine.cs index 084e698..1260110 100644 --- a/Client/Assets/Scripts/Data/ItemDefine.cs +++ b/Client/Assets/Scripts/Data/ItemDefine.cs @@ -1,8 +1,13 @@ namespace Data { - public class ItemDefine:Define + public class ItemDef:Define { public ImageDef texture; public AttributesDef attributes; } + + public class WeaponDef : ItemDef + { + + } } \ No newline at end of file diff --git a/Client/Assets/Scripts/Data/PawnDefine.cs b/Client/Assets/Scripts/Data/PawnDefine.cs index 8620459..dd10c6c 100644 --- a/Client/Assets/Scripts/Data/PawnDefine.cs +++ b/Client/Assets/Scripts/Data/PawnDefine.cs @@ -17,6 +17,7 @@ namespace Data drawingOrder_right; public BehaviorTreeDef behaviorTree; + public AffiliationDef affiliation; public DrawingOrderDef GetDrawingOrder(Orientation orientation) @@ -60,29 +61,38 @@ namespace Data public class BehaviorTreeDef : Define { public BehaviorTreeDef[] childTree; - public string className; + public string className="Selector"; + public string condition; + public override bool Init(XElement xmlDef) { base.Init(xmlDef); + // 从当前节点获取className和condition属性 + className = xmlDef.Attribute("className")?.Value ?? className; + condition = xmlDef.Attribute("condition")?.Value; + var nodes = xmlDef.Elements("Node"); - var xElements = nodes as XElement[] ?? nodes.ToArray(); - if (!xElements.Any()) - return false; + if (!nodes.Any()) + return true; // 没有子节点也是有效的 - className = xmlDef.Attribute("className")?.Value; List children = new(); - foreach (var node in xElements) + foreach (var node in nodes) { var childNode = new BehaviorTreeDef(); - childNode.Init(node); + if (!childNode.Init(node)) + return false; children.Add(childNode); } childTree = children.ToArray(); - return true; } } + + public class AffiliationDef : Define + { + + } } \ No newline at end of file diff --git a/Client/Assets/Scripts/Entity/BuildingBase.cs b/Client/Assets/Scripts/Entity/BuildingBase.cs new file mode 100644 index 0000000..8211fe3 --- /dev/null +++ b/Client/Assets/Scripts/Entity/BuildingBase.cs @@ -0,0 +1,10 @@ +namespace Entity +{ + public class BuildingBase:Entity + { + public override void TryMove() + { + } + + } +} \ No newline at end of file diff --git a/Client/Assets/Scripts/Entity/BuildingBase.cs.meta b/Client/Assets/Scripts/Entity/BuildingBase.cs.meta new file mode 100644 index 0000000..b93038b --- /dev/null +++ b/Client/Assets/Scripts/Entity/BuildingBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: eb881a08fe004eb4ab0a6fa9d5d86d33 +timeCreated: 1753100586 \ No newline at end of file diff --git a/Client/Assets/Scripts/Entity/Character.cs b/Client/Assets/Scripts/Entity/Character.cs index 8ea0579..98b3b0c 100644 --- a/Client/Assets/Scripts/Entity/Character.cs +++ b/Client/Assets/Scripts/Entity/Character.cs @@ -10,12 +10,11 @@ namespace Entity public class Character : Entity { public CharacterDef characterDef; - public GameObject body; private void Start() { aiTree = new RandomWander(); - runtimeAttributes = new AttributesDef(); + attributes = new AttributesDef(); } public void Init() diff --git a/Client/Assets/Scripts/Entity/Entity.cs b/Client/Assets/Scripts/Entity/Entity.cs index 465d887..276b615 100644 --- a/Client/Assets/Scripts/Entity/Entity.cs +++ b/Client/Assets/Scripts/Entity/Entity.cs @@ -7,12 +7,13 @@ using UnityEngine.Serialization; namespace Entity { - public abstract class Entity:MonoBehaviour,ITick + public class Entity:MonoBehaviour,ITick { public AIBase aiTree; public JobBase currentJob; - public AttributesDef runtimeAttributes; + public AttributesDef attributes; public Vector3 direction; + public GameObject body; public bool canSelect = true; public bool IsChase { set; get; } = true; @@ -53,15 +54,15 @@ namespace Entity /// public virtual void TryMove() { - transform.position+=direction * (runtimeAttributes.moveSpeed * Time.deltaTime * (IsChase ? 1 : 0.5f)); + transform.position+=direction * (attributes.moveSpeed * Time.deltaTime * (IsChase ? 1 : 0.5f)); } public virtual void OnHit(Entity from) { - var hit = from.runtimeAttributes.attack - runtimeAttributes.defense; + var hit = from.attributes.attack - attributes.defense; if (hit < 0) - hit = from.runtimeAttributes.attack / 100; - runtimeAttributes.health -= hit; + hit = from.attributes.attack / 100; + attributes.health -= hit; currentJob.StopJob(); } diff --git a/Client/Assets/Scripts/Managers/DefineManager.cs b/Client/Assets/Scripts/Managers/DefineManager.cs index 613c5ec..44c06b3 100644 --- a/Client/Assets/Scripts/Managers/DefineManager.cs +++ b/Client/Assets/Scripts/Managers/DefineManager.cs @@ -44,16 +44,14 @@ namespace Managers Dictionary fieldCache = new(); + // 需要链接的定义、需要链接的字段、链接信息 List> defineCache = new(); - HashSet processedDefines = new(); // 用于跟踪已处理的 Define 对象 - void ProcessDefine(Define def, Define parentDef, FieldInfo parentField) + void ProcessDefine(Define def) { - if (def == null || def.isReferene || processedDefines.Contains(def)) + if (def == null || def.isReferene) return; - - processedDefines.Add(def); - + // 如果字段信息已经缓存,则直接使用缓存 if (!fieldCache.TryGetValue(def.GetType(), out var defineFields)) { @@ -73,7 +71,7 @@ namespace Managers continue; if (defRef.isReferene) { - defineCache.Add(new Tuple(parentDef, parentField, defRef)); + defineCache.Add(new Tuple(def, defineField, defRef)); } else { @@ -84,33 +82,54 @@ namespace Managers anonymousDefines.Add(typeName, new List()); anonymousDefines[typeName].Add(defRef); } - ProcessDefine(defRef, def, defineField); + ProcessDefine(defRef); } } } foreach (var pack in packs) { - foreach (var define in pack.Value.defines) + foreach (var (typeName, defList) in pack.Value.defines) { - var typeName = define.Key; - var defList = define.Value; - if (!defines.ContainsKey(typeName)) defines[typeName] = new Dictionary(); foreach (var def in defList) { defines[typeName][def.defName] = def; - - // 处理顶层 Define - ProcessDefine(def, null, null); + ProcessDefine(def); } } } foreach (var defRef in defineCache) { - defRef.Item2.SetValue(defRef.Item1, FindDefine(defRef.Item3.description, defRef.Item3.defName)); + if (defRef.Item1 == null) + { + Debug.LogError("defRef.Item1 为 null!"); + continue; + } + + if (defRef.Item2 == null) + { + Debug.LogError("defRef.Item2 为 null!"); + continue; + } + + var value = FindDefine(defRef.Item3.description, defRef.Item3.defName); + if (value == null) + { + Debug.LogError($"FindDefine 返回 null: description={defRef.Item3.description}, defName={defRef.Item3.defName}"); + continue; + } + + try + { + defRef.Item2.SetValue(defRef.Item1, value); + } + catch (Exception ex) + { + Debug.LogError($"SetValue 出错: {ex.Message}"); + } } } @@ -138,7 +157,23 @@ namespace Managers } return null; } - + /// + /// 使用模板查找并返回指定类型的 Define 对象。 + /// + /// 目标类型 + /// 定义名 + /// 如果找到,返回转换为目标类型的 Define 对象;否则返回 null。 + public T FindDefine(string defineName) where T : Define + { + foreach (var typeDict in defines.Values) + { + if (typeDict.TryGetValue(defineName, out var define) && define is T result) + { + return result; + } + } + return null; + } public DefinePack GetDefinePackage(Define define) { if (define == null || define.packID == null) diff --git a/Client/Assets/Scripts/Managers/EntityManage.cs b/Client/Assets/Scripts/Managers/EntityManage.cs new file mode 100644 index 0000000..863a99d --- /dev/null +++ b/Client/Assets/Scripts/Managers/EntityManage.cs @@ -0,0 +1,88 @@ +using System.Collections.Generic; +using System.Linq; +using Prefab; +using UnityEngine; + +namespace Managers +{ + public class EntityManage:MonoBehaviour + { + public Dictionary> factionEntities = new(); + + public GameObject entityLevel; + public EntityPrefab entityPrefab; + void Update() + { + // 检测鼠标左键是否按下 + if (Input.GetMouseButtonDown(0)) + { + var ray = Camera.main.ScreenPointToRay(Input.mousePosition); // 获取从相机发出的射线 + + if (Physics.Raycast(ray, out var hit)) // 检测射线是否击中物体 + { + Debug.Log("点击了物体: " + hit.collider.gameObject.name); + + } + } + } + /// + /// 根据给定的PawnDef生成一个实体对象。 + /// + /// 定义实体属性的PawnDef对象。 + /// 实体生成的位置。 + /// + /// 1. 如果entityPrefab或pawnDef为null,则不会生成实体。 + /// 2. 实体将被创建在entityLevel.transform下。 + /// 3. 使用EntityPrefab组件初始化实体。 + /// + public void GenerateEntity(Data.PawnDef pawnDef, Vector3 pos) + { + // 检查entityPrefab是否为空 + if (entityPrefab == null) + { + Debug.LogError("Error: entityPrefab is null. Please assign a valid prefab."); + return; + } + + // 检查pawnDef是否为空 + if (pawnDef == null) + { + Debug.LogError("Error: PawnDef is null. Cannot generate entity without a valid PawnDef."); + return; + } + + try + { + // 实例化实体对象 + var entity = Instantiate(entityPrefab.gameObject, pos, Quaternion.identity, entityLevel.transform); + + // 获取EntityPrefab组件 + var entityComponent = entity.GetComponent(); + + // 检查EntityPrefab组件是否存在 + if (entityComponent == null) + { + Debug.LogError($"Error: EntityPrefab component not found on the instantiated object: {entity.name}"); + return; + } + + // 初始化实体组件 + entityComponent.Init(pawnDef); + // 确保派系键存在,并初始化对应的列表 + var factionKey = pawnDef.attributes.label == null ? "default" : pawnDef.attributes.label; + if (!factionEntities.ContainsKey(factionKey)) + { + factionEntities[factionKey] = new List(); + } + factionEntities[factionKey].Add(entityComponent); + + Base.Clock.AddTick(entity.GetComponent()); + } + catch (System.Exception ex) + { + // 捕获并记录任何异常 + Debug.LogError($"An error occurred while generating the entity: {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/Client/Assets/Scripts/Managers/EntityManage.cs.meta b/Client/Assets/Scripts/Managers/EntityManage.cs.meta new file mode 100644 index 0000000..268cbaf --- /dev/null +++ b/Client/Assets/Scripts/Managers/EntityManage.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: aa378b7511b04429b8b6b0efbcce825a +timeCreated: 1753149728 \ No newline at end of file diff --git a/Client/Assets/Scripts/Managers/Generator.cs b/Client/Assets/Scripts/Managers/Generator.cs deleted file mode 100644 index 80d5a06..0000000 --- a/Client/Assets/Scripts/Managers/Generator.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Prefab; -using UnityEngine; - -namespace Managers -{ - public class Generator:MonoBehaviour - { - public GameObject entityLevel; - public EntityPrefab entityPrefab; - - public void GenerateEntity(Data.PawnDef pawnDef, Vector3 pos) - { - if (entityPrefab == null || pawnDef == null) - return; - - GameObject entity = Instantiate(entityPrefab.gameObject, pos, Quaternion.identity, entityLevel.transform); - // entity.name = pawnDef.name; - var entityComponent = entity.GetComponent(); - entityComponent?.Init(pawnDef); - } - } -} \ No newline at end of file diff --git a/Client/Assets/Scripts/Managers/Generator.cs.meta b/Client/Assets/Scripts/Managers/Generator.cs.meta deleted file mode 100644 index 33bb771..0000000 --- a/Client/Assets/Scripts/Managers/Generator.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d78f1b5a44344a4a987e308d3b9478cc -timeCreated: 1752937967 \ No newline at end of file diff --git a/Client/Assets/Scripts/Managers/PackagesImageManager.cs b/Client/Assets/Scripts/Managers/PackagesImageManager.cs index e6f43b4..750743f 100644 --- a/Client/Assets/Scripts/Managers/PackagesImageManager.cs +++ b/Client/Assets/Scripts/Managers/PackagesImageManager.cs @@ -31,7 +31,7 @@ namespace Managers if (!packagesImages.ContainsKey(packId)) packagesImages[packId] = new Dictionary(); packagesImages[packId].Add(ima.name, texture); - + SplitTextureIntoSprites(packId, ima.name, texture, ima.hCount, ima.wCount, ima.pixelsPerUnit); } } @@ -44,15 +44,31 @@ namespace Managers int cols, int pixelsPerUnit) { - if (texture == null || rows <= 0 || cols <= 0) + if (texture == null) { - Debug.LogError("Invalid parameters for splitting texture."); + Debug.LogError("Texture is null."); return; } + // 如果行数或列数小于1,则设为1(不分割) + rows = Mathf.Max(1, rows); + cols = Mathf.Max(1, cols); + var textureWidth = texture.width; var textureHeight = texture.height; + // 如果不分割(rows和cols都为1),直接创建单个Sprite + if (rows == 1 && cols == 1) + { + if (!sprites.ContainsKey(packId)) + sprites[packId] = new Dictionary(); + + Rect spriteRect = new Rect(0, 0, textureWidth, textureHeight); + var sprite = Sprite.Create(texture, spriteRect, new Vector2(0.5f, 0.5f), pixelsPerUnit); + sprites[packId][baseName] = sprite; + return; + } + var tileWidth = textureWidth / cols; var tileHeight = textureHeight / rows; @@ -61,7 +77,7 @@ namespace Managers Debug.LogError("Texture dimensions are not divisible by the specified rows and columns."); return; } - + if (!sprites.ContainsKey(packId)) sprites[packId] = new Dictionary(); @@ -71,7 +87,7 @@ namespace Managers { 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 spriteName = $"{baseName}_{index}"; diff --git a/Client/Assets/Scripts/Prefab/EntityPrefab.cs b/Client/Assets/Scripts/Prefab/EntityPrefab.cs index e2be6dc..2ecb286 100644 --- a/Client/Assets/Scripts/Prefab/EntityPrefab.cs +++ b/Client/Assets/Scripts/Prefab/EntityPrefab.cs @@ -16,7 +16,7 @@ namespace Prefab public void Init(Data.PawnDef pawnDef) { - entity.runtimeAttributes = pawnDef.attributes.Clone(); + entity.attributes = pawnDef.attributes.Clone(); entity.aiTree = ConvertToAIBase(pawnDef.behaviorTree); outline.Init(); @@ -45,7 +45,10 @@ namespace Prefab { if (string.IsNullOrEmpty(className)) throw new ArgumentException("className 不能为空"); - + if (className.Equals("AIBase", StringComparison.OrdinalIgnoreCase)) + { + return (AIBase)Activator.CreateInstance(typeof(AIBase)); + } // 定义可能的命名空间列表 var possibleNamespaces = new[] { "AI"}; diff --git a/Client/Assets/Scripts/Test/ClockTest.cs b/Client/Assets/Scripts/Test/ClockTest.cs deleted file mode 100644 index 25bdf66..0000000 --- a/Client/Assets/Scripts/Test/ClockTest.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Base; -using UnityEngine; - -namespace Test -{ - public class ClockTest : MonoBehaviour - { - //private static float timer = 0; - - // Start is called once before the first execution of Update after the MonoBehaviour is created - private void Start() - { - var clock = Clock.Instance; - } - - // Update is called once per frame - //void Update() - //{ - // if (Input.GetKeyUp(KeyCode.W)) - // { - // SceneManager.LoadScene("SampleScene"); - // } - // if (timer > 1) - // { - // timer -= 1; - // Debug.Log("��������ʱ�ӳ�ʼ����"); - // } - // timer += Time.deltaTime; - //} - } -} \ No newline at end of file diff --git a/Client/Assets/Scripts/Test/ClockTest.cs.meta b/Client/Assets/Scripts/Test/ClockTest.cs.meta deleted file mode 100644 index 074053c..0000000 --- a/Client/Assets/Scripts/Test/ClockTest.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: be939c7ca1c4f374b83b6535b3cbb656 \ No newline at end of file diff --git a/Client/Assets/Scripts/Test/TestDefine.cs b/Client/Assets/Scripts/Test/TestDefine.cs index 1f9b464..673746a 100644 --- a/Client/Assets/Scripts/Test/TestDefine.cs +++ b/Client/Assets/Scripts/Test/TestDefine.cs @@ -1,3 +1,6 @@ +using System; +using Data; +using Managers; using UnityEngine; namespace Test @@ -6,11 +9,17 @@ namespace Test public class TestDefine : MonoBehaviour { - // Start is called once before the first execution of Update after the MonoBehaviour is created + public EntityManage entityManager; void Awake() { Managers.DefineManager.Instance.Init(); - Debug.Log(Managers.DefineManager.Instance); + } + + private void Start() + { + var chicken = Managers.DefineManager.Instance.FindDefine("testPawn"); + entityManager.GenerateEntity(chicken,Vector3.zero); + Debug.Log(chicken); } // Update is called once per frame diff --git a/Client/Data/Core/Define/Pawn/Character.xml b/Client/Data/Core/Define/Pawn/Character.xml index bf2e285..e149c64 100644 --- a/Client/Data/Core/Define/Pawn/Character.xml +++ b/Client/Data/Core/Define/Pawn/Character.xml @@ -1,5 +1,11 @@ + + + playerAffiliation + + + TestCharacter 100 @@ -9,11 +15,13 @@ testPawn + TestCharacter + playerAffiliation - + diff --git a/Client/Data/Core/Define/Pawn/Monster.xml b/Client/Data/Core/Define/Pawn/Monster.xml index d9cff64..ebdae22 100644 --- a/Client/Data/Core/Define/Pawn/Monster.xml +++ b/Client/Data/Core/Define/Pawn/Monster.xml @@ -1,17 +1,25 @@ - - tenMonster - - 10 - - - cheken + chicken embrace - Claw + + + + + + + + + + + + + + +