aboutsummaryrefslogtreecommitdiffstats
path: root/code/ui/phase/PhaseTimer.razor
blob: 89766cb0712e4eccfe5b237391dc5ed8a9f74433 (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
@namespace MurderGame
@using System
@inherits Sandbox.UI.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()
    {
        var 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());
    }
}