-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathHealth.cs
183 lines (169 loc) · 8.28 KB
/
Health.cs
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
using System;
using System.Collections.Generic;
using System.Linq;
using LeagueSharp;
using LeagueSharp.Common;
using SharpDX;
using SharpDX.Direct3D9;
namespace SAwareness
{
internal class Health
{
private readonly Font _font;
private bool _drawActive = true;
public Health()
{
try
{
_font = new Font(Drawing.Direct3DDevice, new System.Drawing.Font("Times New Roman", 8));
}
catch (Exception)
{
Menu.Health.ForceDisable = true;
Console.WriteLine("Health: Cannot create Font");
return;
}
Drawing.OnPreReset += Drawing_OnPreReset;
Drawing.OnPostReset += Drawing_OnPostReset;
Drawing.OnEndScene += Drawing_OnEndScene;
AppDomain.CurrentDomain.DomainUnload += delegate { Drawing_OnPreReset(new EventArgs()); };
AppDomain.CurrentDomain.ProcessExit += delegate { Drawing_OnPreReset(new EventArgs()); };
}
private void Drawing_OnPostReset(EventArgs args)
{
if (Drawing.Direct3DDevice == null || Drawing.Direct3DDevice.IsDisposed)
return;
_font.OnResetDevice();
_drawActive = true;
}
private void Drawing_OnPreReset(EventArgs args)
{
_font.OnLostDevice();
_drawActive = false;
}
private void Drawing_OnEndScene(EventArgs args)
{
DrawTurrentHealth();
DrawInhibitorHealth();
}
~Health()
{
Drawing.OnPreReset -= Drawing_OnPreReset;
Drawing.OnPostReset -= Drawing_OnPostReset;
Drawing.OnEndScene -= Drawing_OnEndScene;
}
public bool IsActive()
{
return Menu.Health.GetActive();
}
private void DrawInhibitorHealth()
{
if (!IsActive() || !_drawActive)
return;
if (!Menu.InhibitorHealth.GetActive())
return;
var baseB = new List<Obj_Barracks>();
List<Obj_BarracksDampener> baseBd = ObjectManager.Get<Obj_BarracksDampener>().ToList();
foreach (Obj_Barracks inhibitor in baseB)
{
if (!inhibitor.IsDead && inhibitor.IsValid && inhibitor.Health > 0.1f &&
((inhibitor.Health/inhibitor.MaxHealth)*100) != 100)
{
Vector2 pos = Drawing.WorldToMinimap(inhibitor.Position);
int health = 0;
var mode =
Menu.Health.GetMenuItem("SAwarenessHealthMode")
.GetValue<StringList>();
switch (mode.SelectedIndex)
{
case 0:
health = (int) ((inhibitor.Health/inhibitor.MaxHealth)*100);
break;
case 1:
health = (int) inhibitor.Health;
break;
}
if (((inhibitor.Health/inhibitor.MaxHealth)*100) > 75)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.LightGreen);
else if (((inhibitor.Health/inhibitor.MaxHealth)*100) <= 75)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.LightYellow);
else if (((inhibitor.Health/inhibitor.MaxHealth)*100) <= 50)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.Orange);
else if (((inhibitor.Health/inhibitor.MaxHealth)*100) <= 25)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.IndianRed);
//Drawing.DrawText(pos[0], pos[1], System.Drawing.Color.Green, ((int)turret.Health).ToString());
//Drawing.DrawText(turret.HealthBarPosition.X, turret.HealthBarPosition.Y + 20, System.Drawing.Color.Green, ((int)turret.Health).ToString());
}
}
foreach (Obj_BarracksDampener inhibitor in baseBd)
{
if (!inhibitor.IsDead && inhibitor.IsValid && inhibitor.Health > 0.1f &&
((inhibitor.Health/inhibitor.MaxHealth)*100) != 100)
{
Vector2 pos = Drawing.WorldToMinimap(inhibitor.Position);
int health = 0;
var mode =
Menu.Health.GetMenuItem("SAwarenessHealthMode")
.GetValue<StringList>();
switch (mode.SelectedIndex)
{
case 0:
health = (int) ((inhibitor.Health/inhibitor.MaxHealth)*100);
break;
case 1:
health = (int) inhibitor.Health;
break;
}
if (((inhibitor.Health/inhibitor.MaxHealth)*100) > 75)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.LightGreen);
else if (((inhibitor.Health/inhibitor.MaxHealth)*100) <= 75)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.LightYellow);
else if (((inhibitor.Health/inhibitor.MaxHealth)*100) <= 50)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.Orange);
else if (((inhibitor.Health/inhibitor.MaxHealth)*100) <= 25)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.IndianRed);
//Drawing.DrawText(pos[0], pos[1], System.Drawing.Color.Green, ((int)turret.Health).ToString());
//Drawing.DrawText(turret.HealthBarPosition.X, turret.HealthBarPosition.Y + 20, System.Drawing.Color.Green, ((int)turret.Health).ToString());
}
}
}
private void DrawTurrentHealth() //TODO: Draw HP above BarPos
{
if (!IsActive() || !_drawActive)
return;
if (!Menu.TowerHealth.GetActive())
return;
foreach (Obj_AI_Turret turret in ObjectManager.Get<Obj_AI_Turret>())
{
if (!turret.IsDead && turret.IsValid && turret.Health != 9999 &&
((turret.Health/turret.MaxHealth)*100) != 100)
{
Vector2 pos = Drawing.WorldToMinimap(turret.Position);
int health = 0;
var mode =
Menu.Health.GetMenuItem("SAwarenessHealthMode")
.GetValue<StringList>();
switch (mode.SelectedIndex)
{
case 0:
health = (int) ((turret.Health/turret.MaxHealth)*100);
break;
case 1:
health = (int) turret.Health;
break;
}
if (((turret.Health/turret.MaxHealth)*100) > 75)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.LightGreen);
else if (((turret.Health/turret.MaxHealth)*100) <= 75)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.LightYellow);
else if (((turret.Health/turret.MaxHealth)*100) <= 50)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.Orange);
else if (((turret.Health/turret.MaxHealth)*100) <= 25)
DirectXDrawer.DrawText(_font, health.ToString(), (int) pos[0], (int) pos[1], Color.IndianRed);
//Drawing.DrawText(pos[0], pos[1], System.Drawing.Color.Green, ((int)turret.Health).ToString());
//Drawing.DrawText(turret.HealthBarPosition.X, turret.HealthBarPosition.Y + 20, System.Drawing.Color.Green, ((int)turret.Health).ToString());
}
}
}
}
}