aboutsummaryrefslogtreecommitdiffstats
path: root/code/ui/weapon
diff options
context:
space:
mode:
Diffstat (limited to 'code/ui/weapon')
-rw-r--r--code/ui/weapon/Crosshair.razor23
-rw-r--r--code/ui/weapon/Reload.razor82
2 files changed, 105 insertions, 0 deletions
diff --git a/code/ui/weapon/Crosshair.razor b/code/ui/weapon/Crosshair.razor
new file mode 100644
index 0000000..2dc5db1
--- /dev/null
+++ b/code/ui/weapon/Crosshair.razor
@@ -0,0 +1,23 @@
+@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+crosshair {
+ position: absolute;
+ left: 50%;
+ top: 50%;
+ transform: translate(-50%, -50%);
+}
+.dot {
+ border-radius: 3px;
+ width: 6px;
+ height: 6px;
+ background-color: white;
+}
+</style>
+
+<div class="dot"></div>
+
diff --git a/code/ui/weapon/Reload.razor b/code/ui/weapon/Reload.razor
new file mode 100644
index 0000000..d325ade
--- /dev/null
+++ b/code/ui/weapon/Reload.razor
@@ -0,0 +1,82 @@
+@using Sandbox;
+@using Sandbox.UI;
+@using System;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+@@keyframes blink {
+ 0% {
+ background-color: rgba(0, 0, 0, 0.20);
+ }
+ 49% {
+ background-color: rgba(0, 0, 0, 0.20);
+ }
+ 50% {
+ background-color: rgba(255, 0, 0, 0.20);
+ }
+ 100% {
+ background-color: rgba(255, 0, 0, 0.20);
+ }
+}
+reload {
+ width: 100vw;
+ height: 100vh;
+}
+.box {
+ position: absolute;
+ left: 47%;
+ top: 60%;
+ width: 6%;
+ backdrop-filter-blur: 8px;
+ background-color: rgba(0, 0, 0, 0.20);
+ padding: 5px;
+ color: white;
+ font-weight: 700;
+ font-size: 30px;
+ font-family: "Roboto";
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+.blink {
+ animation-name: blink;
+ animation-duration: 0.33s;
+}
+</style>
+
+@if (ReloadNeeded) {
+<!--<div class="box @(@Blink ? "blink" : "")">-->
+<div class="box blink">
+ <div>Reload</div>
+</div>
+}
+
+@code
+{
+ public bool ReloadNeeded { get; set; }
+ public bool Blink { get; set; }
+
+ protected override int BuildHash()
+ {
+ var localPawn = Game.LocalPawn;
+ if (localPawn is Player player)
+ {
+ var inventory = player.Inventory;
+ if (inventory != null && inventory.GetCurrentWeapon() != null)
+ {
+ var weapon = inventory.GetCurrentWeapon();
+ var ammo = weapon.Ammo;
+ ReloadNeeded = ammo == 0 && !weapon.Reloading;
+ Blink = !weapon.Reloading;
+ return HashCode.Combine(ReloadNeeded.GetHashCode(), Blink.GetHashCode());
+ }
+ }
+ if (ReloadNeeded)
+ {
+ ReloadNeeded = false;
+ }
+ return ReloadNeeded.GetHashCode();
+ }
+}