init
This commit is contained in:
37
Assets/TcgEngine/Scripts/Effects/EffectDamage.cs
Normal file
37
Assets/TcgEngine/Scripts/Effects/EffectDamage.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TcgEngine.Gameplay;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Effect that damages a card or a player (lose hp)
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "effect", menuName = "TcgEngine/Effect/Damage", order = 10)]
|
||||
public class EffectDamage : EffectData
|
||||
{
|
||||
public TraitData bonus_damage;
|
||||
|
||||
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
int damage = GetDamage(logic.GameData, caster, ability.value);
|
||||
logic.DamagePlayer(caster, target, damage);
|
||||
}
|
||||
|
||||
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
int damage = GetDamage(logic.GameData, caster, ability.value);
|
||||
logic.DamageCard(caster, target, damage, true);
|
||||
}
|
||||
|
||||
private int GetDamage(Game data, Card caster, int value)
|
||||
{
|
||||
Player player = data.GetPlayer(caster.player_id);
|
||||
int damage = value + caster.GetTraitValue(bonus_damage) + player.GetTraitValue(bonus_damage);
|
||||
return damage;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user