using System;
using ColdMint.scripts.debug;
using Godot;
namespace ColdMint.scripts.damage;
///
/// DamageTemplate
/// 伤害模板
///
public abstract class DamageTemplate
{
///
/// Damage must be assigned a certain value
/// 伤害必须指定确定的数值
///
public int Damage => _damage;
///
/// Critical Hit probability (unit: percent)
/// 暴击几率(单位:百分比)
///
public int CriticalStrikeProbability = 5;
private int _damage;
private bool _isCriticalStrike;
///
///
/// 攻击者
///
public Node2D Attacker { get; set; }
///
/// Whether the damage text moves to the left
/// 伤害文本是否向左移动
///
public bool MoveLeft { get; set; }
///
/// Create actual damage with maximum and minimum values
/// 通过最大值和最小值创建实际伤害
///
public void CreateDamage()
{
_damage = GD.RandRange(MinDamage, MaxDamage);
_isCriticalStrike = GD.RandRange(1, 100) <= CriticalStrikeProbability;
if (_isCriticalStrike)
{
_damage = (int)Math.Round(_damage * Config.CriticalHitMultiplier);
}
}
///
/// Maximum injury
/// 最大伤害
///
public int MaxDamage { get; set; }
///
/// Minimum damage value
/// 最小伤害值
///
public int MinDamage { get; set; }
///
/// Whether the damage is critical
/// 本次伤害是否为暴击
///
public bool IsCriticalStrike => _isCriticalStrike;
///
/// Types of damage
/// 伤害的类型
///
public int Type { get; set; }
///
/// An event performed before harming the enemy
/// 在伤害敌人之前执行的事件
///
public Action BeforeDamage;
///
/// After damaging the enemy
/// 在伤害敌人之后
///
public Action AfterDamage;
}