feat(): 大量更新
This commit is contained in:
26
Assets/Script/Gameplay/Card/Card.cs
Normal file
26
Assets/Script/Gameplay/Card/Card.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Script/Gameplay/Card/Card.cs.meta
Normal file
3
Assets/Script/Gameplay/Card/Card.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1081ce761bc440e29a2f7b75915e5754
|
||||
timeCreated: 1760361406
|
3
Assets/Script/Gameplay/Card/CardBook.meta
Normal file
3
Assets/Script/Gameplay/Card/CardBook.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37e71088bd934b78aa07c7a76b7e5d07
|
||||
timeCreated: 1760422523
|
48
Assets/Script/Gameplay/Card/CardBook/CardBook.cs
Normal file
48
Assets/Script/Gameplay/Card/CardBook/CardBook.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Script/Gameplay/Card/CardBook/CardBook.cs.meta
Normal file
3
Assets/Script/Gameplay/Card/CardBook/CardBook.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bb8bfb17c6a4eaa88954871942ee72d
|
||||
timeCreated: 1760422530
|
12
Assets/Script/Gameplay/Card/CardBook/CardBookData.cs
Normal file
12
Assets/Script/Gameplay/Card/CardBook/CardBookData.cs
Normal 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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54f1f8ff48b84542962110e7a9851917
|
||||
timeCreated: 1760422573
|
12
Assets/Script/Gameplay/Card/CardBook/CardBookViewer.cs
Normal file
12
Assets/Script/Gameplay/Card/CardBook/CardBookViewer.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
// 卡牌书的显示相关脚本
|
||||
public class CardBookViewer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform LeftHandPoint;
|
||||
private CardBook CardBook;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68803a8f56734f22a3025f8028fc027f
|
||||
timeCreated: 1760431288
|
23
Assets/Script/Gameplay/Card/CardBook/CardSlot.cs
Normal file
23
Assets/Script/Gameplay/Card/CardBook/CardSlot.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Script/Gameplay/Card/CardBook/CardSlot.cs.meta
Normal file
3
Assets/Script/Gameplay/Card/CardBook/CardSlot.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5f566603b3f4286965da48bb49c018a
|
||||
timeCreated: 1760422548
|
17
Assets/Script/Gameplay/Card/CardData.cs
Normal file
17
Assets/Script/Gameplay/Card/CardData.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
11
Assets/Script/Gameplay/Card/CardData.cs.meta
Normal file
11
Assets/Script/Gameplay/Card/CardData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c9f5640c7fc55141af2931d0caed1e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3
Assets/Script/Gameplay/Card/CardEffect.meta
Normal file
3
Assets/Script/Gameplay/Card/CardEffect.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea39c6a061fd421988facd6fcb95c639
|
||||
timeCreated: 1760405374
|
16
Assets/Script/Gameplay/Card/CardEffect/CardContext.cs
Normal file
16
Assets/Script/Gameplay/Card/CardEffect/CardContext.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7279b5677f724ab4b93bd1028542d110
|
||||
timeCreated: 1760420712
|
26
Assets/Script/Gameplay/Card/CardEffect/EffectData.cs
Normal file
26
Assets/Script/Gameplay/Card/CardEffect/EffectData.cs
Normal 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,
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5790e0b2fbce41c99a775bbacca0e2bc
|
||||
timeCreated: 1760420527
|
24
Assets/Script/Gameplay/Card/CardEffect/EffectHandler.cs
Normal file
24
Assets/Script/Gameplay/Card/CardEffect/EffectHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 032e368e3d5846d78caf5f3239de979f
|
||||
timeCreated: 1760420695
|
21
Assets/Script/Gameplay/Card/CardLoader.cs
Normal file
21
Assets/Script/Gameplay/Card/CardLoader.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Script/Gameplay/Card/CardLoader.cs.meta
Normal file
3
Assets/Script/Gameplay/Card/CardLoader.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 447cd4a06d4a497cb301f68b51a4121a
|
||||
timeCreated: 1760518833
|
23
Assets/Script/Gameplay/Card/CardViewer.cs
Normal file
23
Assets/Script/Gameplay/Card/CardViewer.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
Assets/Script/Gameplay/Card/CardViewer.cs.meta
Normal file
3
Assets/Script/Gameplay/Card/CardViewer.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84de392c49524b6d8da09ea51c4326c0
|
||||
timeCreated: 1760361433
|
Reference in New Issue
Block a user