-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathElement.cs
More file actions
69 lines (62 loc) · 1.75 KB
/
Element.cs
File metadata and controls
69 lines (62 loc) · 1.75 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
// Copyright (c) 2021-2025 Koji Hasegawa.
// This software is released under the MIT License.
using System;
namespace APIExamples
{
/// <summary>
/// 元素的な属性
/// </summary>
public enum Element
{
None,
Fire,
Water,
Wood,
}
public static class ElementExtensions
{
/// <summary>
/// 属性名を返す
/// </summary>
/// <param name="self"></param>
/// <returns></returns>
public static string GetName(this Element self)
{
switch (self)
{
case Element.None:
return "無";
case Element.Fire:
return "火";
case Element.Water:
return "水";
case Element.Wood:
return "木";
default:
throw new ArgumentException($"Unknown Element: {self.ToString()}");
}
}
/// <summary>
/// 属性攻撃を受けたときの被ダメージ倍率を返す
/// </summary>
/// <param name="self"></param>
/// <param name="attack">攻撃側の属性</param>
/// <returns>被ダメージ倍率</returns>
public static float GetDamageMultiplier(this Element self, Element attack)
{
if (self == Element.Wood && attack == Element.Fire)
{
return 2.0f;
}
if (self == Element.Fire && attack == Element.Water)
{
return 2.0f;
}
if (self == Element.Water && attack == Element.Wood)
{
return 2.0f;
}
return 1.0f;
}
}
}