-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDamage.cs
More file actions
89 lines (82 loc) · 2.64 KB
/
Copy pathDamage.cs
File metadata and controls
89 lines (82 loc) · 2.64 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
89
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace PFW.Damage
{
/// <summary>
/// The base class Damage, on which all damage classes are constructed
/// This class represents a damage dealt in an update, for one-time instant damage (e.g. KEDamage or HeatDamage), the class will be instantiated once
/// For continuous damage (e.g. FireDamage), the class will be instantiated once and the CalculateDamage will be called at every update (controlled by another script inherenting MonoBehaviour)
/// </summary>
internal abstract class Damage
{
/// <summary>
/// Damage type always take a Target struct representing the initial state of the target unit
/// </summary>
/// <param name="damageType"></param>
/// <param name="currentTarget"></param>
protected Damage(DamageTypes damageType, Target currentTarget)
{
this.DamageType = damageType;
this.CurrentTarget = currentTarget;
}
/// <Summary>
/// A struct containing the data of the target of the damage
/// </Summary>
public Target CurrentTarget { get; private set; }
/// <Summary>
/// The type of the damage, indicated by a enum
/// </Summary>
public DamageTypes DamageType { get; private set; }
/// <Summary>
/// Use this method to calculate damage.
/// Override this method in the child classes
/// </Summary>
public virtual Target CalculateDamage()
{
// Override this function to specify damage algorithm
return this.CurrentTarget; // No damage dealt thus return the original state of the target
}
public struct Era
{
public float Value;
public float KEFractionMultiplier;
public float HeatFractionMultiplier;
}
public struct Target
{
public float Armor;
public Era EraData;
public float Health;
}
}
public enum DamageTypes
{
/// <summary>
/// Kinetic energy
/// </summary>
KE,
/// <summary>
/// High-explosive anti-tank
/// </summary>
HEAT,
/// <summary>
/// High-explosive none shaped-charge
/// </summary>
HE,
/// <summary>
/// Napalm burn damage
/// </summary>
FIRE,
/// <summary>
/// Laser
/// </summary>
LASER,
/// <summary>
/// Light arms damage
/// </summary>
LIGHTARMS
}
}