feat(Card): 卡牌基本框架,尚未测试

This commit is contained in:
2025-10-14 14:10:20 +08:00
parent eba8d5792d
commit 9536e1b1c8
16 changed files with 246 additions and 58 deletions

View File

@@ -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}

View File

@@ -4,10 +4,23 @@ namespace Card
{
public class Card
{
private CardConfig cardConfig;
private CardData _cardData;
public Texture Texture => _cardData.CardTexture;
public string CardName => _cardData.CardName;
public string CardDescription => _cardData.CardDescription;
public EffectData[] Effects => _cardData.Effects;
public Sprite Sprite => cardConfig.CardIcon;
public string CardName => cardConfig.CardName;
public string CardDescription => cardConfig.CardDescription;
public Card(CardData cardData)
{
_cardData = cardData;
}
public void PlayCard(CardContext context)
{
foreach (var effect in Effects)
{
EffectHandler.Execute(effect, context);
}
}
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,10 @@
using UnityEngine;
using Share;
namespace Card
{
public class CardContext
{
public ICharacter Player;
public ICharacter Target;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7279b5677f724ab4b93bd1028542d110
timeCreated: 1760420712

View File

@@ -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,
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5790e0b2fbce41c99a775bbacca0e2bc
timeCreated: 1760420527

View File

@@ -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;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 032e368e3d5846d78caf5f3239de979f
timeCreated: 1760420695

View File

@@ -1,7 +0,0 @@
namespace Card
{
public interface ICardEffect
{
public void DoEffect();
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: d2f68930f8eb498aabe29d66e5740753
timeCreated: 1760405389

View File

@@ -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;
}

View File

@@ -0,0 +1,15 @@
using UnityEngine;
namespace Share
{
/// <summary>
/// 角色接口可受伤害、治疗和添加Buff
/// </summary>
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);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a0f41a6a18dd4801a9d6ba995cf09376
timeCreated: 1760420819