-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttack.cs
More file actions
88 lines (73 loc) · 2.39 KB
/
Attack.cs
File metadata and controls
88 lines (73 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class Attack : ScriptableObject
{
public new string name;
public string description = "";
public int cost;
[SerializeField]
private DebuffEffects debuffEffects;
[SerializeField]
private BuffEffects buffEffects;
public abstract void Activate(BattleCharacter attacker, BattleCharacter defender);
protected void ApplyDebuffs(BattleCharacter character, int bonusDamage = 0)
{
if (debuffEffects is DebuffEffects.None) return;
var statusEffectManager = character.GetComponent<StatusEffectManager>();
if (debuffEffects.HasFlag(DebuffEffects.Burn))
{
statusEffectManager.ApplyBurn(3, bonusDamage);
}
if (debuffEffects.HasFlag(DebuffEffects.Bleed))
{
statusEffectManager.ApplyBleed(3, bonusDamage);
}
if (debuffEffects.HasFlag(DebuffEffects.Slow))
{
statusEffectManager.ApplySlow(3);
}
}
protected void ApplyBuffs(BattleCharacter character, int duration, int buffValue)
{
if (buffEffects is BuffEffects.None) return;
if (buffValue <= 0) return;
if (duration <= 0) return;
var statusEffectManager = character.GetComponent<StatusEffectManager>();
if (buffEffects.HasFlag(BuffEffects.PhysicalResist))
{
statusEffectManager.ApplyPhysicalResistBuff(duration, buffValue);
}
if (buffEffects.HasFlag(BuffEffects.MagicResist))
{
statusEffectManager.ApplyMagicResistBuff(duration, buffValue);
}
}
protected int CalculateCritDamage(int critDamage, int baseDamage)
{
int bonusDamage = baseDamage * critDamage / 100;
return bonusDamage;
}
protected bool IsCriticalHit(BattleCharacter character)
{
var rand = new System.Random();
int critChance = character.stats.criticalChance.GetValue();
int roll = rand.Next(1, 101);
return critChance >= roll;
}
[System.Flags]
public enum DebuffEffects
{
None = 0,
Burn = 1,
Bleed = 2,
Slow = 4
}
[System.Flags]
public enum BuffEffects
{
None = 0,
PhysicalResist = 1,
MagicResist = 2
}
}