v0.1.0
This commit is contained in:
695
Assets/DomeShift/DomeHud.cs
Normal file
695
Assets/DomeShift/DomeHud.cs
Normal file
@@ -0,0 +1,695 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DomeShift
|
||||
{
|
||||
internal sealed class DomeHud
|
||||
{
|
||||
private static readonly Color Panel = new Color32(18, 30, 29, 248);
|
||||
private static readonly Color Inset = new Color32(29, 44, 41, 255);
|
||||
private static readonly Color Border = new Color32(62, 85, 77, 255);
|
||||
private static readonly Color Ink = new Color32(240, 243, 222, 255);
|
||||
private static readonly Color MutedInk = new Color32(173, 196, 181, 255);
|
||||
private static readonly Color Mint = new Color32(153, 236, 184, 255);
|
||||
private static readonly Color Amber = new Color32(255, 194, 110, 255);
|
||||
private static readonly Color Alarm = new Color32(255, 136, 118, 255);
|
||||
private static readonly Color Shadow = new Color32(8, 13, 14, 84);
|
||||
private static readonly Color Overlay = new Color32(8, 13, 14, 139);
|
||||
private static readonly Color DoyleAccent = new Color32(147, 211, 239, 255);
|
||||
private static readonly Color MapGround = new Color32(18, 32, 32, 255);
|
||||
private static readonly Color MapCorridor = new Color32(85, 114, 103, 255);
|
||||
private static readonly Color[] StationColors =
|
||||
{
|
||||
Amber, new Color32(124, 221, 240, 255), Mint
|
||||
};
|
||||
|
||||
private static readonly string[] Stations = { "Generator", "Cooling", "Hydroponics" };
|
||||
private static readonly string[] Supplies = { "Fuse", "Mesh filter", "Seed pack" };
|
||||
private static readonly string[] Progress = { "0 / 3", "1 / 3", "2 / 3", "3 / 3" };
|
||||
private static readonly MapRegion[] RegionPlans =
|
||||
{
|
||||
new(DomeRegion.Rainforest, Rect.MinMaxRect(-42, 12, -15, 31), new Color32(119, 211, 157, 255), true),
|
||||
new(DomeRegion.Ocean, Rect.MinMaxRect(-13, 12, 13, 31), new Color32(106, 202, 227, 255), true),
|
||||
new(DomeRegion.MangroveWetlands, Rect.MinMaxRect(15, 12, 42, 31), new Color32(118, 197, 169, 255)),
|
||||
new(DomeRegion.Savanna, Rect.MinMaxRect(-42, -9, -15, 9), new Color32(222, 198, 121, 255)),
|
||||
new(DomeRegion.Orchard, Rect.MinMaxRect(-13, -9, 13, 9), new Color32(180, 208, 115, 255)),
|
||||
new(DomeRegion.ThornScrub, Rect.MinMaxRect(15, 0.35f, 42, 9), new Color32(190, 181, 145, 255)),
|
||||
new(DomeRegion.FogDesert, Rect.MinMaxRect(15, -9, 42, -0.35f), new Color32(230, 173, 133, 255), true),
|
||||
new(DomeRegion.Agriculture, Rect.MinMaxRect(-42, -31, -15, -13), new Color32(188, 220, 118, 255), true),
|
||||
new(DomeRegion.HumanHabitat, Rect.MinMaxRect(-13, -31, 13, -13), new Color32(197, 182, 211, 255)),
|
||||
new(DomeRegion.Technosphere, Rect.MinMaxRect(15, -31, 42, -13), new Color32(159, 182, 212, 255))
|
||||
};
|
||||
|
||||
private readonly GUIStyle tag = Style(12, FontStyle.Bold);
|
||||
private readonly GUIStyle tagRight = Style(12, FontStyle.Bold, TextAnchor.MiddleRight);
|
||||
private readonly GUIStyle body = Style(16, wraps: true);
|
||||
private readonly GUIStyle item = Style(16, FontStyle.Bold);
|
||||
private readonly GUIStyle key = Style(12, FontStyle.Bold, TextAnchor.MiddleCenter);
|
||||
private readonly GUIStyle time = Style(31, FontStyle.Bold, TextAnchor.MiddleRight);
|
||||
private readonly GUIStyle title = Style(78, FontStyle.Bold);
|
||||
private readonly GUIStyle headline = Style(42, FontStyle.Bold);
|
||||
private readonly GUIStyle section = Style(22, FontStyle.Bold);
|
||||
private readonly GUIStyle longLocation = Style(18, FontStyle.Bold);
|
||||
private readonly GUIStyle regionLabel = Style(16, FontStyle.Bold, TextAnchor.MiddleCenter);
|
||||
private readonly GUIStyle longRegionLabel = Style(14, FontStyle.Bold, TextAnchor.MiddleCenter);
|
||||
private readonly GUIStyle prompt = Style(16, FontStyle.Bold, TextAnchor.MiddleCenter, true);
|
||||
private readonly GUIStyle fine = Style(13, wraps: true);
|
||||
|
||||
private int lastSeconds = -1;
|
||||
private string clockText;
|
||||
|
||||
public void Draw(DomeGame game)
|
||||
{
|
||||
if (Screen.width < 1 || Screen.height < 1)
|
||||
return;
|
||||
|
||||
Matrix4x4 originalMatrix = GUI.matrix;
|
||||
float scale = Mathf.Min(Screen.width / 1100f, Screen.height / 700f);
|
||||
float width = Screen.width / scale;
|
||||
float height = Screen.height / scale;
|
||||
GUI.matrix = Matrix4x4.Scale(new Vector3(scale, scale, 1));
|
||||
|
||||
try
|
||||
{
|
||||
if (game.Phase == GamePhase.Title)
|
||||
{
|
||||
DrawTitle(game, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
DrawGameplay(game, width, height);
|
||||
if (game.Phase == GamePhase.Playing)
|
||||
{
|
||||
if (game.MapOpen)
|
||||
DrawMap(game, width, height);
|
||||
}
|
||||
else
|
||||
DrawShiftCard(game, width, height);
|
||||
}
|
||||
finally
|
||||
{
|
||||
GUI.matrix = originalMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawTitle(DomeGame game, float width, float height)
|
||||
{
|
||||
Fill(new Rect(0, 0, width, height), new Color32(14, 22, 21, 53));
|
||||
Rect card = new Rect(32, (height - 595) * 0.5f, 432, 595);
|
||||
DrawPanel(card);
|
||||
Fill(new Rect(card.x, card.y, 5, card.height), Amber);
|
||||
|
||||
float left = card.x + 28;
|
||||
float top = card.y + 27;
|
||||
Label(new Rect(left, top, 314, 20), "GREENHOUSE MAINTENANCE", tag, Amber);
|
||||
DrawBadge(card.xMax - 80, top + 8);
|
||||
Label(new Rect(left - 3, top + 24, 338, 86), "DOME", title, Ink);
|
||||
Label(new Rect(left - 3, top + 88, 338, 86), "SHIFT", title, Mint);
|
||||
Fill(new Rect(left, top + 177, 375, 1), Border);
|
||||
|
||||
Label(new Rect(left, top + 189, 350, 43),
|
||||
"You came looking for a bathroom. The greenhouse locked you in.", body, Ink);
|
||||
Label(new Rect(left, top + 232, 371, 57),
|
||||
"Tour the Rainforest, Tropical Lagoon, Farm and Great Desert, or repair three stations before lockdown.", body, MutedInk);
|
||||
|
||||
Label(new Rect(left, top + 299, 215, 19), "CHOOSE A CHARACTER", tag, Amber);
|
||||
Label(new Rect(left + 206, top + 299, 169, 19), "LEFT / RIGHT ARROWS", tagRight, MutedInk);
|
||||
DrawCharacterOption(game, new Rect(left, top + 324, 181, 58), PlayableCharacter.Bud);
|
||||
DrawCharacterOption(game, new Rect(left + 194, top + 324, 181, 58), PlayableCharacter.Doyle);
|
||||
|
||||
if (ActionButton(new Rect(left, top + 397, 375, 52), "EXPLORE DOME", "X"))
|
||||
game.StartExplore();
|
||||
if (SecondaryButton(new Rect(left, top + 462, 375, 42), "Start timed shift", "ENTER", 63))
|
||||
game.StartShift();
|
||||
|
||||
float controls = top + 524;
|
||||
DrawBinding(left, controls, 118, "WASD / ARROWS", "Move");
|
||||
DrawBinding(left + 175, controls, 30, "E", "Use");
|
||||
DrawBinding(left + 266, controls, 46, "ESC", "Pause");
|
||||
|
||||
if (game.CanToggleFullscreen)
|
||||
DrawFullscreenButton(game, new Rect(width - 325, 24, 167, 34));
|
||||
DrawSoundButton(game, new Rect(width - 150, 24, 126, 34));
|
||||
}
|
||||
|
||||
private void DrawGameplay(DomeGame game, float width, float height)
|
||||
{
|
||||
if (game.Exploring)
|
||||
{
|
||||
Rect location = new Rect(24, 24, 252, 75);
|
||||
DrawPanel(location);
|
||||
Fill(new Rect(location.x, location.y, 3, location.height), Mint);
|
||||
Label(new Rect(location.x + 15, location.y + 12, 218, 18),
|
||||
game.Character == PlayableCharacter.Bud ? "EXPLORING AS BUD" : "EXPLORING AS DOYLE", tag, Mint);
|
||||
GUIStyle locationStyle = game.CurrentRegion == DomeRegion.MangroveWetlands ? longLocation : section;
|
||||
Label(new Rect(location.x + 15, location.y + 34, 224, 27), DomeEnvironment.RegionName(game.CurrentRegion), locationStyle, Ink);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawObjectives(new Rect(24, 24, 252, 166), game.RepairedMask);
|
||||
DrawClock(new Rect(width - 209, 24, 185, 82), game.TimeLeft, game.RoundLength);
|
||||
}
|
||||
|
||||
if (game.Phase == GamePhase.Playing)
|
||||
DrawNavigation(game, width);
|
||||
|
||||
float bottom = height - 24;
|
||||
Rect radio = new Rect(24, bottom - 64, 326, 64);
|
||||
Rect pocket = new Rect(width - 217, bottom - 64, 193, 64);
|
||||
if (!string.IsNullOrWhiteSpace(game.Dispatch))
|
||||
DrawRadio(radio, game.Dispatch);
|
||||
if (!game.Exploring || game.Carried >= 0)
|
||||
DrawPocket(pocket, game.Carried, game.Character);
|
||||
|
||||
float center = width * 0.5f;
|
||||
if (!string.IsNullOrWhiteSpace(game.Prompt))
|
||||
{
|
||||
Rect cue = new Rect(center - 184, bottom - 64, 368, 36);
|
||||
DrawPanel(cue);
|
||||
Fill(new Rect(cue.x, cue.y, 3, cue.height), Amber);
|
||||
Label(new Rect(cue.x + 9, cue.y, cue.width - 18, cue.height), game.Prompt, prompt, Ink);
|
||||
}
|
||||
|
||||
Rect controls = new Rect(center - 192, bottom - 24, 384, 24);
|
||||
Fill(controls, Panel);
|
||||
Label(controls, "WASD / Arrows Move E Use Esc Pause M Sound", key, MutedInk);
|
||||
}
|
||||
|
||||
private void DrawNavigation(DomeGame game, float width)
|
||||
{
|
||||
float left = (width - 407) * 0.5f;
|
||||
if (NavigationButton(new Rect(left, 24, 108, 33), "Map", "TAB", 34, game.MapOpen))
|
||||
game.ToggleMap();
|
||||
if (NavigationButton(new Rect(left + 115, 24, 143, 33), game.Overview ? "Overview cam" : "Follow cam", "C", 24, game.Overview))
|
||||
game.ToggleOverview();
|
||||
if (NavigationButton(new Rect(left + 265, 24, 142, 33), game.Cutaway ? "Roof cutaway" : "Roof visible", "V", 24, game.Cutaway))
|
||||
game.ToggleRoof();
|
||||
|
||||
if (!game.Exploring)
|
||||
{
|
||||
Rect location = new Rect(width * 0.5f - 118, 62, 236, 23);
|
||||
Fill(location, Panel);
|
||||
Label(location, DomeEnvironment.RegionName(game.CurrentRegion), key, MutedInk);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMap(DomeGame game, float width, float height)
|
||||
{
|
||||
Rect card = new Rect((width - 720) * 0.5f, (height - 550) * 0.5f, 720, 550);
|
||||
DrawPanel(card);
|
||||
Fill(new Rect(card.x, card.y, card.width, 3), Mint);
|
||||
Label(new Rect(card.x + 22, card.y + 13, 235, 31), "Dome map", section, Ink);
|
||||
Label(new Rect(card.x + 22, card.y + 43, 370, 19), DomeEnvironment.RegionName(game.CurrentRegion), tag, Mint);
|
||||
if (NavigationButton(new Rect(card.xMax - 132, card.y + 19, 109, 32), "Close", "TAB", 34, false))
|
||||
game.ToggleMap();
|
||||
|
||||
Rect floor = new Rect(card.x + 80, card.y + 72, 560, 560f * DomeEnvironment.HalfDepth / DomeEnvironment.HalfWidth);
|
||||
Fill(floor, MapGround);
|
||||
Stroke(floor, MapCorridor);
|
||||
foreach (MapRegion region in RegionPlans)
|
||||
DrawMapRegion(floor, region, region.Region == game.CurrentRegion);
|
||||
|
||||
DrawMapCorridor(floor, -14, true);
|
||||
DrawMapCorridor(floor, 14, true);
|
||||
DrawMapCorridor(floor, 10.5f, false);
|
||||
DrawMapCorridor(floor, -11, false);
|
||||
|
||||
DrawNorthArrow(card.x + 37, floor.y + 7);
|
||||
if (!game.Exploring)
|
||||
DrawChallengePins(floor, game);
|
||||
|
||||
Vector2 player = CanvasPoint(floor, game.MapPosition);
|
||||
DrawPlayerPin(player);
|
||||
|
||||
float legendY = card.yMax - 42;
|
||||
Fill(new Rect(card.x + 22, legendY - 7, card.width - 44, 1), Border);
|
||||
DrawPlayerPin(new Vector2(card.x + 28, legendY + 12));
|
||||
Label(new Rect(card.x + 42, legendY, 91, 24), "You", fine, MutedInk);
|
||||
Fill(new Rect(card.x + 103, legendY + 10, 12, 3), Amber);
|
||||
Label(new Rect(card.x + 121, legendY, 111, 24), "Film tour", fine, MutedInk);
|
||||
Fill(new Rect(card.x + 212, legendY + 10, 13, 2), MapCorridor);
|
||||
Label(new Rect(card.x + 233, legendY, 92, 24), "Corridor", fine, MutedInk);
|
||||
|
||||
if (!game.Exploring)
|
||||
{
|
||||
DrawMapPin(new Vector2(card.x + 331, legendY + 12), Ink, PinKind.Station);
|
||||
Label(new Rect(card.x + 346, legendY, 84, 24), "Station", fine, MutedInk);
|
||||
DrawMapPin(new Vector2(card.x + 438, legendY + 12), Ink, PinKind.Spare);
|
||||
Label(new Rect(card.x + 451, legendY, 84, 24), "Spare", fine, MutedInk);
|
||||
DrawMapPin(new Vector2(card.x + 527, legendY + 12), Ink, PinKind.Airlock);
|
||||
Label(new Rect(card.x + 541, legendY, 133, 24), "Airlock", fine, MutedInk);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMapRegion(Rect floor, MapRegion region, bool current)
|
||||
{
|
||||
Vector2 upperLeft = WorldPoint(floor, region.Bounds.xMin, region.Bounds.yMax);
|
||||
Vector2 lowerRight = WorldPoint(floor, region.Bounds.xMax, region.Bounds.yMin);
|
||||
Rect area = Rect.MinMaxRect(upperLeft.x, upperLeft.y, lowerRight.x, lowerRight.y);
|
||||
Fill(area, Color.Lerp(MapGround, region.Color, current ? 0.32f : 0.19f));
|
||||
Stroke(area, current ? Mint : Color.Lerp(MapGround, region.Color, 0.55f));
|
||||
|
||||
if (region.FilmTour)
|
||||
Fill(new Rect(area.x + 8, area.y + 8, 12, 3), Amber);
|
||||
if (current)
|
||||
Fill(new Rect(area.x, area.y, 3, area.height), Mint);
|
||||
|
||||
bool hasLung = region.Region == DomeRegion.Technosphere;
|
||||
Rect label = new Rect(area.x + 6, area.center.y - (hasLung ? 23 : 14), area.width - 12, 28);
|
||||
GUIStyle labelStyle = region.Region == DomeRegion.MangroveWetlands ? longRegionLabel : regionLabel;
|
||||
Label(label, DomeEnvironment.RegionName(region.Region), labelStyle, Ink);
|
||||
if (hasLung)
|
||||
Label(new Rect(area.x + 6, area.center.y + 4, area.width - 12, 22), "Lung chambers", key, MutedInk);
|
||||
}
|
||||
|
||||
private static void DrawMapCorridor(Rect floor, float coordinate, bool vertical)
|
||||
{
|
||||
Vector2 center = vertical ? WorldPoint(floor, coordinate, 0) : WorldPoint(floor, 0, coordinate);
|
||||
float length = vertical ? floor.height : floor.width;
|
||||
for (float offset = 8; offset < length - 14; offset += 16)
|
||||
{
|
||||
Rect dash = vertical
|
||||
? new Rect(center.x - 0.5f, floor.y + offset, 1, 7)
|
||||
: new Rect(floor.x + offset, center.y - 0.5f, 7, 1);
|
||||
Fill(dash, MapCorridor);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawNorthArrow(float x, float y)
|
||||
{
|
||||
Label(new Rect(x - 9, y, 18, 18), "N", key, MutedInk);
|
||||
Fill(new Rect(x - 0.5f, y + 22, 1, 19), MutedInk);
|
||||
Fill(new Rect(x - 2, y + 23, 4, 2), MutedInk);
|
||||
Fill(new Rect(x - 4, y + 25, 8, 2), MutedInk);
|
||||
}
|
||||
|
||||
private void DrawChallengePins(Rect floor, DomeGame game)
|
||||
{
|
||||
string hovered = null;
|
||||
Vector2 mouse = Event.current.mousePosition;
|
||||
for (int index = 0; index < Stations.Length; index++)
|
||||
{
|
||||
bool online = (game.RepairedMask & (1 << index)) != 0;
|
||||
Vector2 station = CanvasPoint(floor, game.MapPoint(index));
|
||||
DrawMapPin(station, online ? MutedInk : StationColors[index], PinKind.Station);
|
||||
if ((mouse - station).sqrMagnitude < 80f)
|
||||
hovered = Stations[index];
|
||||
|
||||
if (online || game.Carried == index)
|
||||
continue;
|
||||
|
||||
Vector2 supply = CanvasPoint(floor, game.MapPoint(index + Stations.Length));
|
||||
DrawMapPin(supply, StationColors[index], PinKind.Spare);
|
||||
if ((mouse - supply).sqrMagnitude < 80f)
|
||||
hovered = Supplies[index];
|
||||
}
|
||||
|
||||
Vector2 exit = CanvasPoint(floor, game.MapPoint(6));
|
||||
DrawMapPin(exit, CountRepairs(game.RepairedMask) == 3 ? Mint : Ink, PinKind.Airlock);
|
||||
if ((mouse - exit).sqrMagnitude < 80f)
|
||||
hovered = "Airlock";
|
||||
|
||||
if (hovered != null)
|
||||
{
|
||||
Rect tooltip = new Rect(Mathf.Clamp(mouse.x - 67, floor.xMin, floor.xMax - 134), mouse.y - 35, 134, 23);
|
||||
DrawPanel(tooltip);
|
||||
Label(tooltip, hovered, key, Ink);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawMapPin(Vector2 point, Color color, PinKind kind)
|
||||
{
|
||||
Rect square = new Rect(point.x - 5, point.y - 5, 10, 10);
|
||||
Fill(square, MapGround);
|
||||
if (kind == PinKind.Station)
|
||||
{
|
||||
Stroke(square, color);
|
||||
Fill(new Rect(point.x - 2, point.y - 2, 4, 4), color);
|
||||
}
|
||||
else if (kind == PinKind.Spare)
|
||||
{
|
||||
Fill(new Rect(point.x - 3, point.y - 3, 6, 6), color);
|
||||
}
|
||||
else
|
||||
{
|
||||
Fill(new Rect(point.x - 4, point.y - 1, 8, 2), color);
|
||||
Fill(new Rect(point.x - 1, point.y - 4, 2, 8), color);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawPlayerPin(Vector2 point)
|
||||
{
|
||||
Fill(new Rect(point.x - 7, point.y - 7, 14, 14), MapGround);
|
||||
Stroke(new Rect(point.x - 6, point.y - 6, 12, 12), Mint);
|
||||
Fill(new Rect(point.x - 3, point.y - 3, 6, 6), Ink);
|
||||
}
|
||||
|
||||
private static Vector2 WorldPoint(Rect floor, float x, float z)
|
||||
{
|
||||
return CanvasPoint(floor, DomeEnvironment.MapCoordinates(new Vector2(x, z)));
|
||||
}
|
||||
|
||||
private static Vector2 CanvasPoint(Rect floor, Vector2 normalized)
|
||||
{
|
||||
return new Vector2(floor.x + Mathf.Clamp01(normalized.x) * floor.width,
|
||||
floor.yMax - Mathf.Clamp01(normalized.y) * floor.height);
|
||||
}
|
||||
|
||||
private enum PinKind
|
||||
{
|
||||
Station,
|
||||
Spare,
|
||||
Airlock
|
||||
}
|
||||
|
||||
private readonly struct MapRegion
|
||||
{
|
||||
public readonly DomeRegion Region;
|
||||
public readonly Rect Bounds;
|
||||
public readonly Color Color;
|
||||
public readonly bool FilmTour;
|
||||
|
||||
public MapRegion(DomeRegion region, Rect bounds, Color color, bool filmTour = false)
|
||||
{
|
||||
Region = region;
|
||||
Bounds = bounds;
|
||||
Color = color;
|
||||
FilmTour = filmTour;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawObjectives(Rect rect, int repairedMask)
|
||||
{
|
||||
DrawPanel(rect);
|
||||
int repaired = CountRepairs(repairedMask);
|
||||
string currentGoal = repaired == 3 ? "RETURN TO THE AIRLOCK" : "RESTORE THE DOME";
|
||||
Color goalColor = repaired == 3 ? Mint : Amber;
|
||||
Fill(new Rect(rect.x, rect.y, rect.width, 3), goalColor);
|
||||
Label(new Rect(rect.x + 14, rect.y + 12, 174, 22), currentGoal, tag, goalColor);
|
||||
Label(new Rect(rect.xMax - 49, rect.y + 12, 35, 22), Progress[repaired], tagRight, MutedInk);
|
||||
|
||||
for (int index = 0; index < Stations.Length; index++)
|
||||
{
|
||||
bool online = (repairedMask & (1 << index)) != 0;
|
||||
Rect row = new Rect(rect.x + 10, rect.y + 42 + index * 38, rect.width - 20, 33);
|
||||
Fill(row, Inset);
|
||||
DrawStationIcon(row.x + 9, row.y + 8, index, StationColors[index]);
|
||||
Label(new Rect(row.x + 33, row.y, 118, row.height), Stations[index], item, Ink);
|
||||
Label(new Rect(row.xMax - 68, row.y, 59, row.height), online ? "ONLINE" : "OFFLINE", tagRight, online ? Mint : MutedInk);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawClock(Rect rect, float remaining, float duration)
|
||||
{
|
||||
DrawPanel(rect);
|
||||
Color color = remaining <= 15f ? Alarm : Amber;
|
||||
Label(new Rect(rect.x + 13, rect.y + 13, 81, 17), "SAFETY", tag, MutedInk);
|
||||
Label(new Rect(rect.x + 13, rect.y + 32, 81, 17), "LOCKOUT IN", tag, MutedInk);
|
||||
Label(new Rect(rect.xMax - 85, rect.y + 9, 71, 43), TimeText(remaining), time, color);
|
||||
|
||||
Rect meter = new Rect(rect.x + 13, rect.yMax - 20, rect.width - 26, 6);
|
||||
Fill(meter, Inset);
|
||||
float ratio = duration > 0 ? Mathf.Clamp01(remaining / duration) : 0;
|
||||
Fill(new Rect(meter.x, meter.y, meter.width * ratio, meter.height), color);
|
||||
}
|
||||
|
||||
private void DrawRadio(Rect rect, string message)
|
||||
{
|
||||
DrawPanel(rect);
|
||||
Fill(new Rect(rect.x + 14, rect.y + 15, 6, 6), Mint);
|
||||
Label(new Rect(rect.x + 27, rect.y + 9, rect.width - 39, 18), "DISPATCH", tag, Mint);
|
||||
Label(new Rect(rect.x + 14, rect.y + 26, rect.width - 28, 30), message, fine, Ink);
|
||||
}
|
||||
|
||||
private void DrawPocket(Rect rect, int carried, PlayableCharacter character)
|
||||
{
|
||||
DrawPanel(rect);
|
||||
Label(new Rect(rect.x + 14, rect.y + 9, rect.width - 28, 18),
|
||||
character == PlayableCharacter.Bud ? "BUD'S TOOL BELT" : "DOYLE'S TOOL BELT", tag, CharacterAccent(character));
|
||||
bool occupied = carried >= 0 && carried < Supplies.Length;
|
||||
if (occupied)
|
||||
DrawStationIcon(rect.x + 15, rect.y + 35, carried, StationColors[carried]);
|
||||
Label(new Rect(rect.x + (occupied ? 39 : 14), rect.y + 27, rect.width - 49, 30),
|
||||
occupied ? Supplies[carried] : "Empty", item, occupied ? Ink : MutedInk);
|
||||
}
|
||||
|
||||
private void DrawShiftCard(DomeGame game, float width, float height)
|
||||
{
|
||||
Fill(new Rect(0, 0, width, height), Overlay);
|
||||
bool won = game.Phase == GamePhase.Won;
|
||||
bool paused = game.Phase == GamePhase.Paused;
|
||||
bool showReturn = !paused || game.Exploring;
|
||||
float cardHeight = showReturn ? 352 : 294;
|
||||
Rect card = new Rect((width - 434) * 0.5f, (height - cardHeight) * 0.5f, 434, cardHeight);
|
||||
DrawPanel(card);
|
||||
Color accent = won ? Mint : paused ? Amber : Alarm;
|
||||
Fill(new Rect(card.x, card.y, card.width, 4), accent);
|
||||
|
||||
float left = card.x + 26;
|
||||
Label(new Rect(left, card.y + 23, 300, 20), paused ? "SHIFT CONTROL" : "SHIFT REPORT", tag, accent);
|
||||
string heading = paused ? "Taking a break?" : won ? "You made it out." : "Lockdown.";
|
||||
Label(new Rect(left, card.y + 46, 380, 58), heading, headline, Ink);
|
||||
|
||||
if (paused)
|
||||
{
|
||||
string detail = game.Exploring ? DomeEnvironment.RegionName(game.CurrentRegion) : "The shift clock is paused.";
|
||||
Label(new Rect(left, card.y + 106, 380, 48), detail, body, MutedInk);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawStat(new Rect(left, card.y + 113, 187, 63), "STATIONS ONLINE", Progress[CountRepairs(game.RepairedMask)]);
|
||||
DrawStat(new Rect(left + 195, card.y + 113, 187, 63), "TIME LEFT", TimeText(game.TimeLeft));
|
||||
}
|
||||
|
||||
string retry = game.Character == PlayableCharacter.Bud ? "RETRY AS BUD" : "RETRY AS DOYLE";
|
||||
if (ActionButton(new Rect(left, card.y + 198, 382, 50), paused ? "RESUME SHIFT" : retry, "ENTER"))
|
||||
{
|
||||
if (paused)
|
||||
game.Resume();
|
||||
else
|
||||
game.Restart();
|
||||
}
|
||||
|
||||
if (showReturn && SecondaryButton(new Rect(left, card.y + 261, 382, 42), paused ? "Return to title" : "Change character", "B"))
|
||||
game.ChooseCharacter();
|
||||
|
||||
bool showFullscreen = paused && game.CanToggleFullscreen;
|
||||
Label(new Rect(left, card.yMax - 38, showFullscreen ? 90 : 226, 24), paused ? "ESC Resume" : "R Retry shift", tag, MutedInk);
|
||||
if (showFullscreen)
|
||||
DrawFullscreenButton(game, new Rect(left + 94, card.yMax - 39, 154, 25));
|
||||
DrawSoundButton(game, new Rect(card.xMax - 151, card.yMax - 39, 125, 25));
|
||||
}
|
||||
|
||||
private void DrawCharacterOption(DomeGame game, Rect rect, PlayableCharacter character)
|
||||
{
|
||||
bool selected = game.Character == character;
|
||||
bool bud = character == PlayableCharacter.Bud;
|
||||
bool hovered = rect.Contains(Event.current.mousePosition);
|
||||
Color accent = CharacterAccent(character);
|
||||
Fill(rect, selected || hovered ? Border : Inset);
|
||||
Stroke(rect, selected ? accent : Border);
|
||||
if (selected)
|
||||
Fill(new Rect(rect.x, rect.y, 3, rect.height), accent);
|
||||
|
||||
DrawCharacterPortrait(new Rect(rect.x + 10, rect.y + 8, 42, 42), bud, accent);
|
||||
Label(new Rect(rect.x + 61, rect.y + 8, 79, 22), bud ? "Bud" : "Doyle", item, Ink);
|
||||
Label(new Rect(rect.x + 61, rect.y + 29, 80, 17), bud ? "Macintosh" : "Johnson", fine, MutedInk);
|
||||
DrawKey(new Rect(rect.xMax - 33, rect.y + 17, 24, 24), bud ? "1" : "2",
|
||||
selected ? accent : Inset, selected ? accent : Border, selected ? Panel : Ink);
|
||||
if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
|
||||
game.SelectCharacter(character);
|
||||
}
|
||||
|
||||
private static Color CharacterAccent(PlayableCharacter character)
|
||||
{
|
||||
return character == PlayableCharacter.Bud ? Amber : DoyleAccent;
|
||||
}
|
||||
|
||||
private static void DrawCharacterPortrait(Rect rect, bool bud, Color accent)
|
||||
{
|
||||
Color hair = bud ? new Color32(72, 48, 44, 255) : new Color32(238, 199, 115, 255);
|
||||
Color skin = bud ? new Color32(223, 163, 128, 255) : new Color32(247, 188, 156, 255);
|
||||
float x = rect.x;
|
||||
float y = rect.y;
|
||||
Fill(rect, Panel);
|
||||
Fill(new Rect(x + 6, y + 32, 30, 8), accent);
|
||||
Fill(new Rect(x + 10, y + 29, 22, 5), accent);
|
||||
Fill(new Rect(x + 11, y + 8, 20, bud ? 25 : 11), hair);
|
||||
Fill(new Rect(x + 16, y + 13, 12, 14), skin);
|
||||
Fill(new Rect(x + 20, y + 27, 5, 5), skin);
|
||||
Fill(new Rect(x + 14, y + 9, 13, 5), hair);
|
||||
if (bud)
|
||||
Fill(new Rect(x + 13, y + 11, 16, 3), new Color32(200, 91, 84, 255));
|
||||
else
|
||||
Fill(new Rect(x + 16, y + 5, 9, 5), hair);
|
||||
Fill(new Rect(x + 19, y + 17, 2, 2), Panel);
|
||||
Fill(new Rect(x + 25, y + 17, 2, 2), Panel);
|
||||
}
|
||||
|
||||
private void DrawStat(Rect rect, string text, string value)
|
||||
{
|
||||
Fill(rect, Inset);
|
||||
Label(new Rect(rect.x + 11, rect.y + 8, rect.width - 22, 18), text, tag, MutedInk);
|
||||
Label(new Rect(rect.x + 11, rect.y + 29, rect.width - 22, 24), value, item, Ink);
|
||||
}
|
||||
|
||||
private void DrawSoundButton(DomeGame game, Rect rect)
|
||||
{
|
||||
bool hovered = rect.Contains(Event.current.mousePosition);
|
||||
Fill(rect, hovered ? Border : Inset);
|
||||
Stroke(rect, Border);
|
||||
Label(new Rect(rect.x + 4, rect.y, rect.width - 8, rect.height),
|
||||
game.Muted ? "SOUND OFF M" : "SOUND ON M", key, Ink);
|
||||
if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
|
||||
game.ToggleMute();
|
||||
}
|
||||
|
||||
private void DrawFullscreenButton(DomeGame game, Rect rect)
|
||||
{
|
||||
if (NavigationButton(rect, game.Fullscreen ? "Windowed" : "Fullscreen", "F11", 33, false))
|
||||
game.ToggleFullscreen();
|
||||
}
|
||||
|
||||
private bool ActionButton(Rect rect, string text, string binding)
|
||||
{
|
||||
bool hovered = rect.Contains(Event.current.mousePosition);
|
||||
Fill(new Rect(rect.x, rect.y + 3, rect.width, rect.height), Shadow);
|
||||
Fill(rect, hovered ? Ink : Mint);
|
||||
Label(new Rect(rect.x + 16, rect.y, rect.width - 102, rect.height), text, item, Panel);
|
||||
DrawKey(new Rect(rect.xMax - 76, rect.y + 12, 63, rect.height - 24), binding, Panel, Inset, Ink);
|
||||
return GUI.Button(rect, GUIContent.none, GUIStyle.none);
|
||||
}
|
||||
|
||||
private bool SecondaryButton(Rect rect, string text, string binding, float bindingWidth = 24)
|
||||
{
|
||||
bool hovered = rect.Contains(Event.current.mousePosition);
|
||||
Fill(rect, hovered ? Border : Inset);
|
||||
Stroke(rect, Border);
|
||||
Label(new Rect(rect.x + 16, rect.y, rect.width - bindingWidth - 44, rect.height), text, item, Ink);
|
||||
DrawKey(new Rect(rect.xMax - bindingWidth - 13, rect.center.y - 12, bindingWidth, 24), binding, Inset, Border, Ink);
|
||||
return GUI.Button(rect, GUIContent.none, GUIStyle.none);
|
||||
}
|
||||
|
||||
private bool NavigationButton(Rect rect, string text, string binding, float bindingWidth, bool active)
|
||||
{
|
||||
bool hovered = rect.Contains(Event.current.mousePosition);
|
||||
Fill(rect, hovered ? Border : Panel);
|
||||
Stroke(rect, active ? Mint : Border);
|
||||
Label(new Rect(rect.x + 10, rect.y, rect.width - bindingWidth - 20, rect.height), text, fine, active ? Mint : Ink);
|
||||
DrawKey(new Rect(rect.xMax - bindingWidth - 6, rect.center.y - 10, bindingWidth, 20), binding, Inset, Border, MutedInk);
|
||||
return GUI.Button(rect, GUIContent.none, GUIStyle.none);
|
||||
}
|
||||
|
||||
private void DrawBinding(float x, float y, float keyWidth, string binding, string action)
|
||||
{
|
||||
DrawKey(new Rect(x, y, keyWidth, 24), binding, Inset, Border, Ink);
|
||||
Label(new Rect(x + keyWidth + 8, y, 72, 24), action, fine, MutedInk);
|
||||
}
|
||||
|
||||
private void DrawKey(Rect rect, string text, Color background, Color edge, Color ink)
|
||||
{
|
||||
Fill(rect, background);
|
||||
Stroke(rect, edge);
|
||||
Label(rect, text, key, ink);
|
||||
}
|
||||
|
||||
private static void DrawBadge(float x, float y)
|
||||
{
|
||||
Stroke(new Rect(x, y, 52, 52), Border);
|
||||
Fill(new Rect(x + 7, y + 39, 38, 2), Mint);
|
||||
Fill(new Rect(x + 12, y + 30, 2, 9), Mint);
|
||||
Fill(new Rect(x + 18, y + 22, 2, 17), Mint);
|
||||
Fill(new Rect(x + 25, y + 19, 2, 20), Mint);
|
||||
Fill(new Rect(x + 32, y + 22, 2, 17), Mint);
|
||||
Fill(new Rect(x + 38, y + 30, 2, 9), Mint);
|
||||
Fill(new Rect(x + 25, y + 7, 2, 4), Amber);
|
||||
Fill(new Rect(x + 38, y + 13, 4, 2), Amber);
|
||||
Fill(new Rect(x + 10, y + 13, 4, 2), Amber);
|
||||
}
|
||||
|
||||
private static void DrawStationIcon(float x, float y, int index, Color color)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
Fill(new Rect(x + 5, y, 7, 4), color);
|
||||
Stroke(new Rect(x + 3, y + 3, 11, 11), color);
|
||||
Fill(new Rect(x + 5, y + 14, 7, 3), color);
|
||||
return;
|
||||
}
|
||||
|
||||
if (index == 1)
|
||||
{
|
||||
Stroke(new Rect(x + 1, y + 1, 16, 15), color);
|
||||
Fill(new Rect(x + 4, y + 5, 10, 1), color);
|
||||
Fill(new Rect(x + 4, y + 8, 10, 1), color);
|
||||
Fill(new Rect(x + 4, y + 11, 10, 1), color);
|
||||
return;
|
||||
}
|
||||
|
||||
Fill(new Rect(x + 8, y + 6, 2, 10), color);
|
||||
Fill(new Rect(x + 3, y + 5, 5, 3), color);
|
||||
Fill(new Rect(x + 10, y + 2, 5, 3), color);
|
||||
Fill(new Rect(x + 5, y + 14, 8, 2), color);
|
||||
}
|
||||
|
||||
private string TimeText(float timeLeft)
|
||||
{
|
||||
int seconds = Mathf.Max(0, Mathf.CeilToInt(timeLeft));
|
||||
if (seconds != lastSeconds)
|
||||
{
|
||||
lastSeconds = seconds;
|
||||
clockText = $"{seconds / 60}:{seconds % 60:00}";
|
||||
}
|
||||
return clockText;
|
||||
}
|
||||
|
||||
private static int CountRepairs(int mask)
|
||||
{
|
||||
return (mask & 1) + ((mask >> 1) & 1) + ((mask >> 2) & 1);
|
||||
}
|
||||
|
||||
private static GUIStyle Style(int size, FontStyle weight = FontStyle.Normal,
|
||||
TextAnchor anchor = TextAnchor.MiddleLeft, bool wraps = false)
|
||||
{
|
||||
return new GUIStyle
|
||||
{
|
||||
fontSize = size,
|
||||
fontStyle = weight,
|
||||
alignment = anchor,
|
||||
wordWrap = wraps,
|
||||
clipping = TextClipping.Clip,
|
||||
normal = { textColor = Color.white }
|
||||
};
|
||||
}
|
||||
|
||||
private static void Label(Rect bounds, string text, GUIStyle style, Color color)
|
||||
{
|
||||
Color previous = GUI.contentColor;
|
||||
GUI.contentColor = color;
|
||||
GUI.Label(bounds, text, style);
|
||||
GUI.contentColor = previous;
|
||||
}
|
||||
|
||||
private static void DrawPanel(Rect rect)
|
||||
{
|
||||
Fill(new Rect(rect.x + 3, rect.y + 5, rect.width, rect.height), Shadow);
|
||||
Fill(rect, Panel);
|
||||
Stroke(rect, Border);
|
||||
}
|
||||
|
||||
private static void Stroke(Rect rect, Color color)
|
||||
{
|
||||
Fill(new Rect(rect.x, rect.y, rect.width, 1), color);
|
||||
Fill(new Rect(rect.x, rect.yMax - 1, rect.width, 1), color);
|
||||
Fill(new Rect(rect.x, rect.y + 1, 1, rect.height - 2), color);
|
||||
Fill(new Rect(rect.xMax - 1, rect.y + 1, 1, rect.height - 2), color);
|
||||
}
|
||||
|
||||
private static void Fill(Rect rect, Color color)
|
||||
{
|
||||
Color previous = GUI.color;
|
||||
GUI.color = color;
|
||||
GUI.DrawTexture(rect, Texture2D.whiteTexture);
|
||||
GUI.color = previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user