chore(): 删除所有冗余的代码和资源
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
public class Card
|
||||
{
|
||||
private CardData _cardData;
|
||||
public Texture FrontTexture => _cardData.FrontCardTexture;
|
||||
public Texture BackTexture => _cardData.BackCardTexture;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1081ce761bc440e29a2f7b75915e5754
|
||||
timeCreated: 1760361406
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37e71088bd934b78aa07c7a76b7e5d07
|
||||
timeCreated: 1760422523
|
@@ -1,48 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bb8bfb17c6a4eaa88954871942ee72d
|
||||
timeCreated: 1760422530
|
@@ -1,12 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54f1f8ff48b84542962110e7a9851917
|
||||
timeCreated: 1760422573
|
@@ -1,12 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
// 卡牌书的显示相关脚本
|
||||
public class CardBookViewer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform LeftHandPoint;
|
||||
private CardBook CardBook;
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68803a8f56734f22a3025f8028fc027f
|
||||
timeCreated: 1760431288
|
@@ -1,23 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5f566603b3f4286965da48bb49c018a
|
||||
timeCreated: 1760422548
|
@@ -1,18 +0,0 @@
|
||||
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 FrontCardTexture;
|
||||
public Texture BackCardTexture;
|
||||
public EffectData[] Effects;
|
||||
}
|
||||
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c9f5640c7fc55141af2931d0caed1e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea39c6a061fd421988facd6fcb95c639
|
||||
timeCreated: 1760405374
|
@@ -1,16 +0,0 @@
|
||||
using UnityEngine;
|
||||
using Interface;
|
||||
namespace Gameplay
|
||||
{
|
||||
public class CardContext
|
||||
{
|
||||
public ICharacter Owner;
|
||||
public ICharacter Enemy;
|
||||
|
||||
public CardContext(ICharacter owner,ICharacter enemy)
|
||||
{
|
||||
Owner = owner;
|
||||
Enemy = enemy;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7279b5677f724ab4b93bd1028542d110
|
||||
timeCreated: 1760420712
|
@@ -1,26 +0,0 @@
|
||||
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,
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5790e0b2fbce41c99a775bbacca0e2bc
|
||||
timeCreated: 1760420527
|
@@ -1,24 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 032e368e3d5846d78caf5f3239de979f
|
||||
timeCreated: 1760420695
|
@@ -1,62 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Interface;
|
||||
using Core;
|
||||
using Gameplay.Player;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
public class CardViewer : MonoBehaviour, IInteractable
|
||||
{
|
||||
public Card Card;
|
||||
|
||||
[SerializeField] private MeshRenderer frontMeshRenderer;
|
||||
[SerializeField] private MeshRenderer backMeshRenderer;
|
||||
[SerializeField] private Text cardNameText;
|
||||
[SerializeField] private Text cardDescriptionText;
|
||||
|
||||
private PlayerController _playerController;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
ControllerLocator.Instance.TryGet<PlayerController>(out _playerController);
|
||||
}
|
||||
|
||||
public void SetCard(Card card)
|
||||
{
|
||||
Card = card;
|
||||
if (frontMeshRenderer != null && card.FrontTexture != null)
|
||||
{
|
||||
frontMeshRenderer.material.mainTexture = card.FrontTexture;
|
||||
}
|
||||
|
||||
if (backMeshRenderer != null && card.BackTexture != null)
|
||||
{
|
||||
backMeshRenderer.material.mainTexture = card.BackTexture;
|
||||
}
|
||||
|
||||
cardNameText.text = card.CardName;
|
||||
cardDescriptionText.text = card.CardDescription;
|
||||
}
|
||||
|
||||
public string GetInteractPrompt()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public void Interact(GameObject interactor)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnGazeEnter(GameObject editor)
|
||||
{
|
||||
if(_playerController != null) _playerController.playerCardsController.StopRotatingCards();
|
||||
}
|
||||
|
||||
public void OnGazeExit(GameObject editor)
|
||||
{
|
||||
if (_playerController != null) _playerController.playerCardsController.StartRotatingCards();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84de392c49524b6d8da09ea51c4326c0
|
||||
timeCreated: 1760361433
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5db247b9fcb44b3f85bdcc7cdb634481
|
||||
timeCreated: 1760575054
|
@@ -1,31 +0,0 @@
|
||||
using UnityEngine;
|
||||
namespace Gameplay
|
||||
{
|
||||
// 用来加载卡牌数据的静态类
|
||||
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;
|
||||
}
|
||||
|
||||
public static Card GetCardByID(int cardID)
|
||||
{
|
||||
CardData cardData = GetCardDataByID(cardID);
|
||||
if (cardData != null)
|
||||
{
|
||||
return new Card(cardData);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 447cd4a06d4a497cb301f68b51a4121a
|
||||
timeCreated: 1760518833
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 649c2c30ae8a4f64ae00e35a3bf67479
|
||||
timeCreated: 1760496426
|
@@ -1,176 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Core;
|
||||
using Gameplay.Enemy;
|
||||
using Gameplay.Player;
|
||||
using Interface;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
/// <summary>
|
||||
/// 战斗流程管理器(回合制、循环抽牌)
|
||||
/// 使用方法:在场景中挂载一个空物体并配置 player 与 enemy 的 Combatant 引用。
|
||||
/// 该管理器通过事件回调让 UI 或其它系统接入“双方牌都打空时”的选择(继续/逃跑)。
|
||||
/// </summary>
|
||||
public class CombatFlowManager : MonoSingleton<CombatFlowManager>
|
||||
{
|
||||
[Header("Participants")]
|
||||
public PlayerController player;
|
||||
public EnemyController enemy;
|
||||
|
||||
[Header("Flow Settings")]
|
||||
[Tooltip("玩家是否先手(true=玩家先出一张)")]
|
||||
public bool playerStarts = true;
|
||||
[Tooltip("每出一张牌后的间隔(秒)")]
|
||||
public float turnDelay = 0.8f;
|
||||
|
||||
// Events
|
||||
public event Action OnCombatStarted;
|
||||
public event Action<ICharacter, Card> OnCardPlayed;
|
||||
public event Action<ICharacter> OnCombatEnded; // 参数为胜利方(null 表示平局或逃跑)
|
||||
public event Action OnBothEmpty; // 当双方都没有卡可以出时触发,UI 需要通过 ContinueAfterBothEmpty 或 EscapeFromCombat 响应
|
||||
|
||||
// internal state
|
||||
private Coroutine runningRoutine;
|
||||
private bool waitingForDecision = false;
|
||||
private bool decisionContinue = false;
|
||||
private bool decisionEscape = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启动战斗流程(也可以在 Inspector 中提前绑定 player/enemy,然后只调用 StartCombat())
|
||||
/// </summary>
|
||||
public void StartCombat(PlayerController playerController = null, EnemyController enemyController = null)
|
||||
{
|
||||
if (playerController != null) player = playerController;
|
||||
if (enemyController != null) enemy = enemyController;
|
||||
|
||||
if (player == null || enemy == null)
|
||||
{
|
||||
Debug.LogError("CombatFlowManager: player 或 enemy 未设置。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 初始化双方状态
|
||||
player.StartCombat();
|
||||
enemy.StartCombat();
|
||||
player.InitializeDeckCycle();
|
||||
enemy.InitializeDeckCycle();
|
||||
|
||||
|
||||
runningRoutine = StartCoroutine(CombatRoutine());
|
||||
OnCombatStarted?.Invoke();
|
||||
}
|
||||
|
||||
public void StopCombat()
|
||||
{
|
||||
if (runningRoutine != null) StopCoroutine(runningRoutine);
|
||||
runningRoutine = null;
|
||||
}
|
||||
|
||||
private IEnumerator CombatRoutine()
|
||||
{
|
||||
ICharacter current = playerStarts ? player : enemy;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// 结束检查
|
||||
if (player.IsDead || enemy.IsDead)
|
||||
{
|
||||
ICharacter winner = player.IsDead ? enemy : player;
|
||||
OnCombatEnded?.Invoke(winner);
|
||||
runningRoutine = null;
|
||||
yield break;
|
||||
}
|
||||
|
||||
bool playerHas = player.HasCardsLeft();
|
||||
bool enemyHas = enemy.HasCardsLeft();
|
||||
|
||||
if (!playerHas && !enemyHas)
|
||||
{
|
||||
// 双方都打空,等待玩家选择(由 UI 调用 ContinueAfterBothEmpty 或 EscapeFromCombat)
|
||||
waitingForDecision = true;
|
||||
decisionContinue = false;
|
||||
decisionEscape = false;
|
||||
OnBothEmpty?.Invoke();
|
||||
|
||||
// 等待选择
|
||||
while (waitingForDecision)
|
||||
yield return null;
|
||||
|
||||
if (decisionEscape)
|
||||
{
|
||||
// 玩家选择逃跑 -> 结束战斗,胜者设为 null(或按需要设成敌人/玩家)
|
||||
OnCombatEnded?.Invoke(null);
|
||||
runningRoutine = null;
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (decisionContinue)
|
||||
{
|
||||
// 重新从卡册读取(重置抽牌队列),保持生命与其它状态不变
|
||||
player.InitializeDeckCycle();
|
||||
enemy.InitializeDeckCycle();
|
||||
// 继续循环(当前先手不变)
|
||||
yield return null;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 当前回合:如果当前方没有牌则跳过(空过)
|
||||
if (current.HasCardsLeft())
|
||||
{
|
||||
var card = current.GetNextCard();
|
||||
ICharacter target;
|
||||
if (current is PlayerController)
|
||||
{
|
||||
target = enemy;
|
||||
}
|
||||
else
|
||||
{
|
||||
target = player;
|
||||
}
|
||||
|
||||
|
||||
// 触发卡牌效果(当前仅支持直接伤害)
|
||||
if (card != null)
|
||||
{
|
||||
card.PlayCard(new CardContext(current, target));
|
||||
OnCardPlayed?.Invoke(current, card);
|
||||
}
|
||||
|
||||
// 检查死亡(将在下一循环顶部处理)
|
||||
yield return new WaitForSeconds(turnDelay);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 跳过一轮,不延迟太久
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
|
||||
// 切换行动方
|
||||
current = (current == player) ? enemy : player;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当双方都打空时,UI 调用此方法选择继续下一轮(重新从卡册读取卡牌)
|
||||
/// </summary>
|
||||
public void ContinueAfterBothEmpty()
|
||||
{
|
||||
if (!waitingForDecision) return;
|
||||
decisionContinue = true;
|
||||
waitingForDecision = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当双方都打空时,UI 调用此方法选择逃跑
|
||||
/// </summary>
|
||||
public void EscapeFromCombat()
|
||||
{
|
||||
if (!waitingForDecision) return;
|
||||
decisionEscape = true;
|
||||
waitingForDecision = false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e8e663fe8d349bea29b9887d29db187
|
||||
timeCreated: 1760496426
|
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Gameplay;
|
||||
using Interface;
|
||||
using Gameplay.Enemy;
|
||||
using Gameplay.Player;
|
||||
|
||||
namespace Gameplay.Combat
|
||||
{
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class CombatTrigger : MonoBehaviour
|
||||
{
|
||||
//[Tooltip("战斗管理器引用(场景中单例/对象)")]
|
||||
private CombatFlowManager combatManager;
|
||||
|
||||
[Tooltip("触发时指定的玩家 Combatant(可为空,manager 使用已配置的)")]
|
||||
public PlayerController player;
|
||||
|
||||
[Tooltip("触发时指定的敌人 Combatant(可为空,manager 使用已配置的)")]
|
||||
public EnemyController enemy;
|
||||
|
||||
[Tooltip("被触发后是否自动禁用触发器,避免重复触发")]
|
||||
public bool disableAfterTrigger = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
combatManager = CombatFlowManager.Instance;
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
// Collider 需要 isTrigger
|
||||
var col = GetComponent<Collider>();
|
||||
col.isTrigger = true;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
// 简单检测:玩家层或带有 "Player" 标签的物体
|
||||
if (combatManager == null) return;
|
||||
|
||||
if (other.CompareTag("Player") || other.gameObject.layer == LayerMask.NameToLayer("Player"))
|
||||
{
|
||||
combatManager.StartCombat(player, enemy);
|
||||
if (disableAfterTrigger) gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d9265c2645847c2b5197ed2ba181c98
|
||||
timeCreated: 1760496463
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b712b2fa4f743408e56868a21312535
|
||||
timeCreated: 1760495486
|
@@ -1,77 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Interface;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gameplay.Enemy
|
||||
{
|
||||
public class EnemyController : MonoBehaviour, ICharacter
|
||||
{
|
||||
[SerializeField] private string enemyName;
|
||||
[SerializeField] private int maxHealth = 100;
|
||||
public int MaxHealth => maxHealth;
|
||||
public int CurrentHealth { get; set; }
|
||||
|
||||
[SerializeField] private CardBookData cardBookData;
|
||||
private CardBook myCardBook;
|
||||
private List<Card> cards;
|
||||
private int currentCardIndex = 0;
|
||||
|
||||
public bool IsFlight { get; private set; }
|
||||
public bool IsDead { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
CurrentHealth = MaxHealth;
|
||||
myCardBook = new CardBook(cardBookData);
|
||||
cards = new List<Card>();
|
||||
}
|
||||
|
||||
public void TakeDamage(int damage)
|
||||
{
|
||||
CurrentHealth -= damage;
|
||||
}
|
||||
|
||||
public void Heal(int heal)
|
||||
{
|
||||
CurrentHealth += heal;
|
||||
if (CurrentHealth > MaxHealth)
|
||||
{
|
||||
CurrentHealth = MaxHealth;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartCombat()
|
||||
{
|
||||
Debug.Log($"{name} Enemy Start Combat");
|
||||
IsFlight = false;
|
||||
}
|
||||
|
||||
public void EndFlight()
|
||||
{
|
||||
Debug.Log($"{name} Enemy End Flight");
|
||||
IsFlight = true;
|
||||
}
|
||||
|
||||
public bool HasCardsLeft()
|
||||
{
|
||||
return currentCardIndex < cards.Count;
|
||||
}
|
||||
|
||||
public Card GetNextCard()
|
||||
{
|
||||
if (!HasCardsLeft())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return cards[currentCardIndex++];
|
||||
}
|
||||
|
||||
public void InitializeDeckCycle()
|
||||
{
|
||||
cards = myCardBook.GetCards().ToList();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5a587a681ae48d6b3a5dcd5a723fd5a
|
||||
timeCreated: 1760512105
|
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Gameplay;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色接口,可受伤害、治疗和添加Buff、发生战斗
|
||||
/// 拥有卡牌书
|
||||
/// </summary>
|
||||
public interface ICharacter
|
||||
{
|
||||
// public int MaxHealth { get; }
|
||||
// public int CurrentHealth { get; }
|
||||
// public CardBook CardBook { get; }
|
||||
// public List<Card> Cards { get; }
|
||||
public bool IsFlight { get; }
|
||||
public bool IsDead { get; }
|
||||
public void TakeDamage(int damage);
|
||||
public void Heal(int heal);
|
||||
public void StartCombat();
|
||||
public void EndFlight();
|
||||
public bool HasCardsLeft();
|
||||
public Card GetNextCard();
|
||||
public void InitializeDeckCycle();
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0f41a6a18dd4801a9d6ba995cf09376
|
||||
timeCreated: 1760420819
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e48e8b97eda4ce78cdf0df14fd37ec4
|
||||
timeCreated: 1760362979
|
@@ -1,10 +0,0 @@
|
||||
using UnityEngine;
|
||||
using Interface;
|
||||
namespace Map
|
||||
{
|
||||
public class FlightTrigger : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public ICharacter Player;
|
||||
[SerializeField] public ICharacter Enemy;
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e697dc78ed84a3ab2e921a57c17be95
|
||||
timeCreated: 1760495479
|
@@ -1,20 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
namespace Map
|
||||
{
|
||||
public class MapFlag : MonoBehaviour
|
||||
{
|
||||
public string FlagName;
|
||||
public Vector3 Position;
|
||||
public MapFlag ParentFlag;
|
||||
public MapFlag LeftFlag;
|
||||
public MapFlag RightFlag;
|
||||
|
||||
public event Action<MapFlag> OnPlayerEnter;
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
OnPlayerEnter?.Invoke(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c3ea88c92cc4d0bb6098983903be7fb
|
||||
timeCreated: 1760444130
|
@@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Map
|
||||
{
|
||||
public class MapFlagManager : MonoSingleton<MapFlagManager>
|
||||
{
|
||||
public MapFlag StartFlag;
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f13be1e244e84e3b93b0b3a4c054cb46
|
||||
timeCreated: 1760424376
|
@@ -1,114 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using UnityEngine;
|
||||
using Quaternion = UnityEngine.Quaternion;
|
||||
using Vector3 = UnityEngine.Vector3;
|
||||
|
||||
namespace Gameplay.Player
|
||||
{
|
||||
public class PlayerCardsController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float radius = 2f; // 卡牌围绕玩家旋转的半径
|
||||
[SerializeField] private float rotationSpeed = 50f; // 卡牌旋转
|
||||
[SerializeField] private float highOffset = 1f; // 卡牌高度偏移
|
||||
public bool IsRotating = true; // 是否旋转卡牌
|
||||
[SerializeField] private GameObject cardPrefab; // 卡牌预制体
|
||||
|
||||
public List<CardViewer> Cards;
|
||||
private Transform playerTransform;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Cards != null)
|
||||
{
|
||||
//RotateCards();
|
||||
}
|
||||
}
|
||||
|
||||
// 生成卡牌实体
|
||||
// 生成的卡牌实体围绕着玩家旋转
|
||||
public void GenerateCards(List<Card> cards)
|
||||
{
|
||||
playerTransform = this.transform;
|
||||
Cards = new List<CardViewer>();
|
||||
for (int i = 0; i < cards.Count; i++)
|
||||
{
|
||||
float angle = i * (360f / cards.Count);
|
||||
float rad = angle * Mathf.Deg2Rad;
|
||||
Vector3 cardPosition = new Vector3(
|
||||
playerTransform.position.x + radius * Mathf.Cos(rad),
|
||||
playerTransform.position.y + highOffset,
|
||||
playerTransform.position.z + radius * Mathf.Sin(rad)
|
||||
);
|
||||
|
||||
GameObject cardObject = Instantiate(cardPrefab, cardPosition, Quaternion.identity);
|
||||
|
||||
Vector3 playerPosition = new Vector3(
|
||||
playerTransform.position.x,
|
||||
playerTransform.position.y + highOffset,
|
||||
playerTransform.position.z
|
||||
);
|
||||
Cards[i].transform.LookAt(playerPosition);
|
||||
|
||||
CardViewer cardViewer = cardObject.GetComponent<CardViewer>();
|
||||
cardViewer.SetCard(cards[i]);
|
||||
Cards.Add(cardViewer);
|
||||
}
|
||||
}
|
||||
|
||||
// 旋转已经生成的卡牌实体
|
||||
public void RotateCards()
|
||||
{
|
||||
if (!IsRotating) return;
|
||||
for (int i = 0; i < Cards.Count; i++)
|
||||
{
|
||||
float angle = i * (360f / Cards.Count) + Time.time * rotationSpeed;
|
||||
float rad = angle * Mathf.Deg2Rad;
|
||||
Vector3 cardPosition = new Vector3(
|
||||
playerTransform.position.x + radius * Mathf.Cos(rad),
|
||||
playerTransform.position.y + highOffset,
|
||||
playerTransform.position.z + radius * Mathf.Sin(rad)
|
||||
);
|
||||
Cards[i].transform.position = cardPosition;
|
||||
|
||||
Vector3 playerPosition = new Vector3(
|
||||
playerTransform.position.x,
|
||||
playerTransform.position.y + highOffset,
|
||||
playerTransform.position.z
|
||||
);
|
||||
|
||||
Cards[i].transform.LookAt(playerPosition);
|
||||
// 卡牌绕着y轴旋转180度,从而让卡牌正面朝向玩家
|
||||
Cards[i].transform.Rotate(0, 180, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void StopRotatingCards()
|
||||
{
|
||||
IsRotating = false;
|
||||
}
|
||||
|
||||
public void StartRotatingCards()
|
||||
{
|
||||
IsRotating = true;
|
||||
}
|
||||
|
||||
// 删除卡牌实体
|
||||
public void DeleteCards(CardViewer card)
|
||||
{
|
||||
Cards.Remove(card);
|
||||
Destroy(card.gameObject);
|
||||
}
|
||||
|
||||
public void ClearCards()
|
||||
{
|
||||
foreach (var card in Cards)
|
||||
{
|
||||
Destroy(card.gameObject);
|
||||
}
|
||||
|
||||
Cards.Clear();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb0c79a8230343c29d902ad22e044d2b
|
||||
timeCreated: 1760574485
|
@@ -8,14 +8,11 @@ using Core;
|
||||
|
||||
namespace Gameplay.Player
|
||||
{
|
||||
public class PlayerController : MonoBehaviour, ICharacter
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
public int MaxHealth { get; set; } = 100;
|
||||
public int CurrentHealth { get; private set; }
|
||||
|
||||
[SerializeField] private CardBookData cardBookData;
|
||||
public CardBook MyCardBook { get; private set; }
|
||||
public List<Card> Cards { get; private set; }
|
||||
private int currentCardIndex = 0;
|
||||
|
||||
public bool IsFlight { get; private set; }
|
||||
@@ -23,25 +20,22 @@ namespace Gameplay.Player
|
||||
|
||||
private PlayerMoveController playerMoveController;
|
||||
private PlayerCameraController playerCameraController;
|
||||
public PlayerCardsController playerCardsController;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
playerMoveController = GetComponent<PlayerMoveController>();
|
||||
playerCameraController = GetComponent<PlayerCameraController>();
|
||||
playerCardsController = GetComponent<PlayerCardsController>();
|
||||
|
||||
CurrentHealth = MaxHealth;
|
||||
MyCardBook = new CardBook(cardBookData);
|
||||
Cards = new List<Card>();
|
||||
|
||||
|
||||
ControllerLocator.Instance.Register(this);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Cards.Add(CardLoader.GetCardByID(1));
|
||||
Cards.Add(CardLoader.GetCardByID(2));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -58,43 +52,5 @@ namespace Gameplay.Player
|
||||
CurrentHealth = MaxHealth;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartCombat()
|
||||
{
|
||||
Debug.Log("Player StartCombat");
|
||||
IsFlight = true;
|
||||
playerMoveController.SetSpeed(0.5f);
|
||||
|
||||
playerCardsController.GenerateCards(Cards);
|
||||
}
|
||||
|
||||
public void EndFlight()
|
||||
{
|
||||
Debug.Log("Player EndFlight");
|
||||
IsFlight = false;
|
||||
playerMoveController.ResetSpeed();
|
||||
|
||||
playerCardsController.ClearCards();
|
||||
}
|
||||
|
||||
public bool HasCardsLeft()
|
||||
{
|
||||
return currentCardIndex < Cards.Count;
|
||||
}
|
||||
|
||||
public Card GetNextCard()
|
||||
{
|
||||
if (!HasCardsLeft())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return Cards[currentCardIndex++];
|
||||
}
|
||||
|
||||
public void InitializeDeckCycle()
|
||||
{
|
||||
Cards = MyCardBook.GetCards().ToList();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Core;
|
||||
using Script.Gameplay.Input;
|
||||
using Map;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gameplay.Player
|
||||
|
Reference in New Issue
Block a user