2026-01-29 19:37:40 +01:00
|
|
|
using System;
|
2026-02-14 14:35:29 +01:00
|
|
|
using System.Collections.Generic;
|
2026-03-08 16:55:49 +01:00
|
|
|
using System.Linq;
|
2026-02-16 21:48:59 +01:00
|
|
|
using FNAF_Clone.Map;
|
2026-02-14 14:35:29 +01:00
|
|
|
using GlobalClassLib;
|
2026-01-26 09:39:17 +01:00
|
|
|
using Microsoft.Xna.Framework;
|
2026-03-09 20:05:21 +01:00
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2026-03-16 20:43:53 +01:00
|
|
|
using Microsoft.Xna.Framework.Input;
|
2026-01-26 09:39:17 +01:00
|
|
|
using MonoGameLibrary;
|
|
|
|
|
using MonoGameLibrary.Graphics;
|
2026-03-09 20:05:21 +01:00
|
|
|
using MonoGameLibrary.Input;
|
2026-01-26 09:39:17 +01:00
|
|
|
|
|
|
|
|
namespace FNAF_Clone.GUI;
|
|
|
|
|
|
|
|
|
|
public class UIManager {
|
|
|
|
|
|
|
|
|
|
public static class ScreenTypes {
|
|
|
|
|
public const string OFFICE = "office";
|
|
|
|
|
public const string CAMERAS = "monitor";
|
2026-03-09 20:05:21 +01:00
|
|
|
public const string OVERLAY = "overlay";
|
|
|
|
|
public const string WIN = "win";
|
|
|
|
|
public const string LOSE = "lose";
|
2026-03-11 22:35:30 +01:00
|
|
|
public const string MENU = "menu";
|
|
|
|
|
public const string LOADING = "loading";
|
2026-01-26 09:39:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Screen officeScreen = new(ScreenTypes.OFFICE);
|
|
|
|
|
private static Screen monitorScreen = new(ScreenTypes.CAMERAS);
|
2026-03-09 20:05:21 +01:00
|
|
|
private static Screen overlayScreen = new(ScreenTypes.OVERLAY);
|
|
|
|
|
private static Screen winScreen = new(ScreenTypes.WIN);
|
|
|
|
|
private static Screen loseScreen = new(ScreenTypes.LOSE);
|
2026-03-11 22:35:30 +01:00
|
|
|
private static Screen menuScreen = new(ScreenTypes.MENU);
|
|
|
|
|
private static Screen loadingScreen = new(ScreenTypes.LOADING);
|
2026-01-26 09:39:17 +01:00
|
|
|
|
|
|
|
|
private static TextureAtlas testAtlas;
|
2026-03-09 20:05:21 +01:00
|
|
|
public static TextureAtlas OfficeAtlas{ get; private set; }
|
|
|
|
|
public static TextureAtlas MonitorAtlas{ get; private set; }
|
|
|
|
|
public static TextureAtlas EnemyAtlas{ get; private set; }
|
2026-03-16 20:43:53 +01:00
|
|
|
public static TextureAtlas RoomAtlas{ get; private set; }
|
2026-03-09 20:05:21 +01:00
|
|
|
public static SpriteFont PixelMonoFont{ get; private set; }
|
2026-03-08 16:55:49 +01:00
|
|
|
|
2026-01-26 09:39:17 +01:00
|
|
|
public static int GlobalPixelMultiplier{ get; private set; }
|
|
|
|
|
|
2026-03-09 20:05:21 +01:00
|
|
|
// private Dictionary<(int, int), UIElement> doorElements = new();
|
2026-03-08 16:55:49 +01:00
|
|
|
private static Dictionary<int, UIElement> enemyElements = new();
|
2026-03-09 20:05:21 +01:00
|
|
|
private static TimerUIElement timerElement;
|
2026-03-16 20:43:53 +01:00
|
|
|
private static UIElement cameraView;
|
|
|
|
|
private static Dictionary<int, UIElement> lightIndicators = new();
|
2026-03-09 20:05:21 +01:00
|
|
|
|
|
|
|
|
private static InputListenerHook monitorSwitchHook;
|
2026-03-11 22:35:30 +01:00
|
|
|
|
2026-03-19 20:10:45 +01:00
|
|
|
private static bool fullBright = false; // Debug
|
|
|
|
|
|
2026-03-11 22:35:30 +01:00
|
|
|
public static void LoadAssets() {
|
|
|
|
|
testAtlas = TextureAtlas.FromFile(Core.content, "images/testBlocks-definition.xml");
|
2026-03-09 20:05:21 +01:00
|
|
|
OfficeAtlas = TextureAtlas.FromFile(Core.content, "images/office-definition.xml");
|
|
|
|
|
MonitorAtlas = TextureAtlas.FromFile(Core.content, "images/monitor-definition.xml");
|
|
|
|
|
EnemyAtlas = TextureAtlas.FromFile(Core.content, "images/enemies-definition.xml");
|
2026-03-16 20:43:53 +01:00
|
|
|
RoomAtlas = TextureAtlas.FromFile(Core.content, "images/rooms-definition.xml");
|
2026-03-09 20:05:21 +01:00
|
|
|
PixelMonoFont = Core.content.Load<SpriteFont>("ponderosa");
|
2026-03-11 22:35:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void InitUI() {
|
|
|
|
|
GlobalPixelMultiplier = Core.graphicsDevice.Viewport.Height / 360;
|
2026-01-26 09:39:17 +01:00
|
|
|
|
2026-03-11 22:35:30 +01:00
|
|
|
Screen.AddScreens([officeScreen, monitorScreen, overlayScreen, winScreen, loseScreen, menuScreen, loadingScreen]);
|
|
|
|
|
// Screen.SetScreen(ScreenTypes.OFFICE);
|
|
|
|
|
// Screen.SetOverlayScreen(ScreenTypes.OVERLAY);
|
2026-01-26 09:39:17 +01:00
|
|
|
|
2026-03-16 20:43:53 +01:00
|
|
|
officeScreen.AddElement("office_left", new UIElement([OfficeAtlas["left-open"], OfficeAtlas["left-closed"]], Point.Zero));
|
|
|
|
|
officeScreen.AddElement("office_centre", new UIElement([OfficeAtlas["centre-open"], OfficeAtlas["centre-closed"]], new Point(200, 0)));
|
|
|
|
|
officeScreen.AddElement("office_right", new UIElement([OfficeAtlas["right-open"], OfficeAtlas["right-closed"]], new Point(440, 0)));
|
2026-01-29 19:37:40 +01:00
|
|
|
|
2026-01-26 09:39:17 +01:00
|
|
|
// officeScreen.AddElement("test",
|
|
|
|
|
// new UIElement(testAtlas[0], Point.Zero)
|
|
|
|
|
// {Pressable = true, OnMousePress = () => Console.WriteLine("Pressed!")}
|
|
|
|
|
// );
|
|
|
|
|
|
2026-03-16 20:43:53 +01:00
|
|
|
monitorScreen.AddElement("screen", new UIElement(MonitorAtlas["screen"], Point.Zero));
|
|
|
|
|
monitorScreen.AddElement("view-frame", new UIElement(MonitorAtlas["view-frame"], new Point(62, 55)));
|
|
|
|
|
monitorScreen.AddElement("map-frame", new UIElement(MonitorAtlas["map-frame"], new Point(334, 135)));
|
|
|
|
|
monitorScreen.AddElement("map", new UIElement(MonitorAtlas["map"], new Point(334, 135)));
|
2026-03-11 22:35:30 +01:00
|
|
|
|
2026-03-16 20:43:53 +01:00
|
|
|
List<TextureRegion> rooms = new();
|
|
|
|
|
for (int i = 0; i < ClientMapManager.MAP_SIDE_LENGTH * ClientMapManager.MAP_SIDE_LENGTH; i++){
|
|
|
|
|
rooms.Add(RoomAtlas["room" + i]);
|
|
|
|
|
}
|
|
|
|
|
cameraView = new UIElement(rooms.ToArray(), new(64, 64));
|
|
|
|
|
monitorScreen.AddElement("camera-view", cameraView);
|
|
|
|
|
|
2026-03-21 21:23:33 +01:00
|
|
|
monitorScreen.AddElement("p1-office-door-left", new UIElement([MonitorAtlas["door-office-p1-left-open"], MonitorAtlas["door-office-p1-left-closed"]], new Point(400, 272)));
|
|
|
|
|
monitorScreen.AddElement("p1-office-door-centre", new UIElement([MonitorAtlas["door-office-p1-centre-open"], MonitorAtlas["door-office-p1-centre-closed"]], new Point(400, 272)));
|
|
|
|
|
monitorScreen.AddElement("p1-office-door-right", new UIElement([MonitorAtlas["door-office-p1-right-open"], MonitorAtlas["door-office-p1-right-closed"]], new Point(400, 272)));
|
|
|
|
|
monitorScreen.AddElement("p2-office-door-right", new UIElement([MonitorAtlas["door-office-p2-right-open"], MonitorAtlas["door-office-p2-right-closed"]], new Point(400, 144)));
|
|
|
|
|
monitorScreen.AddElement("p2-office-door-centre", new UIElement([MonitorAtlas["door-office-p2-centre-open"], MonitorAtlas["door-office-p2-centre-closed"]], new Point(400, 144)));
|
|
|
|
|
monitorScreen.AddElement("p2-office-door-left", new UIElement([MonitorAtlas["door-office-p2-left-open"], MonitorAtlas["door-office-p2-left-closed"]], new Point(400, 144)));
|
|
|
|
|
|
|
|
|
|
|
2026-03-16 20:43:53 +01:00
|
|
|
// main menu
|
2026-03-11 22:35:30 +01:00
|
|
|
timerElement = new(new(0, 0), PixelMonoFont);
|
|
|
|
|
overlayScreen.AddElement("timer", timerElement);
|
2026-03-12 22:33:35 +01:00
|
|
|
officeScreen.AddElement("power-p1-office", new PowerIndicator(new(timerElement.Bounds.Item1.X, timerElement.Bounds.Item2.Y + 5), PixelMonoFont, Client.Player, "POWER: "));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextUIElement powerLabel = (TextUIElement)
|
|
|
|
|
monitorScreen.AddElement("power-label", new TextUIElement(new(510, 150), PixelMonoFont){Text = "POWER:"});
|
|
|
|
|
TextUIElement powerP1 = (TextUIElement)
|
|
|
|
|
monitorScreen.AddElement("power-p2", new PowerIndicator(new(powerLabel.Bounds.Item1.X + 10, powerLabel.Bounds.Item2.Y + 10), PixelMonoFont, Client.Opponent, ""){Color = new Color(220, 10, 10, 255)});
|
|
|
|
|
monitorScreen.AddElement("power-p1", new PowerIndicator( new (powerP1.Bounds.Item1.X, powerP1.Bounds.Item2.Y + 5), PixelMonoFont, Client.Player, ""){Color = new Color(15, 190, 247, 255)});
|
2026-03-11 22:35:30 +01:00
|
|
|
|
|
|
|
|
winScreen.AddElement("win-text", new TextUIElement(new(320, 180), PixelMonoFont, TextUIElement.Alignment.CENTER){Text = "YOU WIN", Color = Color.Green});
|
|
|
|
|
loseScreen.AddElement("lose-text", new TextUIElement(new(320, 180), PixelMonoFont, TextUIElement.Alignment.CENTER){Text = "YOU LOSE", Color = Color.Red});
|
|
|
|
|
|
|
|
|
|
MenuInputField usernameField = (MenuInputField)menuScreen.AddElement("username-field", new MenuInputField(PixelMonoFont, new(20, 20), "USERNAME: "));
|
|
|
|
|
MenuInputField field = (MenuInputField)menuScreen.AddElement("server-ip-field", new MenuInputField(PixelMonoFont, new(usernameField.Bounds.Item1.X, usernameField.Bounds.Item2.Y + 20), "SERVER IP: ", "127.0.0.1"));
|
|
|
|
|
UIElement connectButton = menuScreen.AddElement("server-ip-submit", new TextUIElement(new Point(field.Bounds.Item1.X, field.Bounds.Item2.Y), PixelMonoFont)
|
|
|
|
|
{
|
|
|
|
|
Text = "CONNECT",
|
|
|
|
|
Pressable = true,
|
|
|
|
|
OnMousePress = () => {
|
|
|
|
|
// string[] input = serverIpTextBox.Text.Split(":");
|
|
|
|
|
// if(input.Length != 2 || !int.TryParse(input[0], out var port)) return;
|
|
|
|
|
// Client.Connect(input[0], port);
|
|
|
|
|
Client.Player.username = usernameField.Text;
|
|
|
|
|
Client.Connect(field.Text, 9012);
|
|
|
|
|
Screen.SetScreen(ScreenTypes.LOADING);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
menuScreen.AddElement("host-button",
|
2026-03-21 21:23:33 +01:00
|
|
|
new TextUIElement(new(connectButton.Bounds.Item1.X, connectButton.Bounds.Item2.Y + 30), PixelMonoFont) {Text = "HOST", Pressable = true,
|
|
|
|
|
OnMousePress = () => {
|
|
|
|
|
Client.StartServer();
|
|
|
|
|
Client.Player.username = usernameField.Text;
|
|
|
|
|
Client.Connect("127.0.0.1", 9012);
|
|
|
|
|
Screen.SetScreen(ScreenTypes.LOADING);
|
|
|
|
|
|
|
|
|
|
}});
|
2026-03-11 22:35:30 +01:00
|
|
|
|
|
|
|
|
loadingScreen.AddElement("loading-text", new LoadingUIElement(new(320, 180), PixelMonoFont, field.Text));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void DisplayMainMenu() {
|
2026-03-21 21:23:33 +01:00
|
|
|
ResetUI();
|
2026-03-11 22:35:30 +01:00
|
|
|
Screen.SetScreen(ScreenTypes.MENU);
|
|
|
|
|
CommandManager.AllowGameControls(false);
|
2026-03-17 20:14:29 +01:00
|
|
|
// if(Client.Player.username != null)
|
|
|
|
|
// ((MenuInputField)menuScreen["username-field"]).Text = Client.Player.username;
|
2026-03-11 22:35:30 +01:00
|
|
|
}
|
2026-03-21 21:23:33 +01:00
|
|
|
|
2026-03-11 22:35:30 +01:00
|
|
|
public static void SpawnMapElements(TileConnectorProjection[] doors) {
|
2026-03-21 21:23:33 +01:00
|
|
|
|
|
|
|
|
|
2026-02-14 14:35:29 +01:00
|
|
|
for (int i = 0; i < 5; i++){ // NOTE: this loop does y in reverse, y labels are inverted to match server
|
2026-01-29 19:37:40 +01:00
|
|
|
for (int j = 0; j < 5; j++){
|
2026-03-16 20:43:53 +01:00
|
|
|
int id = ClientMapManager.CoordsToId(i, 4 - j);
|
|
|
|
|
if (Client.Player.state.officeTileId == id || Client.Opponent.state.officeTileId == id) continue; // TODO: remove the other check for office
|
2026-02-14 14:35:29 +01:00
|
|
|
Point point1 = new Point(336 + (32 * i), 144 + (32 * j));
|
|
|
|
|
Point point2 = new Point(367 + (32 * i), 175 + (32 * j));
|
2026-03-21 21:23:33 +01:00
|
|
|
monitorScreen.AddElement(
|
|
|
|
|
$"room{id}", new UIElement(point1, point2)
|
|
|
|
|
{Pressable = true, OnMousePress = (() => CommandManager.SendChangeCamera(id))},
|
|
|
|
|
true);
|
|
|
|
|
lightIndicators.Add(id,
|
|
|
|
|
monitorScreen.AddElement(
|
|
|
|
|
$"light{id}", new UIElement(MonitorAtlas["map-light-indicator"], point1)
|
|
|
|
|
{Visible = false},
|
|
|
|
|
true));
|
2026-03-16 20:43:53 +01:00
|
|
|
|
2026-02-16 21:48:59 +01:00
|
|
|
//
|
|
|
|
|
// if (doorPositions.ContainsKey((i, j))){
|
|
|
|
|
// monitorScreen.AddElement("door"+doorPositions[(i, j)], new UIElement([monitorAtlas[5], monitorAtlas[6]], point1));
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-26 16:24:55 +01:00
|
|
|
|
2026-03-21 21:23:33 +01:00
|
|
|
monitorScreen.AddElement("eye-player", new UIElement(MonitorAtlas["eye-small-player"], monitorScreen["room"+Client.Player.state.camera].Bounds.Item1), true);
|
|
|
|
|
monitorScreen.AddElement("eye-opponent", new UIElement([MonitorAtlas["eye-small-opponent-closed"], MonitorAtlas["eye-small-opponent-open"]], monitorScreen["room"+Client.Opponent.state.camera].Bounds.Item1), true);
|
2026-02-26 16:24:55 +01:00
|
|
|
|
2026-02-16 21:48:59 +01:00
|
|
|
foreach (var door in doors){
|
|
|
|
|
if(door.Type != ConnectorType.DOOR_REMOTE) continue;
|
|
|
|
|
|
|
|
|
|
(int x, int y) dpos = (Math.Abs(door.Tiles.tile1.GridPosition.x - door.Tiles.tile2.GridPosition.x), Math.Abs(door.Tiles.tile1.GridPosition.y - door.Tiles.tile2.GridPosition.y));
|
|
|
|
|
|
|
|
|
|
if (dpos.y == 1){
|
|
|
|
|
int targetId = door.Tiles.tile1.GridPosition.y > door.Tiles.tile2.GridPosition.y ? door.Tiles.tile1.Id : door.Tiles.tile2.Id;
|
|
|
|
|
UIElement tile = monitorScreen["room"+targetId];
|
2026-02-21 18:42:44 +01:00
|
|
|
|
2026-03-21 21:23:33 +01:00
|
|
|
monitorScreen.AddElement("door"+Math.Max(door.Tiles.tile1.Id, door.Tiles.tile2.Id)+"-"+Math.Min(door.Tiles.tile1.Id, door.Tiles.tile2.Id), new UIElement([MonitorAtlas["door-remote-open"], MonitorAtlas["door-remote-closed"]], tile.Bounds.Item1), true);
|
2026-01-29 19:37:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-21 21:23:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void DisplayGameUI() {
|
|
|
|
|
Screen.SetScreen(ScreenTypes.OFFICE);
|
|
|
|
|
Screen.SetOverlayScreen(ScreenTypes.OVERLAY);
|
2026-02-21 18:42:44 +01:00
|
|
|
|
2026-03-21 21:23:33 +01:00
|
|
|
CommandManager.AllowGameControls(true);
|
|
|
|
|
UpdateCameras([Client.Player.state.camera]); // in case there is an enemy on the default camera
|
|
|
|
|
cameraView.SetTexture(Client.Player.state.camera);
|
|
|
|
|
}
|
|
|
|
|
public static void StartTimer() {
|
|
|
|
|
timerElement.Start();
|
2026-01-26 09:39:17 +01:00
|
|
|
}
|
2026-03-08 16:55:49 +01:00
|
|
|
|
2026-03-09 20:05:21 +01:00
|
|
|
public static void AddEnemySprite(int id, UIElement sprite, UIElement jumpscareSprite = null) {
|
2026-03-21 21:23:33 +01:00
|
|
|
monitorScreen.AddElement($"enemy{id}", sprite, true);
|
2026-03-09 20:05:21 +01:00
|
|
|
if (jumpscareSprite != null){
|
2026-03-21 21:23:33 +01:00
|
|
|
officeScreen.AddElement($"enemy{id}-jumpscare", jumpscareSprite, true);
|
2026-03-09 20:05:21 +01:00
|
|
|
jumpscareSprite.Active = false;
|
|
|
|
|
jumpscareSprite.Visible = false;
|
|
|
|
|
}
|
2026-03-08 16:55:49 +01:00
|
|
|
enemyElements.Add(id, sprite);
|
|
|
|
|
sprite.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 17:05:15 +01:00
|
|
|
|
|
|
|
|
public static void ChangeDoorState(Direction dir, bool state) {
|
2026-02-21 18:42:44 +01:00
|
|
|
int stateInt = state ? 1 : 0;
|
|
|
|
|
|
2026-02-14 14:35:29 +01:00
|
|
|
switch ((int)dir){
|
2026-03-19 20:10:45 +01:00
|
|
|
case 0:
|
2026-02-21 18:42:44 +01:00
|
|
|
officeScreen["office_left"].SetTexture(stateInt);
|
|
|
|
|
monitorScreen["p1-office-door-left"].SetTexture(stateInt);
|
2026-01-26 09:39:17 +01:00
|
|
|
break;
|
|
|
|
|
case 1:
|
2026-02-21 18:42:44 +01:00
|
|
|
officeScreen["office_centre"].SetTexture(stateInt);
|
|
|
|
|
monitorScreen["p1-office-door-centre"].SetTexture(stateInt);
|
2026-01-26 09:39:17 +01:00
|
|
|
break;
|
|
|
|
|
case 2:
|
2026-02-21 18:42:44 +01:00
|
|
|
officeScreen["office_right"].SetTexture(stateInt);
|
|
|
|
|
monitorScreen["p1-office-door-right"].SetTexture(stateInt);
|
2026-01-26 09:39:17 +01:00
|
|
|
break;
|
2026-03-19 20:10:45 +01:00
|
|
|
}
|
2026-01-26 09:39:17 +01:00
|
|
|
}
|
2026-02-25 17:05:15 +01:00
|
|
|
|
|
|
|
|
public static void ChangeDoorStateOpponent(Direction dir, bool state) { // TODO: overload to avoid excessive casting
|
|
|
|
|
int stateInt = state ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
switch ((int)dir){
|
|
|
|
|
case 0:
|
|
|
|
|
monitorScreen["p2-office-door-left"].SetTexture(stateInt);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
monitorScreen["p2-office-door-centre"].SetTexture(stateInt);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
monitorScreen["p2-office-door-right"].SetTexture(stateInt);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-21 18:42:44 +01:00
|
|
|
|
|
|
|
|
public static void ChangeRemoteDoorState((int, int) id, bool state) {
|
|
|
|
|
monitorScreen["door"+Math.Max(id.Item1, id.Item2)+"-"+Math.Min(id.Item1, id.Item2)].SetTexture(state ? 1 : 0);
|
|
|
|
|
}
|
2026-02-26 16:24:55 +01:00
|
|
|
|
2026-01-26 09:39:17 +01:00
|
|
|
public static void ChangeMonitorState(bool state) {
|
|
|
|
|
Screen.SetScreen(state ? ScreenTypes.CAMERAS : ScreenTypes.OFFICE);
|
2026-03-19 20:10:45 +01:00
|
|
|
UpdateCameras([Client.Player.state.camera]);
|
2026-01-26 09:39:17 +01:00
|
|
|
}
|
2026-02-26 16:24:55 +01:00
|
|
|
|
|
|
|
|
public static void ChangeMonitorStateOpponent(bool state) {
|
|
|
|
|
monitorScreen["eye-opponent"].SetTexture(state ? 1 : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ChangeCamera(int id) {
|
|
|
|
|
monitorScreen["eye-player"].SetPosition(monitorScreen["room"+id].Bounds.Item1);
|
2026-03-16 20:43:53 +01:00
|
|
|
cameraView.SetTexture(id);
|
2026-03-08 16:55:49 +01:00
|
|
|
UpdateCameras([id]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void UpdateCameras(int[] camIds) {
|
2026-03-16 20:43:53 +01:00
|
|
|
foreach (var id in camIds){
|
|
|
|
|
MapTileProjection tile = ClientMapManager.Get(id);
|
2026-03-17 20:14:29 +01:00
|
|
|
if(tile.Owner == null || tile.Id == Client.Player.state.officeTileId || tile.Id == Client.Opponent.state.officeTileId) continue;
|
2026-03-16 20:43:53 +01:00
|
|
|
lightIndicators[id].Visible = tile.Lit;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-08 16:55:49 +01:00
|
|
|
if (camIds.Contains(Client.Player.state.camera)){
|
2026-03-19 20:10:45 +01:00
|
|
|
bool lit = ClientMapManager.Get(Client.Player.state.camera).Lit || fullBright;
|
2026-03-16 20:43:53 +01:00
|
|
|
cameraView.Visible = lit;
|
2026-03-08 16:55:49 +01:00
|
|
|
enemyElements.Values.Where(e => e.Visible).ToList().ForEach(e => e.Visible = false);
|
2026-03-16 20:43:53 +01:00
|
|
|
ClientEnemy[] enemies = ClientEnemyManager.GetByLocation(ClientMapManager.Get(Client.Player.state.camera));
|
2026-03-08 16:55:49 +01:00
|
|
|
foreach (var enemy in enemies){
|
|
|
|
|
enemyElements.TryGetValue(enemy.Id, out var element);
|
|
|
|
|
if (element == null) continue;
|
2026-03-16 20:43:53 +01:00
|
|
|
EnemyUIElement enemyElement = (EnemyUIElement)element;
|
|
|
|
|
enemyElement.Visible = true;
|
|
|
|
|
enemyElement.SetTexture(lit);
|
2026-03-08 16:55:49 +01:00
|
|
|
}
|
2026-03-19 20:10:45 +01:00
|
|
|
|
|
|
|
|
if (!lit && Client.Player.state.monitorUp && enemies.Any(e => e.TypeId == (int)EnemyType.NEKO)){
|
|
|
|
|
SoundManager.StartNekoPurr();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
SoundManager.StopNekoPurr();
|
|
|
|
|
}
|
2026-03-08 16:55:49 +01:00
|
|
|
}
|
2026-02-26 16:24:55 +01:00
|
|
|
}
|
2026-03-08 16:55:49 +01:00
|
|
|
|
2026-02-26 16:24:55 +01:00
|
|
|
public static void ChangeCameraOpponent(int id) {
|
|
|
|
|
monitorScreen["eye-opponent"].SetPosition(monitorScreen["room"+id].Bounds.Item1);
|
2026-03-11 22:35:30 +01:00
|
|
|
|
2026-02-26 16:24:55 +01:00
|
|
|
}
|
2026-03-09 20:05:21 +01:00
|
|
|
|
|
|
|
|
public static void Jumpscare(ClientEnemy enemy) {
|
|
|
|
|
Screen.SetScreen(ScreenTypes.OFFICE);
|
|
|
|
|
enemy.JumpscareSprite.Play();
|
|
|
|
|
timerElement.Stop();
|
2026-03-17 20:14:29 +01:00
|
|
|
CommandManager.AllowGameControls(false);
|
2026-03-09 20:05:21 +01:00
|
|
|
// UIElement jumpscareElement = enemy.Sprite.Clone();
|
|
|
|
|
// jumpscareElement.ScaleMultiplier = 2;
|
|
|
|
|
// jumpscareElement.SetPosition(new Point(0, 0));
|
|
|
|
|
// officeScreen.AddElement("jumpscare", jumpscareElement);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ShowVictoryScreen() {
|
|
|
|
|
Screen.SetScreen(ScreenTypes.WIN);
|
|
|
|
|
Screen.DisableOverlay();
|
2026-03-11 22:35:30 +01:00
|
|
|
CommandManager.AllowGameControls(false);
|
2026-03-19 20:10:45 +01:00
|
|
|
SoundManager.StopAmbience();
|
2026-03-16 20:43:53 +01:00
|
|
|
InputManager.AddListener(Keys.Space, DisplayMainMenu, InputTiming.PRESS, new InputListenerHook(true, true));
|
2026-03-09 20:05:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ShowDeathScreen() {
|
|
|
|
|
Screen.SetScreen(ScreenTypes.LOSE);
|
|
|
|
|
Screen.DisableOverlay();
|
2026-03-11 22:35:30 +01:00
|
|
|
CommandManager.AllowGameControls(false);
|
2026-03-19 20:10:45 +01:00
|
|
|
SoundManager.StopAmbience();
|
2026-03-16 20:43:53 +01:00
|
|
|
InputManager.AddListener(Keys.Space, DisplayMainMenu, InputTiming.PRESS, new InputListenerHook(true, true));
|
2026-03-09 20:05:21 +01:00
|
|
|
}
|
2026-03-21 21:23:33 +01:00
|
|
|
|
|
|
|
|
public static void ResetUI() {
|
|
|
|
|
foreach (Screen screen in Screen.Screens.Values){
|
|
|
|
|
screen.RemoveTemporary();
|
|
|
|
|
}
|
|
|
|
|
lightIndicators.Clear();
|
|
|
|
|
enemyElements.Clear();
|
|
|
|
|
|
|
|
|
|
timerElement.Stop();
|
|
|
|
|
}
|
2026-03-09 20:05:21 +01:00
|
|
|
|
2026-02-26 16:24:55 +01:00
|
|
|
// private static Point GetRoomUIPos((int x, int y) pos) {
|
|
|
|
|
// return new Point(336 + (32 * pos.x), 144 + (32 * pos.y));
|
|
|
|
|
// }
|
|
|
|
|
|
2026-01-26 09:39:17 +01:00
|
|
|
}
|