blob: c3c666096ca956b0fbd83a43c28f65ac979274bd (
plain)
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
|
@using Sandbox;
@using Sandbox.UI;
@namespace MurderGame
@inherits Panel
<style>
Health {
width: 400px;
height: 100%;
background-color: rgba(0, 0, 0, 0.90);
}
.colour-bar {
height: 100%;
}
.transition-bar {
height: 100%;
transition: width 1s ease-out 0.5s;
position: absolute;
top: 0;
left: 0;
}
</style>
<div class="transition-bar" style="background-color: white; width: @(GetHealth())%;"></div>
<div class="colour-bar" style="background-color: @(Colour); width: @(GetHealth())%;"></div>
@code
{
public string Colour { get; set; }
public int GetHealth()
{
var ClientPawn = Game.LocalPawn;
if (ClientPawn is Player)
{
return ClientPawn.Health.CeilToInt();
}
return 0;
}
protected override int BuildHash()
{
return GetHealth().GetHashCode();
}
}
|