feat(): 大量更新

This commit is contained in:
2025-10-15 21:31:13 +08:00
parent 546f08c53a
commit 668bfe12eb
178 changed files with 11318 additions and 446 deletions

View File

@@ -0,0 +1,26 @@
using UnityEngine;
namespace Gameplay
{
public class Card
{
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);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1081ce761bc440e29a2f7b75915e5754
timeCreated: 1760361406

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 37e71088bd934b78aa07c7a76b7e5d07
timeCreated: 1760422523

View File

@@ -0,0 +1,48 @@
using System;
using UnityEngine;
namespace Gameplay
{
public class CardBook
{
public CardBookData Data;
public CardSlot[] Slots;
public CardSlot[] Spares;
public CardBook(CardBookData data)
{
Data = data;
Slots = new CardSlot[Data.SlotCount];
Spares = new CardSlot[Data.SpareCount];
for (int i = 0; i < Slots.Length; i++)
{
Slots[i] = new CardSlot();
}
for (int i = 0; i < Spares.Length; i++)
{
Spares[i] = new CardSlot();
}
}
// Get all cards in the card book,and not Spares
public Card[] GetCards()
{
var cards = new Card[Slots.Length + Spares.Length];
for (int i = 0; i < Slots.Length; i++)
{
cards[i] = Slots[i].StoredCard;
}
return cards;
}
public Card[] GetSpareCards()
{
var cards = new Card[Spares.Length + Spares.Length];
for (int i = 0; i < Spares.Length; i++)
{
cards[i] = Spares[i].StoredCard;
}
return cards;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4bb8bfb17c6a4eaa88954871942ee72d
timeCreated: 1760422530

View File

@@ -0,0 +1,12 @@
using UnityEngine;
namespace Gameplay
{
[CreateAssetMenu(fileName = "CardBookData", menuName = "ScriptableObject/CardBookData", order = 1)]
public class CardBookData : ScriptableObject
{
public int SlotCount;
public int SpareCount;
public int MaxLoopCount;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 54f1f8ff48b84542962110e7a9851917
timeCreated: 1760422573

View File

@@ -0,0 +1,12 @@
using UnityEngine;
namespace Gameplay
{
// 卡牌书的显示相关脚本
public class CardBookViewer : MonoBehaviour
{
[SerializeField] private Transform LeftHandPoint;
private CardBook CardBook;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 68803a8f56734f22a3025f8028fc027f
timeCreated: 1760431288

View File

@@ -0,0 +1,23 @@
namespace Gameplay
{
public class CardSlot
{
public Card StoredCard;
public bool IsEmpty => StoredCard == null;
public int ActiveTimes = 0;
public void StoreCard(Card card)
{
StoredCard = card;
ActiveTimes = 0;
}
public Card RemoveCard()
{
var card = StoredCard;
StoredCard = null;
ActiveTimes = 0;
return card;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e5f566603b3f4286965da48bb49c018a
timeCreated: 1760422548

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Gameplay
{
[CreateAssetMenu(fileName = "CardData", menuName = "ScriptableObject/CardData")]
public class CardData : ScriptableObject
{
public int CardID;
public string CardName;
public string CardDescription;
public Texture CardTexture;
public EffectData[] Effects;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7c9f5640c7fc55141af2931d0caed1e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ea39c6a061fd421988facd6fcb95c639
timeCreated: 1760405374

View File

@@ -0,0 +1,16 @@
using UnityEngine;
using Share;
namespace Gameplay
{
public class CardContext
{
public ICharacter Owner;
public ICharacter Enemy;
public CardContext(ICharacter owner,ICharacter enemy)
{
Owner = owner;
Enemy = enemy;
}
}
}

View File

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

View File

@@ -0,0 +1,26 @@
using UnityEngine;
namespace Gameplay
{
[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,
}
}

View File

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

View File

@@ -0,0 +1,24 @@
using UnityEngine;
namespace Gameplay
{
public static class EffectHandler
{
public static void Execute(EffectData effect, CardContext context)
{
switch (effect.type)
{
case EffectType.Damage:
context.Enemy.TakeDamage(effect.value);
break;
case EffectType.Heal:
context.Enemy.Heal(effect.value);
break;
default:
Debug.Log($"未知效果类型: {effect.type}");
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,21 @@
using UnityEngine;
namespace Gameplay
{
// 从Resources文件夹加载卡牌数据的静态类
public static class CardLoader
{
public static CardData GetCardDataByID(int cardID)
{
CardData[] allCards = Resources.LoadAll<CardData>("Configs/Card");
foreach (var card in allCards)
{
if (card.CardID == cardID)
{
return card;
}
}
Debug.LogError($"Card with ID {cardID} not found!");
return null;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 447cd4a06d4a497cb301f68b51a4121a
timeCreated: 1760518833

View File

@@ -0,0 +1,23 @@
using UnityEngine;
using UnityEngine.UI;
namespace Gameplay
{
public class CardViewer : MonoBehaviour
{
public Card Card;
[SerializeField] private MeshRenderer meshRenderer;
[SerializeField] private Text cardNameText;
[SerializeField] private Text cardDescriptionText;
public void Setup(Card card)
{
Card = card;
meshRenderer.material.mainTexture = card.Texture;
cardNameText.text = card.CardName;
cardDescriptionText.text = card.CardDescription;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 84de392c49524b6d8da09ea51c4326c0
timeCreated: 1760361433