77 lines
1.8 KiB
C#
77 lines
1.8 KiB
C#
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();
|
|
}
|
|
}
|
|
} |