chore(): 删除所有冗余的代码和资源
This commit is contained in:
@@ -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