forked from Hazardu/ChampionsOfForest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDamageMath.cs
More file actions
25 lines (24 loc) · 740 Bytes
/
DamageMath.cs
File metadata and controls
25 lines (24 loc) · 740 Bytes
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace ChampionsOfForest
{
public static class DamageMath
{
/// <summary>
/// Takes a float input damage and returns a integer that is smaller than int.maxvalue and amount of times it has to be sent.
/// </summary>
public static void DamageClamp(float damage, out int outdamage, out int repetitions)
{
if(damage <= int.MaxValue)
{
outdamage = (int)damage;
repetitions = 1;
}
repetitions = Mathf.CeilToInt(damage / int.MaxValue);
outdamage = (int)(damage / repetitions);
}
}
}