From 9536e1b1c837276480d94ee8e0b1b27820cf207d Mon Sep 17 00:00:00 2001 From: GanX <2423855310@qq.com> Date: Tue, 14 Oct 2025 14:10:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(Card):=20=E5=8D=A1=E7=89=8C=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E6=A1=86=E6=9E=B6=EF=BC=8C=E5=B0=9A=E6=9C=AA=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scenes/Level1.unity | 139 ++++++++++++++---- Assets/Script/Card/Card.cs | 23 ++- Assets/Script/Card/CardConfig.cs | 14 -- Assets/Script/Card/CardData.cs | 16 ++ .../{CardConfig.cs.meta => CardData.cs.meta} | 0 Assets/Script/Card/CardEffect/CardContext.cs | 10 ++ .../Card/CardEffect/CardContext.cs.meta | 3 + Assets/Script/Card/CardEffect/EffectData.cs | 28 ++++ .../Script/Card/CardEffect/EffectData.cs.meta | 3 + .../Script/Card/CardEffect/EffectHandler.cs | 33 +++++ .../Card/CardEffect/EffectHandler.cs.meta | 3 + Assets/Script/Card/CardEffect/ICardEffect.cs | 7 - .../Card/CardEffect/ICardEffect.cs.meta | 3 - Assets/Script/Card/CardViewer.cs | 4 +- Assets/Script/Share/ICharacter.cs | 15 ++ Assets/Script/Share/ICharacter.cs.meta | 3 + 16 files changed, 246 insertions(+), 58 deletions(-) delete mode 100644 Assets/Script/Card/CardConfig.cs create mode 100644 Assets/Script/Card/CardData.cs rename Assets/Script/Card/{CardConfig.cs.meta => CardData.cs.meta} (100%) create mode 100644 Assets/Script/Card/CardEffect/CardContext.cs create mode 100644 Assets/Script/Card/CardEffect/CardContext.cs.meta create mode 100644 Assets/Script/Card/CardEffect/EffectData.cs create mode 100644 Assets/Script/Card/CardEffect/EffectData.cs.meta create mode 100644 Assets/Script/Card/CardEffect/EffectHandler.cs create mode 100644 Assets/Script/Card/CardEffect/EffectHandler.cs.meta delete mode 100644 Assets/Script/Card/CardEffect/ICardEffect.cs delete mode 100644 Assets/Script/Card/CardEffect/ICardEffect.cs.meta create mode 100644 Assets/Script/Share/ICharacter.cs create mode 100644 Assets/Script/Share/ICharacter.cs.meta diff --git a/Assets/Scenes/Level1.unity b/Assets/Scenes/Level1.unity index 89d7244..c2f4bf6 100644 --- a/Assets/Scenes/Level1.unity +++ b/Assets/Scenes/Level1.unity @@ -38,7 +38,6 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.18028305, g: 0.22571313, b: 0.3069213, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -104,7 +103,7 @@ NavMeshSettings: serializedVersion: 2 m_ObjectHideFlags: 0 m_BuildSettings: - serializedVersion: 2 + serializedVersion: 3 agentTypeID: 0 agentRadius: 0.5 agentHeight: 2 @@ -117,7 +116,7 @@ NavMeshSettings: cellSize: 0.16666667 manualTileSize: 0 tileSize: 256 - accuratePlacement: 0 + buildHeightMesh: 0 maxJobWorkers: 0 preserveTilesOutsideBounds: 0 debug: @@ -164,9 +163,17 @@ Camera: m_projectionMatrixMode: 1 m_GateFitMode: 2 m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -200,13 +207,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 330585543} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 1, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &330585547 MonoBehaviour: @@ -238,9 +245,20 @@ MonoBehaviour: m_Dithering: 0 m_ClearDepth: 1 m_AllowXRRendering: 1 + m_AllowHDROutput: 1 + m_UseScreenCoordOverride: 0 + m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} + 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 + m_JitterScale: 1 + m_MipBias: 0 + m_VarianceClampScale: 0.9 + m_ContrastAdaptiveSharpening: 0 --- !u!1 &410087039 GameObject: m_ObjectHideFlags: 0 @@ -328,13 +346,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 410087039} + serializedVersion: 2 m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 3, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!114 &410087042 MonoBehaviour: @@ -348,15 +366,18 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} m_Name: m_EditorClassIdentifier: - m_Version: 1 + m_Version: 3 m_UsePipelineSettings: 1 m_AdditionalLightsShadowResolutionTier: 2 m_LightLayerMask: 1 + m_RenderingLayers: 1 m_CustomShadowLayers: 0 m_ShadowLayerMask: 1 + m_ShadowRenderingLayers: 1 m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} ---- !u!1 &832575517 + m_SoftShadowQuality: 1 +--- !u!1 &1274249800 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -364,44 +385,108 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 832575519} - - component: {fileID: 832575518} + - component: {fileID: 1274249804} + - component: {fileID: 1274249803} + - component: {fileID: 1274249802} + - component: {fileID: 1274249801} m_Layer: 0 - m_Name: Global Volume + m_Name: Plane m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &832575518 -MonoBehaviour: +--- !u!64 &1274249801 +MeshCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 832575517} + m_GameObject: {fileID: 1274249800} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IsGlobal: 1 - priority: 0 - blendDistance: 0 - weight: 1 - sharedProfile: {fileID: 11400000, guid: a6560a915ef98420e9faacc1c7438823, type: 2} ---- !u!4 &832575519 + serializedVersion: 5 + m_Convex: 0 + m_CookingOptions: 30 + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1274249802 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1274249800} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, 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: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1274249803 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1274249800} + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1274249804 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 832575517} + m_GameObject: {fileID: 1274249800} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: -0.097626016, y: 0.17689009, z: -0.20200007} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 330585546} + - {fileID: 410087041} + - {fileID: 1274249804} diff --git a/Assets/Script/Card/Card.cs b/Assets/Script/Card/Card.cs index 5d334fe..cb8bed4 100644 --- a/Assets/Script/Card/Card.cs +++ b/Assets/Script/Card/Card.cs @@ -4,10 +4,23 @@ namespace Card { public class Card { - private CardConfig cardConfig; - - public Sprite Sprite => cardConfig.CardIcon; - public string CardName => cardConfig.CardName; - public string CardDescription => cardConfig.CardDescription; + private CardData _cardData; + public Texture Texture => _cardData.CardTexture; + public string CardName => _cardData.CardName; + public string CardDescription => _cardData.CardDescription; + public EffectData[] Effects => _cardData.Effects; + + public Card(CardData cardData) + { + _cardData = cardData; + } + + public void PlayCard(CardContext context) + { + foreach (var effect in Effects) + { + EffectHandler.Execute(effect, context); + } + } } } \ No newline at end of file diff --git a/Assets/Script/Card/CardConfig.cs b/Assets/Script/Card/CardConfig.cs deleted file mode 100644 index e82ae24..0000000 --- a/Assets/Script/Card/CardConfig.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Card -{ - public class CardConfig : ScriptableObject - { - public string CardName; - public string CardDescription; - public Sprite CardIcon; - } - -} diff --git a/Assets/Script/Card/CardData.cs b/Assets/Script/Card/CardData.cs new file mode 100644 index 0000000..5a5f6b7 --- /dev/null +++ b/Assets/Script/Card/CardData.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Card +{ + [CreateAssetMenu(fileName = "NewCard", menuName = "Card/CardData")] + public class CardData : ScriptableObject + { + public string CardName; + public string CardDescription; + public Texture CardTexture; + public EffectData[] Effects; + } + +} diff --git a/Assets/Script/Card/CardConfig.cs.meta b/Assets/Script/Card/CardData.cs.meta similarity index 100% rename from Assets/Script/Card/CardConfig.cs.meta rename to Assets/Script/Card/CardData.cs.meta diff --git a/Assets/Script/Card/CardEffect/CardContext.cs b/Assets/Script/Card/CardEffect/CardContext.cs new file mode 100644 index 0000000..8f4e2d9 --- /dev/null +++ b/Assets/Script/Card/CardEffect/CardContext.cs @@ -0,0 +1,10 @@ +using UnityEngine; +using Share; +namespace Card +{ + public class CardContext + { + public ICharacter Player; + public ICharacter Target; + } +} \ No newline at end of file diff --git a/Assets/Script/Card/CardEffect/CardContext.cs.meta b/Assets/Script/Card/CardEffect/CardContext.cs.meta new file mode 100644 index 0000000..7d53ab7 --- /dev/null +++ b/Assets/Script/Card/CardEffect/CardContext.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7279b5677f724ab4b93bd1028542d110 +timeCreated: 1760420712 \ No newline at end of file diff --git a/Assets/Script/Card/CardEffect/EffectData.cs b/Assets/Script/Card/CardEffect/EffectData.cs new file mode 100644 index 0000000..c80a1a2 --- /dev/null +++ b/Assets/Script/Card/CardEffect/EffectData.cs @@ -0,0 +1,28 @@ +using UnityEngine; + +namespace Card +{ + [System.Serializable] + public class EffectData + { + public EffectType type; // 效果类型,例如攻击、治疗、抽卡 + public int value; // 参数值 + public TargetType target; // 可选参数:目标类型("self", "enemy", "all") + } + + public enum TargetType + { + Self, + Enemy, + All, + None + } + + public enum EffectType + { + Damage, + Heal, + DrawCard, + AddBuff, + } +} \ No newline at end of file diff --git a/Assets/Script/Card/CardEffect/EffectData.cs.meta b/Assets/Script/Card/CardEffect/EffectData.cs.meta new file mode 100644 index 0000000..625fa10 --- /dev/null +++ b/Assets/Script/Card/CardEffect/EffectData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5790e0b2fbce41c99a775bbacca0e2bc +timeCreated: 1760420527 \ No newline at end of file diff --git a/Assets/Script/Card/CardEffect/EffectHandler.cs b/Assets/Script/Card/CardEffect/EffectHandler.cs new file mode 100644 index 0000000..dcdd04c --- /dev/null +++ b/Assets/Script/Card/CardEffect/EffectHandler.cs @@ -0,0 +1,33 @@ +using UnityEngine; + +namespace Card +{ + public static class EffectHandler + { + public static void Execute(EffectData effect, CardContext context) + { + switch (effect.type) + { + case EffectType.Damage: + context.Target.TakeDamage(effect.value); + break; + + case EffectType.Heal: + context.Target.Heal(effect.value); + break; + + case EffectType.DrawCard: + context.Player.Draw(effect.value); + break; + + case EffectType.AddBuff: + //TODO:context.Target.AddBuff(effect.value); + break; + + default: + Debug.LogWarning($"未知效果类型: {effect.type}"); + break; + } + } + } +} \ No newline at end of file diff --git a/Assets/Script/Card/CardEffect/EffectHandler.cs.meta b/Assets/Script/Card/CardEffect/EffectHandler.cs.meta new file mode 100644 index 0000000..487a91a --- /dev/null +++ b/Assets/Script/Card/CardEffect/EffectHandler.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 032e368e3d5846d78caf5f3239de979f +timeCreated: 1760420695 \ No newline at end of file diff --git a/Assets/Script/Card/CardEffect/ICardEffect.cs b/Assets/Script/Card/CardEffect/ICardEffect.cs deleted file mode 100644 index 0816ee6..0000000 --- a/Assets/Script/Card/CardEffect/ICardEffect.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Card -{ - public interface ICardEffect - { - public void DoEffect(); - } -} \ No newline at end of file diff --git a/Assets/Script/Card/CardEffect/ICardEffect.cs.meta b/Assets/Script/Card/CardEffect/ICardEffect.cs.meta deleted file mode 100644 index ca3ebc0..0000000 --- a/Assets/Script/Card/CardEffect/ICardEffect.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d2f68930f8eb498aabe29d66e5740753 -timeCreated: 1760405389 \ No newline at end of file diff --git a/Assets/Script/Card/CardViewer.cs b/Assets/Script/Card/CardViewer.cs index eb15af1..ab815ac 100644 --- a/Assets/Script/Card/CardViewer.cs +++ b/Assets/Script/Card/CardViewer.cs @@ -8,14 +8,14 @@ namespace Card { public Card Card; - [SerializeField] private SpriteRenderer spriteRenderer; + [SerializeField] private MeshRenderer meshRenderer; [SerializeField] private Text cardNameText; [SerializeField] private Text cardDescriptionText; public void Setup(Card card) { Card = card; - spriteRenderer.sprite = card.Sprite; + meshRenderer.material.mainTexture = card.Texture; cardNameText.text = card.CardName; cardDescriptionText.text = card.CardDescription; } diff --git a/Assets/Script/Share/ICharacter.cs b/Assets/Script/Share/ICharacter.cs new file mode 100644 index 0000000..5f37c13 --- /dev/null +++ b/Assets/Script/Share/ICharacter.cs @@ -0,0 +1,15 @@ +using UnityEngine; + +namespace Share +{ + /// + /// 角色接口,可受伤害、治疗和添加Buff + /// + public interface ICharacter + { + public void TakeDamage(int damage); + public void Heal(int heal); + public void AddBuff(string buffName, int duration); + public void Draw(int count); + } +} \ No newline at end of file diff --git a/Assets/Script/Share/ICharacter.cs.meta b/Assets/Script/Share/ICharacter.cs.meta new file mode 100644 index 0000000..47a911d --- /dev/null +++ b/Assets/Script/Share/ICharacter.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a0f41a6a18dd4801a9d6ba995cf09376 +timeCreated: 1760420819 \ No newline at end of file