aboutsummaryrefslogtreecommitdiffstats
path: root/code/ui/phase/PhaseTimer.razor
blob: 92939762d0ba7a562441315c771a0aa5877a670a (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
60
61
@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 {
    background-color: rgba(0, 0, 0, 0.20);
    backdrop-filter-blur: 8px;
    padding: 5px;
    color: white;
    font-weight: 700;
    font-size: 30px;
    font-family: "Roboto";
}
</style>

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

@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());
    }
}