92 lines
2.3 KiB
C#
92 lines
2.3 KiB
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using Gameplay;
|
||
|
using Share;
|
||
|
using UnityEngine;
|
||
|
using Core;
|
||
|
|
||
|
namespace Gameplay.Player
|
||
|
{
|
||
|
public class PlayerController : MonoBehaviour, ICharacter
|
||
|
{
|
||
|
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; }
|
||
|
public bool IsDead { get; private set; }
|
||
|
|
||
|
private PlayerMoveController playerMoveController;
|
||
|
private PlayerCameraController playerCameraController;
|
||
|
|
||
|
private void Awake()
|
||
|
{
|
||
|
playerMoveController = GetComponent<PlayerMoveController>();
|
||
|
playerCameraController = GetComponent<PlayerCameraController>();
|
||
|
|
||
|
CurrentHealth = MaxHealth;
|
||
|
MyCardBook = new CardBook(cardBookData);
|
||
|
Cards = new List<Card>();
|
||
|
|
||
|
UIViewerControllerLocator.Instance.Register(this);
|
||
|
}
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public void TakeDamage(int damage)
|
||
|
{
|
||
|
CurrentHealth -= damage;
|
||
|
}
|
||
|
|
||
|
public void Heal(int heal)
|
||
|
{
|
||
|
CurrentHealth += heal;
|
||
|
if (CurrentHealth > MaxHealth)
|
||
|
{
|
||
|
CurrentHealth = MaxHealth;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void StartCombat()
|
||
|
{
|
||
|
Debug.Log("Player StartCombat");
|
||
|
IsFlight = true;
|
||
|
playerMoveController.SetSpeed(0.5f);
|
||
|
}
|
||
|
|
||
|
public void EndFlight()
|
||
|
{
|
||
|
Debug.Log("Player EndFlight");
|
||
|
IsFlight = false;
|
||
|
playerMoveController.ResetSpeed();
|
||
|
}
|
||
|
|
||
|
public bool HasCardsLeft()
|
||
|
{
|
||
|
return currentCardIndex < Cards.Count;
|
||
|
}
|
||
|
|
||
|
public Card GetNextCard()
|
||
|
{
|
||
|
if (!HasCardsLeft())
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
return Cards[currentCardIndex++];
|
||
|
}
|
||
|
|
||
|
public void InitializeDeckCycle()
|
||
|
{
|
||
|
Cards = MyCardBook.GetCards().ToList();
|
||
|
}
|
||
|
}
|
||
|
}
|