146 lines
5.0 KiB
C#
146 lines
5.0 KiB
C#
using System.Collections.Generic;
|
|
using Continentis.MainGame.Card;
|
|
using SoulliesFramework.General;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis.MainGame.Character
|
|
{
|
|
public partial class CharacterBase
|
|
{
|
|
public virtual void InitializeCards()
|
|
{
|
|
string initialPile = this is PlayerHero ? "Draw" : "Pool";
|
|
|
|
foreach (KeyValuePair<CardData, int> cardData in data.initialDeck)
|
|
{
|
|
for (int i = 0; i < cardData.Value; i++)
|
|
{
|
|
cardData.Key.GenerateCardInstance(this, initialPile);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class CharacterBase
|
|
{
|
|
public void Attack(CharacterBase target, int startDamage)
|
|
{
|
|
eventSubmodule.onStartAttack.Invoke(new List<CharacterBase> { target });
|
|
|
|
bool dodged = target.CheckDodge(startDamage);
|
|
int hurt = 0;
|
|
int blocked = 0;
|
|
int shielded = 0;
|
|
|
|
if (!dodged)
|
|
{
|
|
int remainingDamageAfterBlock = target.CheckBlock(startDamage);
|
|
if (remainingDamageAfterBlock > 0)
|
|
{
|
|
blocked = startDamage - remainingDamageAfterBlock;
|
|
int remainingDamageAfterShield = target.CheckShield(remainingDamageAfterBlock);
|
|
if (remainingDamageAfterShield > 0)
|
|
{
|
|
shielded = remainingDamageAfterBlock - remainingDamageAfterShield;
|
|
hurt = remainingDamageAfterShield;
|
|
target.HealthRemoval(remainingDamageAfterShield);
|
|
}
|
|
}
|
|
}
|
|
|
|
target.characterView.hudContainer.enablingHUDs["MainAttributesBar"].UpdateHud();
|
|
AttackResult attackResult = new AttackResult(this, startDamage, dodged, blocked, shielded, hurt);
|
|
eventSubmodule.onFinishAttack.Invoke(new List<CharacterBase> { target }, new List<AttackResult> { attackResult });
|
|
}
|
|
|
|
public bool CheckDodge(int damage)
|
|
{
|
|
int dodge = attributeSubmodule.GetRoundCurrentGeneralAttribute("Dodge");
|
|
|
|
if (dodge > 0)
|
|
{
|
|
bool success = damage <= dodge;
|
|
|
|
if (!success)
|
|
{
|
|
attributeSubmodule.generalAttributeGroup.current["Dodge"] = 0;
|
|
}
|
|
MainGameManager.Instance.basePrefabs.GenerateInfoText("Dodged!", characterView.transform.position);
|
|
return success;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public int CheckBlock(int damage)
|
|
{
|
|
int block = attributeSubmodule.GetRoundCurrentGeneralAttribute("Block");
|
|
|
|
if (block > 0)
|
|
{
|
|
bool success = damage <= block;
|
|
int remainingDamage = 0;
|
|
int blockedDamage = block;
|
|
|
|
if (!success)
|
|
{
|
|
attributeSubmodule.generalAttributeGroup.current["Block"] = 0;
|
|
remainingDamage = damage - block;
|
|
}
|
|
else
|
|
{
|
|
attributeSubmodule.generalAttributeGroup.current["Block"] = block - damage;
|
|
blockedDamage = damage;
|
|
}
|
|
|
|
MainGameManager.Instance.basePrefabs.GenerateBlockedText(blockedDamage, characterView.transform.position);
|
|
return remainingDamage;
|
|
}
|
|
|
|
return damage;
|
|
}
|
|
|
|
public int CheckShield(int damage)
|
|
{
|
|
int shield = attributeSubmodule.GetRoundCurrentGeneralAttribute("Shield");
|
|
|
|
if (shield > 0)
|
|
{
|
|
bool success = damage <= shield;
|
|
int remainingDamage = 0;
|
|
int blockedDamage = shield;
|
|
|
|
if (!success)
|
|
{
|
|
attributeSubmodule.generalAttributeGroup.current["Shield"] = 0;
|
|
remainingDamage = damage - shield;
|
|
}
|
|
else
|
|
{
|
|
attributeSubmodule.generalAttributeGroup.current["Shield"] = shield - damage;
|
|
blockedDamage = damage;
|
|
}
|
|
|
|
MainGameManager.Instance.basePrefabs.GenerateBlockedText(blockedDamage, characterView.transform.position);
|
|
return remainingDamage;
|
|
}
|
|
|
|
return damage;
|
|
}
|
|
|
|
public void HealthRemoval(int damage)
|
|
{
|
|
attributeSubmodule.generalAttributeGroup.current["Health"] -= damage;
|
|
MainGameManager.Instance.basePrefabs.GenerateHurtText(damage, characterView.transform.position);
|
|
}
|
|
|
|
public void Heal(int heal)
|
|
{
|
|
if (heal <= 0) return;
|
|
|
|
//this.ChangeCombatAttribute("Health", heal, "MaximumHealth");
|
|
//MGU.GenerateHealNumber(this.transform.position, heal);
|
|
//connectedHudContainer.enablingHUDs["MainAttributeBar"].UpdateHud();
|
|
}
|
|
}
|
|
} |