aboutsummaryrefslogtreecommitdiffstats
path: root/code/ui/phase/PhaseTimer.razor
blob: 73f44e27722f2c6f1914499374e9cc7898f0b329 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@using Sandbox;
@using System
@using Sandbox.UI;

@namespace MurderGame
@inherits Panel

<style>
phasetimer {
    position: absolute;
    top: 0;
    width: 100%;
    margin: 30px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.box {
    color: white;
    font-weight: 700;
    font-size: 25px;
    font-family: "Roboto";
	text-shadow: 1px 1px 0 0 rgba(0,0,0,0.75);
}
</style>

@if (HasTime())
{
<smallbox class="box">
    @GetTime()
</smallbox>
} else
{
<smallbox class="box">
    @GetPhase()
</smallbox>
}

@code
{
    public bool HasTime()
    {
        return MurderGame.Instance.CurrentPhase.TimeLeft >= 0;
    }
    public string GetTime()
    {
        TimeSpan timeSpan = TimeSpan.FromSeconds(MurderGame.Instance.CurrentPhase.TimeLeft);
        return timeSpan.ToString(@"mm\:ss");
    }
    public string GetPhase()
    {
        return MurderGame.Instance.CurrentPhase.Title;
    }

    protected override int BuildHash()
    {
        return HashCode.Combine(MurderGame.Instance.CurrentPhase.TimeLeft.GetHashCode(), MurderGame.Instance.CurrentPhase.Title.GetHashCode());
    }
}