Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b883ff858d |
189
Assets/DomeShift/DomeCameraRig.cs
Normal file
189
Assets/DomeShift/DomeCameraRig.cs
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DomeShift
|
||||||
|
{
|
||||||
|
internal sealed class DomeCameraRig
|
||||||
|
{
|
||||||
|
private static readonly Vector3 OverviewOffset = new(15f, 67f, -79f);
|
||||||
|
private static readonly Vector3 FollowOffset = new(0f, 16f, -20f);
|
||||||
|
|
||||||
|
private const float MinimumPitch = 18f;
|
||||||
|
private const float MaximumPitch = 82f;
|
||||||
|
private const float OrbitSensitivity = 0.24f;
|
||||||
|
private const float ZoomStep = 0.85f;
|
||||||
|
|
||||||
|
private readonly View followView = new();
|
||||||
|
private readonly View overviewView = new();
|
||||||
|
private readonly View viewerView = new();
|
||||||
|
private View activeView;
|
||||||
|
private Vector2 lastPointer;
|
||||||
|
private int dragButton = -1;
|
||||||
|
private bool panning;
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
followView.Reset();
|
||||||
|
overviewView.Reset();
|
||||||
|
viewerView.Reset();
|
||||||
|
dragButton = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Frame(Camera camera, DomeEnvironment profile, Transform environmentRoot, Transform player,
|
||||||
|
bool title, bool overview, bool viewer, bool allowInput)
|
||||||
|
{
|
||||||
|
bool wideView = title || overview || viewer;
|
||||||
|
View view = title ? null : viewer ? viewerView : overview ? overviewView : followView;
|
||||||
|
if (activeView != view)
|
||||||
|
{
|
||||||
|
activeView = view;
|
||||||
|
dragButton = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
float aspect = Mathf.Max(camera.aspect, 0.1f);
|
||||||
|
Vector3 center;
|
||||||
|
Vector3 offset;
|
||||||
|
float baseSize;
|
||||||
|
if (wideView)
|
||||||
|
{
|
||||||
|
float shift = title ? Mathf.Min(profile.Width * 0.18f, aspect * 9f) : 0f;
|
||||||
|
center = environmentRoot.position + new Vector3(-shift, profile.RoofHeight * 0.23f, -1f);
|
||||||
|
offset = OverviewOffset;
|
||||||
|
float projectedWidth = profile.Width * 0.5f + profile.Depth * 0.09f + 4.5f + shift;
|
||||||
|
baseSize = Mathf.Max(profile.Depth * 0.35f + profile.RoofHeight * 0.62f + 3f, projectedWidth / aspect);
|
||||||
|
if (viewer)
|
||||||
|
baseSize = Mathf.Max(baseSize, FittedDomeSize(profile, aspect));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
center = player.position + new Vector3(0f, 0.5f, 1.15f);
|
||||||
|
offset = FollowOffset;
|
||||||
|
baseSize = Mathf.Max(9.4f, 11.5f / aspect);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view == null)
|
||||||
|
{
|
||||||
|
dragButton = -1;
|
||||||
|
camera.transform.SetPositionAndRotation(center + offset, Quaternion.LookRotation(-offset));
|
||||||
|
camera.orthographicSize = baseSize;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float baseYaw = Mathf.Atan2(-offset.x, -offset.z) * Mathf.Rad2Deg;
|
||||||
|
float basePitch = Mathf.Atan2(offset.y, new Vector2(offset.x, offset.z).magnitude) * Mathf.Rad2Deg;
|
||||||
|
if (allowInput && Application.isFocused)
|
||||||
|
ReadInput(camera, view, baseYaw, basePitch, baseSize, wideView);
|
||||||
|
else
|
||||||
|
dragButton = -1;
|
||||||
|
|
||||||
|
Vector2 panLimit = wideView ? new Vector2(profile.Width * 0.57f, profile.Depth * 0.57f) : Vector2.one * 7f;
|
||||||
|
view.Pan.x = Mathf.Clamp(view.Pan.x, -panLimit.x, panLimit.x);
|
||||||
|
view.Pan.y = Mathf.Clamp(view.Pan.y, -panLimit.y, panLimit.y);
|
||||||
|
center += new Vector3(view.Pan.x, 0f, view.Pan.y);
|
||||||
|
|
||||||
|
float pitch = basePitch + view.PitchOffset;
|
||||||
|
Quaternion rotation = Quaternion.Euler(pitch, baseYaw + view.Yaw, 0f);
|
||||||
|
float size = baseSize * view.Zoom;
|
||||||
|
// Orthographic scale is independent of distance. Back up at shallow pitches to preserve the foreground.
|
||||||
|
float foregroundDistance = size / Mathf.Sin(pitch * Mathf.Deg2Rad) + 4f;
|
||||||
|
float distance = Mathf.Max(offset.magnitude, Mathf.Min(foregroundDistance, camera.farClipPlane * 0.48f));
|
||||||
|
camera.transform.SetPositionAndRotation(center - rotation * Vector3.forward * distance, rotation);
|
||||||
|
camera.orthographicSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float FittedDomeSize(DomeEnvironment profile, float aspect)
|
||||||
|
{
|
||||||
|
// Include the foundation and projecting airlock in the default overview framing.
|
||||||
|
float halfWidth = profile.Width * (47.6f / 86f);
|
||||||
|
float halfDepth = profile.Depth * (37.2f / 64f);
|
||||||
|
float yaw = Mathf.Atan2(OverviewOffset.x, -OverviewOffset.z);
|
||||||
|
float pitch = Mathf.Atan2(OverviewOffset.y, new Vector2(OverviewOffset.x, OverviewOffset.z).magnitude);
|
||||||
|
float horizontal = halfWidth * Mathf.Cos(yaw) + halfDepth * Mathf.Sin(yaw);
|
||||||
|
float depth = halfDepth * Mathf.Cos(yaw) + halfWidth * Mathf.Sin(yaw);
|
||||||
|
float nearEdge = depth * Mathf.Sin(pitch) + (profile.RoofHeight * 0.23f + 1.4f) * Mathf.Cos(pitch);
|
||||||
|
return Mathf.Max((horizontal + 2.5f) / aspect, nearEdge + 2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReadInput(Camera camera, View view, float baseYaw, float basePitch, float baseSize, bool wideView)
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(KeyCode.Home))
|
||||||
|
{
|
||||||
|
view.Reset();
|
||||||
|
dragButton = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 pointer = Input.mousePosition;
|
||||||
|
if (!camera.pixelRect.Contains(pointer))
|
||||||
|
{
|
||||||
|
dragButton = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float wheel = Input.mouseScrollDelta.y;
|
||||||
|
if (wheel != 0f)
|
||||||
|
{
|
||||||
|
float zoom = view.Zoom * Mathf.Pow(ZoomStep, Mathf.Clamp(wheel, -8f, 8f));
|
||||||
|
view.Zoom = Mathf.Clamp(zoom, wideView ? 0.18f : 0.42f, wideView ? 2.25f : 2.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetMouseButtonDown(2))
|
||||||
|
{
|
||||||
|
BeginDrag(2, pointer, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetMouseButtonDown(1))
|
||||||
|
{
|
||||||
|
BeginDrag(1, pointer, Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dragButton < 0 || !Input.GetMouseButton(dragButton))
|
||||||
|
{
|
||||||
|
dragButton = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 delta = pointer - lastPointer;
|
||||||
|
lastPointer = pointer;
|
||||||
|
if (panning)
|
||||||
|
{
|
||||||
|
Quaternion heading = Quaternion.Euler(0f, baseYaw + view.Yaw, 0f);
|
||||||
|
float pitch = (basePitch + view.PitchOffset) * Mathf.Deg2Rad;
|
||||||
|
float unitsPerPixel = baseSize * view.Zoom * 2f / Mathf.Max(camera.pixelHeight, 1);
|
||||||
|
Vector3 worldDelta = heading * new Vector3(delta.x, 0f, delta.y / Mathf.Sin(pitch));
|
||||||
|
view.Pan -= new Vector2(worldDelta.x, worldDelta.z) * unitsPerPixel;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float dpiScale = Mathf.Clamp(720f / Mathf.Max(camera.pixelHeight, 1), 0.45f, 1.6f);
|
||||||
|
view.Yaw = Mathf.Repeat(view.Yaw + delta.x * OrbitSensitivity * dpiScale + 180f, 360f) - 180f;
|
||||||
|
float pitch = basePitch + view.PitchOffset + delta.y * OrbitSensitivity * dpiScale;
|
||||||
|
view.PitchOffset = Mathf.Clamp(pitch, MinimumPitch, MaximumPitch) - basePitch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BeginDrag(int button, Vector2 pointer, bool pan)
|
||||||
|
{
|
||||||
|
dragButton = button;
|
||||||
|
lastPointer = pointer;
|
||||||
|
panning = pan;
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class View
|
||||||
|
{
|
||||||
|
public Vector2 Pan;
|
||||||
|
public float Yaw;
|
||||||
|
public float PitchOffset;
|
||||||
|
public float Zoom = 1f;
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
Pan = Vector2.zero;
|
||||||
|
Yaw = 0f;
|
||||||
|
PitchOffset = 0f;
|
||||||
|
Zoom = 1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/DomeShift/DomeCameraRig.cs.meta
Normal file
2
Assets/DomeShift/DomeCameraRig.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fdec7f01989e4d6a8d6713f9bafac94c
|
||||||
@@ -162,6 +162,32 @@ namespace DomeShift
|
|||||||
internal float SurfaceY(Vector2 point) => biomes.SurfaceY(point);
|
internal float SurfaceY(Vector2 point) => biomes.SurfaceY(point);
|
||||||
internal void SetCutaway(bool cutaway) => architecture.SetCutaway(cutaway);
|
internal void SetCutaway(bool cutaway) => architecture.SetCutaway(cutaway);
|
||||||
|
|
||||||
|
internal bool ApplyViewportSettings(float newWidth, float newDepth, float newRoofHeight, int newBays,
|
||||||
|
float newGlass, float newDensity, float newRelief, int newSeed)
|
||||||
|
{
|
||||||
|
newWidth = Mathf.Clamp(newWidth, 68f, 126f);
|
||||||
|
newDepth = Mathf.Clamp(newDepth, 52f, 96f);
|
||||||
|
newRoofHeight = Mathf.Clamp(newRoofHeight, 10f, 22f);
|
||||||
|
newBays = Mathf.Clamp(newBays, 4, 12);
|
||||||
|
newGlass = Mathf.Clamp(newGlass, 0.06f, 0.4f);
|
||||||
|
newDensity = Mathf.Clamp(newDensity, 0.3f, 1.5f);
|
||||||
|
newRelief = Mathf.Clamp(newRelief, 0f, 1.6f);
|
||||||
|
|
||||||
|
if (width == newWidth && depth == newDepth && roofHeight == newRoofHeight && roofBays == newBays
|
||||||
|
&& glazingOpacity == newGlass && vegetationDensity == newDensity && terrainRelief == newRelief && seed == newSeed)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
width = newWidth;
|
||||||
|
depth = newDepth;
|
||||||
|
roofHeight = newRoofHeight;
|
||||||
|
roofBays = newBays;
|
||||||
|
glazingOpacity = newGlass;
|
||||||
|
vegetationDensity = newDensity;
|
||||||
|
terrainRelief = newRelief;
|
||||||
|
seed = newSeed;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private Transform Build(bool preview)
|
private Transform Build(bool preview)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ namespace DomeShift
|
|||||||
Playing,
|
Playing,
|
||||||
Paused,
|
Paused,
|
||||||
Won,
|
Won,
|
||||||
Lost
|
Lost,
|
||||||
|
Viewer
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PlayableCharacter
|
public enum PlayableCharacter
|
||||||
@@ -21,6 +22,8 @@ namespace DomeShift
|
|||||||
[RequireComponent(typeof(DomeEnvironment))]
|
[RequireComponent(typeof(DomeEnvironment))]
|
||||||
public sealed class DomeGame : MonoBehaviour
|
public sealed class DomeGame : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
private enum RunMode { Challenge, Explore, Story }
|
||||||
|
|
||||||
private const int AllRepaired = 0b111;
|
private const int AllRepaired = 0b111;
|
||||||
private const int Airlock = 6;
|
private const int Airlock = 6;
|
||||||
private const float WalkSpeed = 8.2f;
|
private const float WalkSpeed = 8.2f;
|
||||||
@@ -55,9 +58,12 @@ namespace DomeShift
|
|||||||
Footprint(5, 0f, 0.44f, 0.44f)
|
Footprint(5, 0f, 0.44f, 0.44f)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private readonly DomeStory story = new();
|
||||||
|
private readonly DomeCameraRig cameraRig = new();
|
||||||
private DomeEnvironment environment;
|
private DomeEnvironment environment;
|
||||||
private Transform environmentRoot;
|
private Transform environmentRoot;
|
||||||
private DomeWorld world;
|
private DomeWorld world;
|
||||||
|
private DomeStoryProps storyProps;
|
||||||
private DomeHud hud;
|
private DomeHud hud;
|
||||||
private DomeAudio audioBus;
|
private DomeAudio audioBus;
|
||||||
private Camera domeCamera;
|
private Camera domeCamera;
|
||||||
@@ -67,10 +73,24 @@ namespace DomeShift
|
|||||||
private float worldTime;
|
private float worldTime;
|
||||||
private float displayTransitionUntil = -1f;
|
private float displayTransitionUntil = -1f;
|
||||||
private int nearby = -1;
|
private int nearby = -1;
|
||||||
|
private RunMode mode;
|
||||||
|
|
||||||
public GamePhase Phase { get; private set; } = GamePhase.Title;
|
public GamePhase Phase { get; private set; } = GamePhase.Title;
|
||||||
public PlayableCharacter Character { get; private set; } = PlayableCharacter.Bud;
|
public PlayableCharacter Character { get; private set; } = PlayableCharacter.Bud;
|
||||||
public bool Exploring { get; private set; }
|
public bool Exploring => mode == RunMode.Explore;
|
||||||
|
public bool InStory => mode == RunMode.Story;
|
||||||
|
public DomeEnvironment Profile => environment;
|
||||||
|
public string StoryTitle => story.Title;
|
||||||
|
public string StoryBrief => story.Brief;
|
||||||
|
public string StoryGoal => story.Goal;
|
||||||
|
public string StoryStatus => story.Status;
|
||||||
|
public float Homeostasis => story.Homeostasis;
|
||||||
|
public int StoryChapter => story.ChapterNumber;
|
||||||
|
public int StoryChapterCount => story.ChapterCount;
|
||||||
|
public int StoryDone => story.Done;
|
||||||
|
public int StoryTotal => story.Total;
|
||||||
|
public int StoryPinCount => story.PinCount;
|
||||||
|
public int StoryCarried => story.HeldPart;
|
||||||
public bool MapOpen { get; private set; }
|
public bool MapOpen { get; private set; }
|
||||||
public bool Cutaway { get; private set; }
|
public bool Cutaway { get; private set; }
|
||||||
public bool Overview { get; private set; }
|
public bool Overview { get; private set; }
|
||||||
@@ -85,11 +105,16 @@ namespace DomeShift
|
|||||||
public bool CanToggleFullscreen => !Application.isEditor;
|
public bool CanToggleFullscreen => !Application.isEditor;
|
||||||
public string Dispatch { get; private set; } = "";
|
public string Dispatch { get; private set; } = "";
|
||||||
public Vector2 MapPoint(int index) => DomeEnvironment.MapCoordinates(DomeEnvironment.Site(index));
|
public Vector2 MapPoint(int index) => DomeEnvironment.MapCoordinates(DomeEnvironment.Site(index));
|
||||||
|
public Vector2 StoryPin(int index) => DomeEnvironment.MapCoordinates(story.Pin(index).Point);
|
||||||
|
public string StoryPinName(int index) => story.Pin(index).Name;
|
||||||
|
|
||||||
public string Prompt
|
public string Prompt
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (InStory)
|
||||||
|
return story.Prompt(nearby);
|
||||||
|
|
||||||
if (nearby == -1)
|
if (nearby == -1)
|
||||||
return RepairedMask == AllRepaired ? "Head to the airlock" : "";
|
return RepairedMask == AllRepaired ? "Head to the airlock" : "";
|
||||||
|
|
||||||
@@ -112,9 +137,7 @@ namespace DomeShift
|
|||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
environment = GetComponent<DomeEnvironment>();
|
environment = GetComponent<DomeEnvironment>();
|
||||||
environmentRoot = environment.BuildForGame();
|
BuildWorld();
|
||||||
world = DomeWorld.Create(environmentRoot, environment);
|
|
||||||
world.SetCharacter(Character);
|
|
||||||
hud = new DomeHud();
|
hud = new DomeHud();
|
||||||
audioBus = gameObject.AddComponent<DomeAudio>();
|
audioBus = gameObject.AddComponent<DomeAudio>();
|
||||||
audioBus.Muted = PlayerPrefs.GetInt(MuteKey, 0) == 1;
|
audioBus.Muted = PlayerPrefs.GetInt(MuteKey, 0) == 1;
|
||||||
@@ -159,7 +182,7 @@ namespace DomeShift
|
|||||||
PlayFrame();
|
PlayFrame();
|
||||||
break;
|
break;
|
||||||
case GamePhase.Paused:
|
case GamePhase.Paused:
|
||||||
if (Exploring && Input.GetKeyDown(KeyCode.B))
|
if (Input.GetKeyDown(KeyCode.B))
|
||||||
ChooseCharacter();
|
ChooseCharacter();
|
||||||
else if (escape || enter)
|
else if (escape || enter)
|
||||||
Resume();
|
Resume();
|
||||||
@@ -171,6 +194,12 @@ namespace DomeShift
|
|||||||
else if (enter || Input.GetKeyDown(KeyCode.R))
|
else if (enter || Input.GetKeyDown(KeyCode.R))
|
||||||
Restart();
|
Restart();
|
||||||
break;
|
break;
|
||||||
|
case GamePhase.Viewer:
|
||||||
|
if (escape || Input.GetKeyDown(KeyCode.B))
|
||||||
|
ExitViewer();
|
||||||
|
else if (Input.GetKeyDown(KeyCode.V))
|
||||||
|
ToggleRoof();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameDome();
|
FrameDome();
|
||||||
@@ -192,23 +221,86 @@ namespace DomeShift
|
|||||||
|
|
||||||
public void StartShift()
|
public void StartShift()
|
||||||
{
|
{
|
||||||
EnterDome(false);
|
EnterDome(RunMode.Challenge);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartExplore()
|
public void StartExplore()
|
||||||
{
|
{
|
||||||
EnterDome(true);
|
EnterDome(RunMode.Explore);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnterDome(bool explore)
|
public void StartStory()
|
||||||
|
{
|
||||||
|
EnterDome(RunMode.Story);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartViewer()
|
||||||
|
{
|
||||||
|
if (Phase != GamePhase.Title)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ResetRun();
|
||||||
|
mode = RunMode.Challenge;
|
||||||
|
Overview = true;
|
||||||
|
SetCutaway(false);
|
||||||
|
world.SetShiftEquipmentVisible(false);
|
||||||
|
world.Player.gameObject.SetActive(false);
|
||||||
|
Phase = GamePhase.Viewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ExitViewer()
|
||||||
|
{
|
||||||
|
if (Phase == GamePhase.Viewer)
|
||||||
|
ReturnToTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyViewParameters(float width, float depth, float roofHeight, int bays,
|
||||||
|
float glass, float density, float relief, int seed)
|
||||||
|
{
|
||||||
|
if (Phase != GamePhase.Viewer || !environment.ApplyViewportSettings(width, depth, roofHeight,
|
||||||
|
bays, glass, density, relief, seed))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BuildWorld();
|
||||||
|
SetPlayerPosition(DomeEnvironment.Spawn);
|
||||||
|
world.SetShiftEquipmentVisible(false);
|
||||||
|
world.Player.gameObject.SetActive(false);
|
||||||
|
world.Tick(Vector2.zero, -1, 0, 0f);
|
||||||
|
SetCutaway(Cutaway);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetCamera()
|
||||||
|
{
|
||||||
|
cameraRig.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildWorld()
|
||||||
|
{
|
||||||
|
environmentRoot = environment.BuildForGame();
|
||||||
|
world = DomeWorld.Create(environmentRoot, environment);
|
||||||
|
world.SetCharacter(Character);
|
||||||
|
storyProps = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnterDome(RunMode newMode)
|
||||||
{
|
{
|
||||||
ResetRun();
|
ResetRun();
|
||||||
Exploring = explore;
|
mode = newMode;
|
||||||
Overview = false;
|
Overview = false;
|
||||||
SetCutaway(true);
|
SetCutaway(true);
|
||||||
Dispatch = explore
|
world.SetShiftEquipmentVisible(!InStory);
|
||||||
|
if (InStory)
|
||||||
|
{
|
||||||
|
story.Reset();
|
||||||
|
ShowStoryChapter();
|
||||||
|
Dispatch = $"{Character}, check the main airlock. Tab opens the map.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Dispatch = Exploring
|
||||||
? $"{Character}, wander the dome at your own pace. Press Tab for the map."
|
? $"{Character}, wander the dome at your own pace. Press Tab for the map."
|
||||||
: $"{Character}, match the spares on the stands to the station colors.";
|
: $"{Character}, match the spares on the stands to the station colors.";
|
||||||
|
}
|
||||||
Phase = GamePhase.Playing;
|
Phase = GamePhase.Playing;
|
||||||
audioBus.Play(DomeAudio.Cue.Start);
|
audioBus.Play(DomeAudio.Cue.Start);
|
||||||
}
|
}
|
||||||
@@ -225,19 +317,25 @@ namespace DomeShift
|
|||||||
|
|
||||||
public void ChooseCharacter()
|
public void ChooseCharacter()
|
||||||
{
|
{
|
||||||
if (Phase != GamePhase.Won && Phase != GamePhase.Lost && !(Phase == GamePhase.Paused && Exploring))
|
if (Phase != GamePhase.Won && Phase != GamePhase.Lost && Phase != GamePhase.Paused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ReturnToTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReturnToTitle()
|
||||||
|
{
|
||||||
ResetRun();
|
ResetRun();
|
||||||
Exploring = false;
|
mode = RunMode.Challenge;
|
||||||
Overview = false;
|
Overview = false;
|
||||||
|
world.SetShiftEquipmentVisible(true);
|
||||||
SetCutaway(false);
|
SetCutaway(false);
|
||||||
Phase = GamePhase.Title;
|
Phase = GamePhase.Title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
EnterDome(Exploring);
|
EnterDome(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Resume()
|
public void Resume()
|
||||||
@@ -299,7 +397,7 @@ namespace DomeShift
|
|||||||
private void Pause()
|
private void Pause()
|
||||||
{
|
{
|
||||||
Phase = GamePhase.Paused;
|
Phase = GamePhase.Paused;
|
||||||
world.Tick(Vector2.zero, Carried, RepairedMask, worldTime);
|
UpdateCrew(Vector2.zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetRun()
|
private void ResetRun()
|
||||||
@@ -311,6 +409,9 @@ namespace DomeShift
|
|||||||
worldTime = 0f;
|
worldTime = 0f;
|
||||||
MapOpen = false;
|
MapOpen = false;
|
||||||
Dispatch = "";
|
Dispatch = "";
|
||||||
|
cameraRig.Reset();
|
||||||
|
storyProps?.Hide();
|
||||||
|
world.Player.gameObject.SetActive(true);
|
||||||
SetPlayerPosition(DomeEnvironment.Spawn);
|
SetPlayerPosition(DomeEnvironment.Spawn);
|
||||||
world.Tick(Vector2.zero, Carried, RepairedMask, worldTime);
|
world.Tick(Vector2.zero, Carried, RepairedMask, worldTime);
|
||||||
}
|
}
|
||||||
@@ -322,7 +423,11 @@ namespace DomeShift
|
|||||||
else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Keypad2))
|
else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Keypad2))
|
||||||
SelectCharacter(PlayableCharacter.Doyle);
|
SelectCharacter(PlayableCharacter.Doyle);
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.X))
|
if (Input.GetKeyDown(KeyCode.S))
|
||||||
|
StartStory();
|
||||||
|
else if (Input.GetKeyDown(KeyCode.P))
|
||||||
|
StartViewer();
|
||||||
|
else if (Input.GetKeyDown(KeyCode.X))
|
||||||
StartExplore();
|
StartExplore();
|
||||||
else if (enter)
|
else if (enter)
|
||||||
StartShift();
|
StartShift();
|
||||||
@@ -336,9 +441,9 @@ namespace DomeShift
|
|||||||
if (Input.GetKeyDown(KeyCode.V)) ToggleRoof();
|
if (Input.GetKeyDown(KeyCode.V)) ToggleRoof();
|
||||||
if (Input.GetKeyDown(KeyCode.C)) ToggleOverview();
|
if (Input.GetKeyDown(KeyCode.C)) ToggleOverview();
|
||||||
|
|
||||||
if (!Exploring)
|
if (mode == RunMode.Challenge)
|
||||||
TimeLeft = Mathf.Max(0f, TimeLeft - Time.deltaTime);
|
TimeLeft = Mathf.Max(0f, TimeLeft - Time.deltaTime);
|
||||||
if (!Exploring && TimeLeft <= 0f)
|
if (mode == RunMode.Challenge && TimeLeft <= 0f)
|
||||||
{
|
{
|
||||||
Phase = GamePhase.Lost;
|
Phase = GamePhase.Lost;
|
||||||
Dispatch = "The safety timer locked out the dome.";
|
Dispatch = "The safety timer locked out the dome.";
|
||||||
@@ -351,13 +456,16 @@ namespace DomeShift
|
|||||||
Axis(KeyCode.D, KeyCode.RightArrow, KeyCode.A, KeyCode.LeftArrow),
|
Axis(KeyCode.D, KeyCode.RightArrow, KeyCode.A, KeyCode.LeftArrow),
|
||||||
Axis(KeyCode.W, KeyCode.UpArrow, KeyCode.S, KeyCode.DownArrow));
|
Axis(KeyCode.W, KeyCode.UpArrow, KeyCode.S, KeyCode.DownArrow));
|
||||||
Vector2 positionBefore = playerPosition;
|
Vector2 positionBefore = playerPosition;
|
||||||
Move(Vector2.ClampMagnitude(input, 1f) * (WalkSpeed * Mathf.Min(Time.deltaTime, 0.08f)));
|
Move(CameraRelative(input) * (WalkSpeed * Mathf.Min(Time.deltaTime, 0.08f)));
|
||||||
|
|
||||||
nearby = ClosestPoint();
|
nearby = InStory ? story.Closest(playerPosition) : ClosestPoint();
|
||||||
if (Input.GetKeyDown(KeyCode.E))
|
if (nearby >= 0 && Input.GetKeyDown(KeyCode.E))
|
||||||
{
|
{
|
||||||
|
if (InStory)
|
||||||
|
InteractWithStory();
|
||||||
|
else
|
||||||
Interact();
|
Interact();
|
||||||
nearby = ClosestPoint();
|
nearby = InStory ? story.Closest(playerPosition) : ClosestPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 displacement = playerPosition - positionBefore;
|
Vector2 displacement = playerPosition - positionBefore;
|
||||||
@@ -371,10 +479,28 @@ namespace DomeShift
|
|||||||
return forward - backward;
|
return forward - backward;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector2 CameraRelative(Vector2 input)
|
||||||
|
{
|
||||||
|
Transform view = domeCamera.transform;
|
||||||
|
Vector3 forward = Vector3.ProjectOnPlane(view.forward, Vector3.up).normalized;
|
||||||
|
Vector3 right = Vector3.ProjectOnPlane(view.right, Vector3.up).normalized;
|
||||||
|
Vector3 local = environmentRoot.InverseTransformVector(forward * input.y + right * input.x);
|
||||||
|
return new Vector2(local.x, local.z).normalized;
|
||||||
|
}
|
||||||
|
|
||||||
private void AnimateWorld(Vector2 motion)
|
private void AnimateWorld(Vector2 motion)
|
||||||
{
|
{
|
||||||
worldTime += Time.deltaTime;
|
worldTime += Time.deltaTime;
|
||||||
world.Tick(motion, Carried, RepairedMask, worldTime);
|
UpdateCrew(motion);
|
||||||
|
if (InStory)
|
||||||
|
storyProps.Animate(worldTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateCrew(Vector2 motion)
|
||||||
|
{
|
||||||
|
int carry = InStory ? story.HeldPart : Carried;
|
||||||
|
int repairs = InStory && Phase == GamePhase.Won ? AllRepaired : RepairedMask;
|
||||||
|
world.Tick(motion, carry, repairs, worldTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Move(Vector2 movement)
|
private void Move(Vector2 movement)
|
||||||
@@ -389,12 +515,15 @@ namespace DomeShift
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bool CanWalk(Vector2 position)
|
private bool CanWalk(Vector2 position)
|
||||||
|
{
|
||||||
|
if (!InStory)
|
||||||
{
|
{
|
||||||
foreach (Rect obstacle in Obstacles)
|
foreach (Rect obstacle in Obstacles)
|
||||||
{
|
{
|
||||||
if (obstacle.Contains(position))
|
if (obstacle.Contains(position))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return environment.CanWalk(position);
|
return environment.CanWalk(position);
|
||||||
}
|
}
|
||||||
@@ -493,26 +622,53 @@ namespace DomeShift
|
|||||||
audioBus.Play(DomeAudio.Cue.Repair);
|
audioBus.Play(DomeAudio.Cue.Repair);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FrameDome()
|
private void ShowStoryChapter()
|
||||||
{
|
{
|
||||||
bool title = Phase == GamePhase.Title;
|
storyProps ??= DomeStoryProps.Create(environmentRoot, environment);
|
||||||
float aspect = Mathf.Max(domeCamera.aspect, 0.1f);
|
storyProps.Hide();
|
||||||
if (title || Overview)
|
for (int i = 0; i < story.Total; i++)
|
||||||
{
|
{
|
||||||
float shift = title ? Mathf.Min(environment.Width * 0.18f, aspect * 9f) : 0f;
|
DomeStory.Task task = story.Target(i);
|
||||||
Vector3 center = environmentRoot.position + new Vector3(-shift, environment.RoofHeight * 0.23f, -1f);
|
Vector2 point = task.Point;
|
||||||
float projectedWidth = environment.Width * 0.5f + environment.Depth * 0.09f + 4.5f + shift;
|
Vector3 position = new(point.x, environment.SurfaceY(point) + 0.025f, point.y);
|
||||||
domeCamera.transform.position = center + new Vector3(15f, 67f, -79f);
|
storyProps.Show(i, task.Kind, position, DomeStory.Accent);
|
||||||
domeCamera.transform.LookAt(center);
|
}
|
||||||
domeCamera.orthographicSize = Mathf.Max(environment.Depth * 0.35f + environment.RoofHeight * 0.62f + 3f,
|
}
|
||||||
projectedWidth / aspect);
|
|
||||||
|
private void InteractWithStory()
|
||||||
|
{
|
||||||
|
DomeStory.Task task = story.Target(nearby);
|
||||||
|
StoryAction result = story.Interact(nearby, out string feedback);
|
||||||
|
Dispatch = feedback;
|
||||||
|
if (result == StoryAction.Blocked)
|
||||||
|
{
|
||||||
|
audioBus.Play(DomeAudio.Cue.Denied);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 lookAt = world.Player.position + new Vector3(0f, 0.5f, 1.15f);
|
storyProps.Complete(nearby);
|
||||||
domeCamera.transform.position = lookAt + new Vector3(0f, 16f, -20f);
|
if (result == StoryAction.ChapterFinished && story.IsLastChapter)
|
||||||
domeCamera.transform.LookAt(lookAt);
|
{
|
||||||
domeCamera.orthographicSize = Mathf.Max(9.4f, 11.5f / aspect);
|
Phase = GamePhase.Won;
|
||||||
|
audioBus.Play(DomeAudio.Cue.Won);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == StoryAction.ChapterFinished)
|
||||||
|
{
|
||||||
|
story.Advance();
|
||||||
|
ShowStoryChapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pickup = task.Kind == StoryPropKind.Supply || task.Kind == StoryPropKind.Litter;
|
||||||
|
audioBus.Play(pickup ? DomeAudio.Cue.Pickup : DomeAudio.Cue.Repair);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FrameDome()
|
||||||
|
{
|
||||||
|
bool allowInput = Phase == GamePhase.Viewer || (Phase == GamePhase.Playing && !MapOpen);
|
||||||
|
cameraRig.Frame(domeCamera, environment, environmentRoot, world.Player, Phase == GamePhase.Title,
|
||||||
|
Overview, Phase == GamePhase.Viewer, allowInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawMarkers()
|
private void DrawMarkers()
|
||||||
@@ -527,6 +683,19 @@ namespace DomeShift
|
|||||||
markerStyle.fontSize = Mathf.RoundToInt(12f * scale);
|
markerStyle.fontSize = Mathf.RoundToInt(12f * scale);
|
||||||
|
|
||||||
Color previousColor = GUI.color;
|
Color previousColor = GUI.color;
|
||||||
|
if (InStory)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < story.Total; i++)
|
||||||
|
{
|
||||||
|
if (!story.IsOpen(i) && nearby != i)
|
||||||
|
continue;
|
||||||
|
DomeStory.Task task = story.Target(i);
|
||||||
|
DrawMarker(task.Point, 1.85f, task.Name, DomeStory.Accent, nearby == i, scale);
|
||||||
|
}
|
||||||
|
GUI.color = previousColor;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < PointRanges.Length; i++)
|
for (int i = 0; i < PointRanges.Length; i++)
|
||||||
{
|
{
|
||||||
if (i == Airlock)
|
if (i == Airlock)
|
||||||
@@ -550,8 +719,12 @@ namespace DomeShift
|
|||||||
|
|
||||||
private void DrawMarker(int index, string label, Color accent, float scale)
|
private void DrawMarker(int index, string label, Color accent, float scale)
|
||||||
{
|
{
|
||||||
Vector2 point = DomeEnvironment.Site(index);
|
DrawMarker(DomeEnvironment.Site(index), MarkerHeights[index], label, accent, index == nearby, scale);
|
||||||
Vector3 worldPoint = environmentRoot.TransformPoint(new Vector3(point.x, environment.SurfaceY(point) + MarkerHeights[index], point.y));
|
}
|
||||||
|
|
||||||
|
private void DrawMarker(Vector2 point, float height, string label, Color accent, bool active, float scale)
|
||||||
|
{
|
||||||
|
Vector3 worldPoint = environmentRoot.TransformPoint(new Vector3(point.x, environment.SurfaceY(point) + height, point.y));
|
||||||
Vector3 projected = domeCamera.WorldToScreenPoint(worldPoint);
|
Vector3 projected = domeCamera.WorldToScreenPoint(worldPoint);
|
||||||
if (projected.z <= 0f || projected.x < 2f || projected.x > Screen.width - 2f
|
if (projected.z <= 0f || projected.x < 2f || projected.x > Screen.width - 2f
|
||||||
|| projected.y < 2f || projected.y > Screen.height - 2f)
|
|| projected.y < 2f || projected.y > Screen.height - 2f)
|
||||||
@@ -559,7 +732,6 @@ namespace DomeShift
|
|||||||
float width = Mathf.Max(52f, label.Length * 7 + 20f) * scale;
|
float width = Mathf.Max(52f, label.Length * 7 + 20f) * scale;
|
||||||
Rect rect = new(projected.x - width * 0.5f, Screen.height - projected.y - 9f * scale, width, 20f * scale);
|
Rect rect = new(projected.x - width * 0.5f, Screen.height - projected.y - 9f * scale, width, 20f * scale);
|
||||||
|
|
||||||
bool active = index == nearby;
|
|
||||||
GUI.color = active ? accent : new Color32(27, 39, 49, 235);
|
GUI.color = active ? accent : new Color32(27, 39, 49, 235);
|
||||||
GUI.DrawTexture(rect, Texture2D.whiteTexture);
|
GUI.DrawTexture(rect, Texture2D.whiteTexture);
|
||||||
GUI.color = accent;
|
GUI.color = accent;
|
||||||
|
|||||||
@@ -45,17 +45,24 @@ namespace DomeShift
|
|||||||
private readonly GUIStyle item = Style(16, FontStyle.Bold);
|
private readonly GUIStyle item = Style(16, FontStyle.Bold);
|
||||||
private readonly GUIStyle key = Style(12, FontStyle.Bold, TextAnchor.MiddleCenter);
|
private readonly GUIStyle key = Style(12, FontStyle.Bold, TextAnchor.MiddleCenter);
|
||||||
private readonly GUIStyle time = Style(31, FontStyle.Bold, TextAnchor.MiddleRight);
|
private readonly GUIStyle time = Style(31, FontStyle.Bold, TextAnchor.MiddleRight);
|
||||||
|
private readonly GUIStyle percentage = Style(24, FontStyle.Bold, TextAnchor.MiddleRight);
|
||||||
private readonly GUIStyle title = Style(78, FontStyle.Bold);
|
private readonly GUIStyle title = Style(78, FontStyle.Bold);
|
||||||
private readonly GUIStyle headline = Style(42, FontStyle.Bold);
|
private readonly GUIStyle headline = Style(42, FontStyle.Bold);
|
||||||
private readonly GUIStyle section = Style(22, FontStyle.Bold);
|
private readonly GUIStyle section = Style(22, FontStyle.Bold);
|
||||||
private readonly GUIStyle longLocation = Style(18, FontStyle.Bold);
|
private readonly GUIStyle longLocation = Style(18, FontStyle.Bold);
|
||||||
private readonly GUIStyle regionLabel = Style(16, FontStyle.Bold, TextAnchor.MiddleCenter);
|
private readonly GUIStyle regionLabel = Style(16, FontStyle.Bold, TextAnchor.MiddleCenter);
|
||||||
private readonly GUIStyle longRegionLabel = Style(14, FontStyle.Bold, TextAnchor.MiddleCenter);
|
private readonly GUIStyle longRegionLabel = Style(14, FontStyle.Bold, TextAnchor.MiddleCenter);
|
||||||
|
private readonly GUIStyle chapterTitle = Style(22, FontStyle.Bold, wraps: true);
|
||||||
|
private readonly GUIStyle storyHeadline = Style(34, FontStyle.Bold, wraps: true);
|
||||||
private readonly GUIStyle prompt = Style(16, FontStyle.Bold, TextAnchor.MiddleCenter, true);
|
private readonly GUIStyle prompt = Style(16, FontStyle.Bold, TextAnchor.MiddleCenter, true);
|
||||||
private readonly GUIStyle fine = Style(13, wraps: true);
|
private readonly GUIStyle fine = Style(13, wraps: true);
|
||||||
|
private GUIStyle seedInput;
|
||||||
|
|
||||||
private int lastSeconds = -1;
|
private int lastSeconds = -1;
|
||||||
private string clockText;
|
private string clockText;
|
||||||
|
private bool viewingDome;
|
||||||
|
private bool parametersOpen;
|
||||||
|
private ViewParameters viewParameters;
|
||||||
|
|
||||||
public void Draw(DomeGame game)
|
public void Draw(DomeGame game)
|
||||||
{
|
{
|
||||||
@@ -70,6 +77,13 @@ namespace DomeShift
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (game.Phase == GamePhase.Viewer)
|
||||||
|
{
|
||||||
|
DrawViewer(game, width, height);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
viewingDome = false;
|
||||||
if (game.Phase == GamePhase.Title)
|
if (game.Phase == GamePhase.Title)
|
||||||
{
|
{
|
||||||
DrawTitle(game, width, height);
|
DrawTitle(game, width, height);
|
||||||
@@ -109,31 +123,159 @@ namespace DomeShift
|
|||||||
Label(new Rect(left, top + 189, 350, 43),
|
Label(new Rect(left, top + 189, 350, 43),
|
||||||
"You came looking for a bathroom. The greenhouse locked you in.", body, Ink);
|
"You came looking for a bathroom. The greenhouse locked you in.", body, Ink);
|
||||||
Label(new Rect(left, top + 232, 371, 57),
|
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);
|
"See Bud and Doyle through their stay, explore all ten regions, or take a closer look at the dome itself.", body, MutedInk);
|
||||||
|
|
||||||
Label(new Rect(left, top + 299, 215, 19), "CHOOSE A CHARACTER", tag, Amber);
|
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);
|
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, top + 324, 181, 58), PlayableCharacter.Bud);
|
||||||
DrawCharacterOption(game, new Rect(left + 194, top + 324, 181, 58), PlayableCharacter.Doyle);
|
DrawCharacterOption(game, new Rect(left + 194, top + 324, 181, 58), PlayableCharacter.Doyle);
|
||||||
|
|
||||||
if (ActionButton(new Rect(left, top + 397, 375, 52), "EXPLORE DOME", "X"))
|
if (ActionButton(new Rect(left, top + 397, 375, 50), "STORY MODE", "S"))
|
||||||
|
game.StartStory();
|
||||||
|
if (SecondaryButton(new Rect(left, top + 459, 181, 41), "Explore Dome", "X"))
|
||||||
game.StartExplore();
|
game.StartExplore();
|
||||||
if (SecondaryButton(new Rect(left, top + 462, 375, 42), "Start timed shift", "ENTER", 63))
|
if (SecondaryButton(new Rect(left + 194, top + 459, 181, 41), "Dome View", "P"))
|
||||||
|
game.StartViewer();
|
||||||
|
if (SecondaryButton(new Rect(left, top + 512, 375, 38), "Timed repair shift", "ENTER", 63))
|
||||||
game.StartShift();
|
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)
|
if (game.CanToggleFullscreen)
|
||||||
DrawFullscreenButton(game, new Rect(width - 325, 24, 167, 34));
|
DrawFullscreenButton(game, new Rect(width - 325, 24, 167, 34));
|
||||||
DrawSoundButton(game, new Rect(width - 150, 24, 126, 34));
|
DrawSoundButton(game, new Rect(width - 150, 24, 126, 34));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawViewer(DomeGame game, float width, float height)
|
||||||
|
{
|
||||||
|
if (!viewingDome)
|
||||||
|
{
|
||||||
|
viewParameters = new ViewParameters(game.Profile);
|
||||||
|
parametersOpen = true;
|
||||||
|
viewingDome = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.H)
|
||||||
|
{
|
||||||
|
parametersOpen = !parametersOpen;
|
||||||
|
GUIUtility.keyboardControl = 0;
|
||||||
|
Event.current.Use();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NavigationButton(new Rect(24, 24, 165, 33), parametersOpen ? "Hide parameters" : "Show parameters", "H", 24, parametersOpen))
|
||||||
|
parametersOpen = !parametersOpen;
|
||||||
|
|
||||||
|
Rect heading = new Rect(197, 24, 130, 33);
|
||||||
|
Fill(heading, Panel);
|
||||||
|
Stroke(heading, Border);
|
||||||
|
Label(heading, "DOME VIEW", key, Mint);
|
||||||
|
|
||||||
|
if (NavigationButton(new Rect(width - 490, 24, 148, 33), game.Cutaway ? "Roof cutaway" : "Roof visible", "V", 24, game.Cutaway))
|
||||||
|
game.ToggleRoof();
|
||||||
|
if (NavigationButton(new Rect(width - 334, 24, 154, 33), "Recenter", "HOME", 48, false))
|
||||||
|
game.ResetCamera();
|
||||||
|
if (NavigationButton(new Rect(width - 172, 24, 148, 33), "Back to title", "ESC", 33, false))
|
||||||
|
{
|
||||||
|
game.ExitViewer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parametersOpen)
|
||||||
|
DrawViewerParameters(game, new Rect(24, 68, 272, 466));
|
||||||
|
|
||||||
|
Rect camera = new Rect(width * 0.5f - 201, height - 59, 402, 35);
|
||||||
|
DrawPanel(camera);
|
||||||
|
DrawCameraHint(camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawViewerParameters(DomeGame game, Rect card)
|
||||||
|
{
|
||||||
|
DrawPanel(card);
|
||||||
|
Fill(new Rect(card.x, card.y, 3, card.height), Mint);
|
||||||
|
Label(new Rect(card.x + 16, card.y + 12, card.width - 32, 28), "Model parameters", section, Ink);
|
||||||
|
|
||||||
|
Rect first = new Rect(card.x + 16, card.y + 52, card.width - 32, 35);
|
||||||
|
viewParameters.Width = DrawSlider(first, "Width", viewParameters.Width, 68, 126, .1f, "0.0");
|
||||||
|
first.y += 43;
|
||||||
|
viewParameters.Depth = DrawSlider(first, "Depth", viewParameters.Depth, 52, 96, .1f, "0.0");
|
||||||
|
first.y += 43;
|
||||||
|
viewParameters.Height = DrawSlider(first, "Roof height", viewParameters.Height, 10, 22, .1f, "0.0");
|
||||||
|
first.y += 43;
|
||||||
|
viewParameters.Bays = Mathf.RoundToInt(DrawSlider(first, "Roof bays", viewParameters.Bays, 4, 12, 1, "0"));
|
||||||
|
first.y += 43;
|
||||||
|
viewParameters.Glass = DrawSlider(first, "Glass opacity", viewParameters.Glass, .06f, .4f, .01f, "0%");
|
||||||
|
first.y += 43;
|
||||||
|
viewParameters.Vegetation = DrawSlider(first, "Vegetation density", viewParameters.Vegetation, .3f, 1.5f, .01f, "0%");
|
||||||
|
first.y += 43;
|
||||||
|
viewParameters.Relief = DrawSlider(first, "Terrain relief", viewParameters.Relief, 0, 1.6f, .01f, "0%");
|
||||||
|
|
||||||
|
seedInput ??= new GUIStyle(GUI.skin.textField) { alignment = TextAnchor.MiddleRight, fontSize = 13 };
|
||||||
|
Rect seed = new Rect(card.xMax - 116, card.y + 361, 100, 28);
|
||||||
|
Label(new Rect(card.x + 16, seed.y, 114, seed.height), "Scene seed", fine, Ink);
|
||||||
|
viewParameters.Seed = GUI.TextField(seed, viewParameters.Seed, 11, seedInput);
|
||||||
|
bool validSeed = int.TryParse(viewParameters.Seed, out int seedValue);
|
||||||
|
if (!validSeed)
|
||||||
|
Stroke(seed, Alarm);
|
||||||
|
|
||||||
|
Rect apply = new Rect(card.x + 16, card.y + 408, card.width - 32, 42);
|
||||||
|
if (ActionButton(apply, validSeed ? "APPLY CHANGES" : "ENTER A VALID SEED", null, validSeed && viewParameters.DiffersFrom(game.Profile, seedValue)))
|
||||||
|
{
|
||||||
|
game.ApplyViewParameters(viewParameters.Width, viewParameters.Depth, viewParameters.Height, viewParameters.Bays,
|
||||||
|
viewParameters.Glass, viewParameters.Vegetation, viewParameters.Relief, seedValue);
|
||||||
|
viewParameters = new ViewParameters(game.Profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float DrawSlider(Rect row, string name, float value, float min, float max, float step, string format)
|
||||||
|
{
|
||||||
|
Label(new Rect(row.x, row.y, row.width - 67, 16), name, fine, Ink);
|
||||||
|
Label(new Rect(row.xMax - 64, row.y, 64, 16), value.ToString(format), tagRight, Mint);
|
||||||
|
float next = GUI.HorizontalSlider(new Rect(row.x, row.y + 18, row.width, 17), value, min, max);
|
||||||
|
return Mathf.Approximately(next, value) ? value : Mathf.Clamp(Mathf.Round(next / step) * step, min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct ViewParameters
|
||||||
|
{
|
||||||
|
public float Width;
|
||||||
|
public float Depth;
|
||||||
|
public float Height;
|
||||||
|
public int Bays;
|
||||||
|
public float Glass;
|
||||||
|
public float Vegetation;
|
||||||
|
public float Relief;
|
||||||
|
public string Seed;
|
||||||
|
|
||||||
|
public ViewParameters(DomeEnvironment profile)
|
||||||
|
{
|
||||||
|
Width = profile.Width;
|
||||||
|
Depth = profile.Depth;
|
||||||
|
Height = profile.RoofHeight;
|
||||||
|
Bays = profile.RoofBays;
|
||||||
|
Glass = profile.GlazingOpacity;
|
||||||
|
Vegetation = profile.VegetationDensity;
|
||||||
|
Relief = profile.TerrainRelief;
|
||||||
|
Seed = profile.Seed.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DiffersFrom(DomeEnvironment profile, int seed)
|
||||||
|
{
|
||||||
|
return !Mathf.Approximately(Width, profile.Width)
|
||||||
|
|| !Mathf.Approximately(Depth, profile.Depth)
|
||||||
|
|| !Mathf.Approximately(Height, profile.RoofHeight)
|
||||||
|
|| Bays != profile.RoofBays
|
||||||
|
|| !Mathf.Approximately(Glass, profile.GlazingOpacity)
|
||||||
|
|| !Mathf.Approximately(Vegetation, profile.VegetationDensity)
|
||||||
|
|| !Mathf.Approximately(Relief, profile.TerrainRelief)
|
||||||
|
|| seed != profile.Seed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawGameplay(DomeGame game, float width, float height)
|
private void DrawGameplay(DomeGame game, float width, float height)
|
||||||
{
|
{
|
||||||
if (game.Exploring)
|
if (game.InStory)
|
||||||
|
{
|
||||||
|
DrawStoryChapter(new Rect(24, 24, 311, 222), game);
|
||||||
|
DrawHomeostasis(new Rect(width - 231, 24, 207, 82), game.Homeostasis);
|
||||||
|
}
|
||||||
|
else if (game.Exploring)
|
||||||
{
|
{
|
||||||
Rect location = new Rect(24, 24, 252, 75);
|
Rect location = new Rect(24, 24, 252, 75);
|
||||||
DrawPanel(location);
|
DrawPanel(location);
|
||||||
@@ -156,22 +298,58 @@ namespace DomeShift
|
|||||||
Rect radio = new Rect(24, bottom - 64, 326, 64);
|
Rect radio = new Rect(24, bottom - 64, 326, 64);
|
||||||
Rect pocket = new Rect(width - 217, bottom - 64, 193, 64);
|
Rect pocket = new Rect(width - 217, bottom - 64, 193, 64);
|
||||||
if (!string.IsNullOrWhiteSpace(game.Dispatch))
|
if (!string.IsNullOrWhiteSpace(game.Dispatch))
|
||||||
DrawRadio(radio, game.Dispatch);
|
DrawRadio(radio, game.Dispatch, game.InStory ? "STORY UPDATE" : "DISPATCH");
|
||||||
if (!game.Exploring || game.Carried >= 0)
|
int carried = game.InStory ? game.StoryCarried : game.Carried;
|
||||||
DrawPocket(pocket, game.Carried, game.Character);
|
if (carried >= 0 || (!game.Exploring && !game.InStory))
|
||||||
|
DrawPocket(pocket, carried, game.Character, game.InStory);
|
||||||
|
|
||||||
float center = width * 0.5f;
|
float center = width * 0.5f;
|
||||||
if (!string.IsNullOrWhiteSpace(game.Prompt))
|
if (!string.IsNullOrWhiteSpace(game.Prompt))
|
||||||
{
|
{
|
||||||
Rect cue = new Rect(center - 184, bottom - 64, 368, 36);
|
Rect cue = new Rect(center - 184, bottom - 86, 368, 36);
|
||||||
DrawPanel(cue);
|
DrawPanel(cue);
|
||||||
Fill(new Rect(cue.x, cue.y, 3, cue.height), Amber);
|
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);
|
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);
|
Rect controls = new Rect(center - 195, bottom - 43, 390, 43);
|
||||||
Fill(controls, Panel);
|
Fill(controls, Panel);
|
||||||
Label(controls, "WASD / Arrows Move E Use Esc Pause M Sound", key, MutedInk);
|
Label(new Rect(controls.x, controls.y + 2, controls.width, 19), "WASD / Arrows Move E Use Esc Pause M Sound", key, Ink);
|
||||||
|
DrawCameraHint(new Rect(controls.x, controls.y + 21, controls.width, 19));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawStoryChapter(Rect rect, DomeGame game)
|
||||||
|
{
|
||||||
|
DrawPanel(rect);
|
||||||
|
Fill(new Rect(rect.x, rect.y, 3, rect.height), Amber);
|
||||||
|
float left = rect.x + 15;
|
||||||
|
float content = rect.width - 30;
|
||||||
|
Label(new Rect(left, rect.y + 10, content, 20), $"CHAPTER {game.StoryChapter} OF {game.StoryChapterCount}", tag, Amber);
|
||||||
|
Label(new Rect(left, rect.y + 33, content, 29), game.StoryTitle, chapterTitle, Ink);
|
||||||
|
Label(new Rect(left, rect.y + 64, content, 18), game.StoryStatus, tag, MutedInk);
|
||||||
|
Label(new Rect(left, rect.y + 82, content, 68), game.StoryBrief, fine, Ink);
|
||||||
|
Fill(new Rect(left, rect.y + 156, content, 1), Border);
|
||||||
|
Label(new Rect(left, rect.y + 162, content - 60, 18), "CURRENT OBJECTIVE", tag, Amber);
|
||||||
|
Label(new Rect(rect.xMax - 67, rect.y + 162, 52, 18), $"{game.StoryDone} / {game.StoryTotal}", tagRight, Ink);
|
||||||
|
Label(new Rect(left, rect.y + 181, content, 36), game.StoryGoal, fine, Ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawHomeostasis(Rect rect, float homeostasis)
|
||||||
|
{
|
||||||
|
DrawPanel(rect);
|
||||||
|
float amount = Mathf.Clamp01(homeostasis);
|
||||||
|
Color color = amount < 0.4f ? Alarm : amount < 0.7f ? Amber : Mint;
|
||||||
|
Label(new Rect(rect.x + 13, rect.y + 14, 112, 36), "HOMEOSTASIS", tag, MutedInk);
|
||||||
|
Label(new Rect(rect.xMax - 84, rect.y + 10, 71, 43), $"{amount:0%}", percentage, color);
|
||||||
|
|
||||||
|
Rect meter = new Rect(rect.x + 13, rect.yMax - 20, rect.width - 26, 6);
|
||||||
|
Fill(meter, Inset);
|
||||||
|
Fill(new Rect(meter.x, meter.y, meter.width * amount, meter.height), color);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawCameraHint(Rect rect)
|
||||||
|
{
|
||||||
|
Label(rect, "RMB Orbit Shift+RMB Pan Wheel Zoom Home Reset", key, MutedInk);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawNavigation(DomeGame game, float width)
|
private void DrawNavigation(DomeGame game, float width)
|
||||||
@@ -214,7 +392,9 @@ namespace DomeShift
|
|||||||
DrawMapCorridor(floor, -11, false);
|
DrawMapCorridor(floor, -11, false);
|
||||||
|
|
||||||
DrawNorthArrow(card.x + 37, floor.y + 7);
|
DrawNorthArrow(card.x + 37, floor.y + 7);
|
||||||
if (!game.Exploring)
|
if (game.InStory)
|
||||||
|
DrawStoryPins(floor, game);
|
||||||
|
else if (!game.Exploring)
|
||||||
DrawChallengePins(floor, game);
|
DrawChallengePins(floor, game);
|
||||||
|
|
||||||
Vector2 player = CanvasPoint(floor, game.MapPosition);
|
Vector2 player = CanvasPoint(floor, game.MapPosition);
|
||||||
@@ -229,7 +409,12 @@ namespace DomeShift
|
|||||||
Fill(new Rect(card.x + 212, legendY + 10, 13, 2), MapCorridor);
|
Fill(new Rect(card.x + 212, legendY + 10, 13, 2), MapCorridor);
|
||||||
Label(new Rect(card.x + 233, legendY, 92, 24), "Corridor", fine, MutedInk);
|
Label(new Rect(card.x + 233, legendY, 92, 24), "Corridor", fine, MutedInk);
|
||||||
|
|
||||||
if (!game.Exploring)
|
if (game.InStory)
|
||||||
|
{
|
||||||
|
DrawMapPin(new Vector2(card.x + 331, legendY + 12), Amber, PinKind.Station);
|
||||||
|
Label(new Rect(card.x + 346, legendY, 160, 24), "Story objective", fine, MutedInk);
|
||||||
|
}
|
||||||
|
else if (!game.Exploring)
|
||||||
{
|
{
|
||||||
DrawMapPin(new Vector2(card.x + 331, legendY + 12), Ink, PinKind.Station);
|
DrawMapPin(new Vector2(card.x + 331, legendY + 12), Ink, PinKind.Station);
|
||||||
Label(new Rect(card.x + 346, legendY, 84, 24), "Station", fine, MutedInk);
|
Label(new Rect(card.x + 346, legendY, 84, 24), "Station", fine, MutedInk);
|
||||||
@@ -316,6 +501,27 @@ namespace DomeShift
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawStoryPins(Rect floor, DomeGame game)
|
||||||
|
{
|
||||||
|
const float labelWidth = 166f;
|
||||||
|
const float labelHeight = 29f;
|
||||||
|
for (int index = 0; index < game.StoryPinCount; index++)
|
||||||
|
{
|
||||||
|
Vector2 target = CanvasPoint(floor, game.StoryPin(index));
|
||||||
|
DrawMapPin(target, Amber, PinKind.Station);
|
||||||
|
|
||||||
|
float preferredX = target.x + 9;
|
||||||
|
if (preferredX + labelWidth > floor.xMax)
|
||||||
|
preferredX = target.x - labelWidth - 9;
|
||||||
|
float y = target.y + (index % 2 == 0 ? -labelHeight - 6 : 7);
|
||||||
|
Rect label = new Rect(Mathf.Clamp(preferredX, floor.xMin + 3, floor.xMax - labelWidth - 3),
|
||||||
|
Mathf.Clamp(y, floor.yMin + 3, floor.yMax - labelHeight - 3), labelWidth, labelHeight);
|
||||||
|
Fill(label, Panel);
|
||||||
|
Fill(new Rect(label.x, label.y, 2, label.height), Amber);
|
||||||
|
Label(new Rect(label.x + 7, label.y, label.width - 14, label.height), game.StoryPinName(index), fine, Amber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void DrawMapPin(Vector2 point, Color color, PinKind kind)
|
private static void DrawMapPin(Vector2 point, Color color, PinKind kind)
|
||||||
{
|
{
|
||||||
Rect square = new Rect(point.x - 5, point.y - 5, 10, 10);
|
Rect square = new Rect(point.x - 5, point.y - 5, 10, 10);
|
||||||
@@ -412,15 +618,15 @@ namespace DomeShift
|
|||||||
Fill(new Rect(meter.x, meter.y, meter.width * ratio, meter.height), color);
|
Fill(new Rect(meter.x, meter.y, meter.width * ratio, meter.height), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawRadio(Rect rect, string message)
|
private void DrawRadio(Rect rect, string message, string channel)
|
||||||
{
|
{
|
||||||
DrawPanel(rect);
|
DrawPanel(rect);
|
||||||
Fill(new Rect(rect.x + 14, rect.y + 15, 6, 6), Mint);
|
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 + 27, rect.y + 9, rect.width - 39, 18), channel, tag, Mint);
|
||||||
Label(new Rect(rect.x + 14, rect.y + 26, rect.width - 28, 30), message, fine, Ink);
|
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)
|
private void DrawPocket(Rect rect, int carried, PlayableCharacter character, bool inStory)
|
||||||
{
|
{
|
||||||
DrawPanel(rect);
|
DrawPanel(rect);
|
||||||
Label(new Rect(rect.x + 14, rect.y + 9, rect.width - 28, 18),
|
Label(new Rect(rect.x + 14, rect.y + 9, rect.width - 28, 18),
|
||||||
@@ -428,8 +634,9 @@ namespace DomeShift
|
|||||||
bool occupied = carried >= 0 && carried < Supplies.Length;
|
bool occupied = carried >= 0 && carried < Supplies.Length;
|
||||||
if (occupied)
|
if (occupied)
|
||||||
DrawStationIcon(rect.x + 15, rect.y + 35, carried, StationColors[carried]);
|
DrawStationIcon(rect.x + 15, rect.y + 35, carried, StationColors[carried]);
|
||||||
|
string part = occupied ? (inStory && carried == 2 ? "Seed tray" : Supplies[carried]) : "Empty";
|
||||||
Label(new Rect(rect.x + (occupied ? 39 : 14), rect.y + 27, rect.width - 49, 30),
|
Label(new Rect(rect.x + (occupied ? 39 : 14), rect.y + 27, rect.width - 49, 30),
|
||||||
occupied ? Supplies[carried] : "Empty", item, occupied ? Ink : MutedInk);
|
part, item, occupied ? Ink : MutedInk);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawShiftCard(DomeGame game, float width, float height)
|
private void DrawShiftCard(DomeGame game, float width, float height)
|
||||||
@@ -437,23 +644,32 @@ namespace DomeShift
|
|||||||
Fill(new Rect(0, 0, width, height), Overlay);
|
Fill(new Rect(0, 0, width, height), Overlay);
|
||||||
bool won = game.Phase == GamePhase.Won;
|
bool won = game.Phase == GamePhase.Won;
|
||||||
bool paused = game.Phase == GamePhase.Paused;
|
bool paused = game.Phase == GamePhase.Paused;
|
||||||
bool showReturn = !paused || game.Exploring;
|
const float cardHeight = 352;
|
||||||
float cardHeight = showReturn ? 352 : 294;
|
|
||||||
Rect card = new Rect((width - 434) * 0.5f, (height - cardHeight) * 0.5f, 434, cardHeight);
|
Rect card = new Rect((width - 434) * 0.5f, (height - cardHeight) * 0.5f, 434, cardHeight);
|
||||||
DrawPanel(card);
|
DrawPanel(card);
|
||||||
Color accent = won ? Mint : paused ? Amber : Alarm;
|
Color accent = won ? Mint : paused ? Amber : Alarm;
|
||||||
Fill(new Rect(card.x, card.y, card.width, 4), accent);
|
Fill(new Rect(card.x, card.y, card.width, 4), accent);
|
||||||
|
|
||||||
float left = card.x + 26;
|
float left = card.x + 26;
|
||||||
Label(new Rect(left, card.y + 23, 300, 20), paused ? "SHIFT CONTROL" : "SHIFT REPORT", tag, accent);
|
string report = game.InStory ? (paused ? "STORY PAUSED" : "STORY REPORT") : paused ? "SHIFT CONTROL" : "SHIFT REPORT";
|
||||||
|
Label(new Rect(left, card.y + 23, 300, 20), report, tag, accent);
|
||||||
string heading = paused ? "Taking a break?" : won ? "You made it out." : "Lockdown.";
|
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 (game.InStory && !paused)
|
||||||
|
heading = won ? "Balance restored." : "Balance disrupted.";
|
||||||
|
Label(new Rect(left, card.y + 46, 380, 58), heading, game.InStory ? storyHeadline : headline, Ink);
|
||||||
|
|
||||||
if (paused)
|
if (paused)
|
||||||
{
|
{
|
||||||
string detail = game.Exploring ? DomeEnvironment.RegionName(game.CurrentRegion) : "The shift clock is paused.";
|
string detail = game.InStory ? game.StoryTitle
|
||||||
|
: game.Exploring ? DomeEnvironment.RegionName(game.CurrentRegion)
|
||||||
|
: "The shift clock is paused.";
|
||||||
Label(new Rect(left, card.y + 106, 380, 48), detail, body, MutedInk);
|
Label(new Rect(left, card.y + 106, 380, 48), detail, body, MutedInk);
|
||||||
}
|
}
|
||||||
|
else if (game.InStory)
|
||||||
|
{
|
||||||
|
DrawStat(new Rect(left, card.y + 113, 187, 63), "CHAPTER", $"{game.StoryChapter} / {game.StoryChapterCount}");
|
||||||
|
DrawStat(new Rect(left + 195, card.y + 113, 187, 63), "HOMEOSTASIS", $"{game.Homeostasis:0%}");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawStat(new Rect(left, card.y + 113, 187, 63), "STATIONS ONLINE", Progress[CountRepairs(game.RepairedMask)]);
|
DrawStat(new Rect(left, card.y + 113, 187, 63), "STATIONS ONLINE", Progress[CountRepairs(game.RepairedMask)]);
|
||||||
@@ -461,7 +677,9 @@ namespace DomeShift
|
|||||||
}
|
}
|
||||||
|
|
||||||
string retry = game.Character == PlayableCharacter.Bud ? "RETRY AS BUD" : "RETRY AS DOYLE";
|
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"))
|
string primary = game.InStory ? (paused ? "RESUME STORY" : won ? "PLAY STORY AGAIN" : "RETRY STORY")
|
||||||
|
: paused ? (game.Exploring ? "RESUME EXPLORING" : "RESUME SHIFT") : retry;
|
||||||
|
if (ActionButton(new Rect(left, card.y + 198, 382, 50), primary, "ENTER"))
|
||||||
{
|
{
|
||||||
if (paused)
|
if (paused)
|
||||||
game.Resume();
|
game.Resume();
|
||||||
@@ -469,11 +687,11 @@ namespace DomeShift
|
|||||||
game.Restart();
|
game.Restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showReturn && SecondaryButton(new Rect(left, card.y + 261, 382, 42), paused ? "Return to title" : "Change character", "B"))
|
if (SecondaryButton(new Rect(left, card.y + 261, 382, 42), paused || game.InStory ? "Return to title" : "Change character", "B"))
|
||||||
game.ChooseCharacter();
|
game.ChooseCharacter();
|
||||||
|
|
||||||
bool showFullscreen = paused && game.CanToggleFullscreen;
|
bool showFullscreen = paused && game.CanToggleFullscreen;
|
||||||
Label(new Rect(left, card.yMax - 38, showFullscreen ? 90 : 226, 24), paused ? "ESC Resume" : "R Retry shift", tag, MutedInk);
|
Label(new Rect(left, card.yMax - 38, showFullscreen ? 90 : 226, 24), paused ? "ESC Resume" : "R Replay", tag, MutedInk);
|
||||||
if (showFullscreen)
|
if (showFullscreen)
|
||||||
DrawFullscreenButton(game, new Rect(left + 94, card.yMax - 39, 154, 25));
|
DrawFullscreenButton(game, new Rect(left + 94, card.yMax - 39, 154, 25));
|
||||||
DrawSoundButton(game, new Rect(card.xMax - 151, card.yMax - 39, 125, 25));
|
DrawSoundButton(game, new Rect(card.xMax - 151, card.yMax - 39, 125, 25));
|
||||||
@@ -549,14 +767,16 @@ namespace DomeShift
|
|||||||
game.ToggleFullscreen();
|
game.ToggleFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ActionButton(Rect rect, string text, string binding)
|
private bool ActionButton(Rect rect, string text, string binding, bool enabled = true)
|
||||||
{
|
{
|
||||||
bool hovered = rect.Contains(Event.current.mousePosition);
|
bool hovered = rect.Contains(Event.current.mousePosition);
|
||||||
Fill(new Rect(rect.x, rect.y + 3, rect.width, rect.height), Shadow);
|
Fill(new Rect(rect.x, rect.y + 3, rect.width, rect.height), Shadow);
|
||||||
Fill(rect, hovered ? Ink : Mint);
|
Fill(rect, enabled ? hovered ? Ink : Mint : Inset);
|
||||||
Label(new Rect(rect.x + 16, rect.y, rect.width - 102, rect.height), text, item, Panel);
|
float reservedWidth = binding == null ? 32 : 102;
|
||||||
|
Label(new Rect(rect.x + 16, rect.y, rect.width - reservedWidth, rect.height), text, item, enabled ? Panel : MutedInk);
|
||||||
|
if (binding != null)
|
||||||
DrawKey(new Rect(rect.xMax - 76, rect.y + 12, 63, rect.height - 24), binding, Panel, Inset, Ink);
|
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);
|
return enabled && GUI.Button(rect, GUIContent.none, GUIStyle.none);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SecondaryButton(Rect rect, string text, string binding, float bindingWidth = 24)
|
private bool SecondaryButton(Rect rect, string text, string binding, float bindingWidth = 24)
|
||||||
@@ -564,7 +784,7 @@ namespace DomeShift
|
|||||||
bool hovered = rect.Contains(Event.current.mousePosition);
|
bool hovered = rect.Contains(Event.current.mousePosition);
|
||||||
Fill(rect, hovered ? Border : Inset);
|
Fill(rect, hovered ? Border : Inset);
|
||||||
Stroke(rect, Border);
|
Stroke(rect, Border);
|
||||||
Label(new Rect(rect.x + 16, rect.y, rect.width - bindingWidth - 44, rect.height), text, item, Ink);
|
Label(new Rect(rect.x + 16, rect.y, rect.width - bindingWidth - 39, rect.height), text, item, Ink);
|
||||||
DrawKey(new Rect(rect.xMax - bindingWidth - 13, rect.center.y - 12, bindingWidth, 24), binding, Inset, Border, 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);
|
return GUI.Button(rect, GUIContent.none, GUIStyle.none);
|
||||||
}
|
}
|
||||||
@@ -579,12 +799,6 @@ namespace DomeShift
|
|||||||
return GUI.Button(rect, GUIContent.none, GUIStyle.none);
|
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)
|
private void DrawKey(Rect rect, string text, Color background, Color edge, Color ink)
|
||||||
{
|
{
|
||||||
Fill(rect, background);
|
Fill(rect, background);
|
||||||
|
|||||||
237
Assets/DomeShift/DomeStory.cs
Normal file
237
Assets/DomeShift/DomeStory.cs
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DomeShift
|
||||||
|
{
|
||||||
|
internal enum StoryAction
|
||||||
|
{
|
||||||
|
Blocked,
|
||||||
|
Completed,
|
||||||
|
ChapterFinished
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class DomeStory
|
||||||
|
{
|
||||||
|
internal const float InteractionRange = 2.35f;
|
||||||
|
internal static readonly Color Accent = new Color32(255, 194, 110, 255);
|
||||||
|
|
||||||
|
private static readonly Chapter[] Chapters =
|
||||||
|
{
|
||||||
|
new("Locked In", "Day 1",
|
||||||
|
"Bud and Doyle mistook the dome for a mall. The airlock has sealed, and their detour left smoke drifting through the rainforest.",
|
||||||
|
"Check the airlock and clear the rainforest alarm.", 0.89f, 0.99f,
|
||||||
|
new("Main airlock", "Check the airlock", "The experiment has started. The main door is staying shut.", 0f, -26f, StoryPropKind.Hatch),
|
||||||
|
new("Rainforest litter", "Pick up the smoking litter", "The source is gone. The intake is still reading smoke.", -21.5f, 10.9f, StoryPropKind.Litter, requires: 0b001),
|
||||||
|
new("Rainforest intake", "Clear the rainforest alarm", "Rainforest intake is clear. Olivia is taking inventory in the habitat.", -28.7f, 12.3f, StoryPropKind.Intake, requires: 0b010)),
|
||||||
|
new("The Secret Stash", "Early in the experiment",
|
||||||
|
"A raid on the hidden snacks left a trail of wrappers. Then Bud and Doyle fooled around in the lab, leaving Olivia with a ventilation alarm.",
|
||||||
|
"Clean the habitat and reset the lab vent.", 0.84f, 0.98f,
|
||||||
|
new("Snack wrappers", "Bag the snack wrappers", "Wrappers bagged. There is another pile farther up the habitat hall.", 0f, -22.1f, StoryPropKind.Litter),
|
||||||
|
new("Empty snack boxes", "Clear the snack boxes", "The hall is clean. Check the lab vent at the Technosphere entrance.", 0f, -15.1f, StoryPropKind.Litter),
|
||||||
|
new("Lab ventilation", "Reset the lab vent", "Lab ventilation is back. Faulkner has sent both of you to the desert.", 20f, -11.25f, StoryPropKind.Intake, requires: 0b011)),
|
||||||
|
new("The Desert Door", "After three days in the desert",
|
||||||
|
"The desert’s service door turned out to have a key. Bud and Doyle slipped out, and the open hatch broke the seal.",
|
||||||
|
"Recover the key, reseal the hatch, and check the Lung.", 0.76f, 0.97f,
|
||||||
|
new("Service key", "Recover the service key", "You have the key. Take it to the hatch at the far edge of the Great Desert.", 22f, -1.5f, StoryPropKind.Supply),
|
||||||
|
new("Desert service hatch", "Reseal the service hatch", "The hatch is sealed. The Lung needs to bring pressure back into balance.", 40f, -4f, StoryPropKind.Hatch, requires: 0b001),
|
||||||
|
new("Lung monitor", "Balance the Lung", "Pressure is steady again. Outside, a pizza delivery gives Bud a spectacularly bad idea.", 32f, -18.6f, StoryPropKind.Console, requires: 0b010)),
|
||||||
|
new("After the Party", "A month into the experiment",
|
||||||
|
"The boys threw a party to prove they cared about the environment. The guests are gone, the dome is trashed, and the scientists are ready to walk.",
|
||||||
|
"Clean up the party and bring air, water, and crops back.", 0.01f, 0.99f,
|
||||||
|
new("Lagoon trash", "Clear the lagoon shore", "The lagoon shore is clear. The water monitor is still offline.", 6f, 13.8f, StoryPropKind.Litter),
|
||||||
|
new("Orchard trash", "Clear the orchard litter", "Orchard litter is bagged. The crew can start clearing the air.", -6f, -9.5f, StoryPropKind.Litter),
|
||||||
|
new("Farm seed tray", "Pick up the seed tray", "Take the seed tray to the damaged Farm beds.", -16f, -11f, StoryPropKind.Supply, part: 2),
|
||||||
|
new("Crop beds", "Replant the Farm beds", "New seedlings are in. The Farm is back on the recovery chart.", -25f, -13.1f, StoryPropKind.Planter, requires: 0b00000100, part: 2),
|
||||||
|
new("Air filter", "Pick up the clean air filter", "Take the clean filter to the rainforest intake.", 17.5f, 11.4f, StoryPropKind.Supply, part: 1),
|
||||||
|
new("Rainforest filtration", "Install the air filter", "The intake is running clean. The fogger is cycling again.", -18f, 11.1f, StoryPropKind.Intake, requires: 0b00010010, part: 1),
|
||||||
|
new("Tide monitor", "Restart the lagoon monitor", "The lagoon monitor is back online and the water is clearing.", -3.2f, 11.8f, StoryPropKind.Console, requires: 0b00000001),
|
||||||
|
new("Homeostasis desk", "Confirm the recovery", "The dome is healthy again. Earth Day is tomorrow, and Faulkner has come back for the ceremony.", 1.6f, -16.9f, StoryPropKind.Console, requires: 0b01111111)),
|
||||||
|
new("Opening Day", "Earth Day",
|
||||||
|
"Faulkner’s surprise for the reopening has turned dangerous. Bud and Doyle know what they helped set in motion and have one last mess to put right.",
|
||||||
|
"Cancel the ceremony from the safety relays, then reopen the airlock.", 0.99f, 1f,
|
||||||
|
new("Lagoon safety relay", "Cancel the lagoon cue", "The lagoon relay is safe. Two other areas still need clearance.", 3.7f, 18.5f, StoryPropKind.Signal),
|
||||||
|
new("Farm safety relay", "Cancel the Farm cue", "The Farm relay is safe. Keep going until the airlock has clearance.", -24f, -11.8f, StoryPropKind.Signal),
|
||||||
|
new("Ceremony shutdown", "Cancel the main show", "The ceremony controls are safe. Meet everyone at the front airlock.", 21f, -14.5f, StoryPropKind.Signal, requires: 0b011),
|
||||||
|
new("Main airlock", "Reopen the dome", "The dome is safe and the experiment made it to Earth Day.", 0f, -27.2f, StoryPropKind.Hatch, requires: 0b111))
|
||||||
|
};
|
||||||
|
|
||||||
|
private int chapterIndex;
|
||||||
|
private int completed;
|
||||||
|
public int HeldPart { get; private set; } = -1;
|
||||||
|
public int ChapterNumber => chapterIndex + 1;
|
||||||
|
public int ChapterCount => Chapters.Length;
|
||||||
|
public bool IsLastChapter => chapterIndex == Chapters.Length - 1;
|
||||||
|
public string Title => Current.Title;
|
||||||
|
public string Status => Current.Status;
|
||||||
|
public string Brief => Current.Brief;
|
||||||
|
public string Goal => Current.Goal;
|
||||||
|
public int Total => Current.Tasks.Length;
|
||||||
|
public int Done
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < Total; i++)
|
||||||
|
if (IsDone(i))
|
||||||
|
count++;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public float Homeostasis => Mathf.Lerp(Current.StartingHealth, Current.RestoredHealth, Done / (float)Total);
|
||||||
|
private Chapter Current => Chapters[chapterIndex];
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
chapterIndex = 0;
|
||||||
|
completed = 0;
|
||||||
|
HeldPart = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Advance()
|
||||||
|
{
|
||||||
|
chapterIndex++;
|
||||||
|
completed = 0;
|
||||||
|
HeldPart = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Target(int index) => Current.Tasks[index];
|
||||||
|
public bool IsDone(int index) => (completed & (1 << index)) != 0;
|
||||||
|
|
||||||
|
public bool IsOpen(int index)
|
||||||
|
{
|
||||||
|
if (IsDone(index))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Task task = Target(index);
|
||||||
|
if ((completed & task.Requires) != task.Requires)
|
||||||
|
return false;
|
||||||
|
if (task.Part == -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return task.Kind == StoryPropKind.Supply ? HeldPart == -1 : HeldPart == task.Part;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Closest(Vector2 position)
|
||||||
|
{
|
||||||
|
int closest = -1;
|
||||||
|
float nearest = InteractionRange * InteractionRange;
|
||||||
|
for (int i = 0; i < Total; i++)
|
||||||
|
{
|
||||||
|
if (IsDone(i))
|
||||||
|
continue;
|
||||||
|
float squaredDistance = (Target(i).Point - position).sqrMagnitude;
|
||||||
|
if (squaredDistance >= nearest)
|
||||||
|
continue;
|
||||||
|
nearest = squaredDistance;
|
||||||
|
closest = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return closest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Prompt(int index)
|
||||||
|
{
|
||||||
|
if (index == -1)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
Task task = Target(index);
|
||||||
|
return IsOpen(index) ? "E " + task.Verb : BlockedMessage(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoryAction Interact(int index, out string dispatch)
|
||||||
|
{
|
||||||
|
Task task = Target(index);
|
||||||
|
if (!IsOpen(index))
|
||||||
|
{
|
||||||
|
dispatch = BlockedMessage(task);
|
||||||
|
return StoryAction.Blocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
completed |= 1 << index;
|
||||||
|
if (task.Part >= 0)
|
||||||
|
HeldPart = task.Kind == StoryPropKind.Supply ? task.Part : -1;
|
||||||
|
dispatch = task.Completed;
|
||||||
|
return completed == (1 << Total) - 1 ? StoryAction.ChapterFinished : StoryAction.Completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string BlockedMessage(Task task)
|
||||||
|
{
|
||||||
|
if (task.Part >= 0 && task.Kind == StoryPropKind.Supply && HeldPart != -1)
|
||||||
|
return "Install the part you are carrying first";
|
||||||
|
if (task.Part >= 0 && HeldPart != task.Part)
|
||||||
|
return "Pick up the matching supply first";
|
||||||
|
return "Complete the earlier work first";
|
||||||
|
}
|
||||||
|
|
||||||
|
public int PinCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < Total; i++)
|
||||||
|
if (IsOpen(i))
|
||||||
|
count++;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Pin(int index)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Total; i++)
|
||||||
|
{
|
||||||
|
if (!IsOpen(i))
|
||||||
|
continue;
|
||||||
|
if (index-- == 0)
|
||||||
|
return Target(i);
|
||||||
|
}
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal readonly struct Task
|
||||||
|
{
|
||||||
|
public readonly string Name;
|
||||||
|
public readonly string Verb;
|
||||||
|
public readonly string Completed;
|
||||||
|
public readonly Vector2 Point;
|
||||||
|
public readonly StoryPropKind Kind;
|
||||||
|
public readonly int Requires;
|
||||||
|
public readonly int Part;
|
||||||
|
|
||||||
|
public Task(string name, string verb, string completed, float x, float z, StoryPropKind kind,
|
||||||
|
int requires = 0, int part = -1)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Verb = verb;
|
||||||
|
Completed = completed;
|
||||||
|
Point = new Vector2(x, z);
|
||||||
|
Kind = kind;
|
||||||
|
Requires = requires;
|
||||||
|
Part = part;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly struct Chapter
|
||||||
|
{
|
||||||
|
public readonly string Title;
|
||||||
|
public readonly string Status;
|
||||||
|
public readonly string Brief;
|
||||||
|
public readonly string Goal;
|
||||||
|
public readonly float StartingHealth;
|
||||||
|
public readonly float RestoredHealth;
|
||||||
|
public readonly Task[] Tasks;
|
||||||
|
|
||||||
|
public Chapter(string title, string status, string brief, string goal, float startingHealth,
|
||||||
|
float restoredHealth, Task first, params Task[] remaining)
|
||||||
|
{
|
||||||
|
Title = title;
|
||||||
|
Status = status;
|
||||||
|
Brief = brief;
|
||||||
|
Goal = goal;
|
||||||
|
StartingHealth = startingHealth;
|
||||||
|
RestoredHealth = restoredHealth;
|
||||||
|
Tasks = new Task[remaining.Length + 1];
|
||||||
|
Tasks[0] = first;
|
||||||
|
remaining.CopyTo(Tasks, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/DomeShift/DomeStory.cs.meta
Normal file
2
Assets/DomeShift/DomeStory.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 66105ac6b1ba4a239d8e7f2c66bf3305
|
||||||
444
Assets/DomeShift/DomeStoryProps.cs
Normal file
444
Assets/DomeShift/DomeStoryProps.cs
Normal file
@@ -0,0 +1,444 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
|
||||||
|
namespace DomeShift
|
||||||
|
{
|
||||||
|
internal enum StoryPropKind
|
||||||
|
{
|
||||||
|
Litter,
|
||||||
|
Supply,
|
||||||
|
Console,
|
||||||
|
Hatch,
|
||||||
|
Planter,
|
||||||
|
Signal,
|
||||||
|
Intake
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class DomeStoryProps
|
||||||
|
{
|
||||||
|
private const int Capacity = 8;
|
||||||
|
private static readonly Color ReadyColor = new Color32(153, 236, 184, 255);
|
||||||
|
|
||||||
|
private readonly Slot[] slots = new Slot[Capacity];
|
||||||
|
private readonly Transform root;
|
||||||
|
private readonly DomeEnvironment environment;
|
||||||
|
private readonly Shader shader;
|
||||||
|
private readonly Mesh floorCue;
|
||||||
|
private readonly Material frame;
|
||||||
|
private readonly Material metal;
|
||||||
|
private readonly Material linen;
|
||||||
|
private readonly Material dark;
|
||||||
|
private readonly Material safety;
|
||||||
|
private readonly Material rust;
|
||||||
|
private readonly Material soil;
|
||||||
|
private readonly Material wilted;
|
||||||
|
private readonly Material leaf;
|
||||||
|
private readonly Material leafTip;
|
||||||
|
|
||||||
|
private DomeStoryProps(Transform parent, DomeEnvironment environment)
|
||||||
|
{
|
||||||
|
this.environment = environment;
|
||||||
|
root = Group(parent, "Story mission props", Vector3.zero);
|
||||||
|
shader = Shader.Find("Standard");
|
||||||
|
frame = MaterialFor("Painted frame", new Color32(51, 82, 80, 255));
|
||||||
|
metal = MaterialFor("Machine alloy", new Color32(121, 151, 143, 255), 0.28f);
|
||||||
|
linen = MaterialFor("Light trim", new Color32(227, 217, 171, 255));
|
||||||
|
dark = MaterialFor("Graphite", new Color32(19, 34, 41, 255));
|
||||||
|
safety = MaterialFor("Safety stripe", new Color32(243, 173, 81, 255));
|
||||||
|
rust = MaterialFor("Warm enamel", new Color32(193, 85, 63, 255));
|
||||||
|
soil = MaterialFor("Seed-bed soil", new Color32(80, 58, 43, 255));
|
||||||
|
wilted = MaterialFor("Wilting foliage", new Color32(159, 147, 89, 255));
|
||||||
|
leaf = MaterialFor("Restored foliage", new Color32(74, 143, 82, 255));
|
||||||
|
leafTip = MaterialFor("New foliage", new Color32(155, 192, 94, 255));
|
||||||
|
floorCue = MakeFloorCue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DomeStoryProps Create(Transform parent, DomeEnvironment environment) => new(parent, environment);
|
||||||
|
|
||||||
|
public void Hide()
|
||||||
|
{
|
||||||
|
foreach (Slot slot in slots)
|
||||||
|
if (slot != null)
|
||||||
|
slot.Root.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Show(int slot, StoryPropKind kind, Vector3 canonicalPosition, Color accent)
|
||||||
|
{
|
||||||
|
if ((uint)slot >= Capacity)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Slot prop = slots[slot] ??= CreateSlot();
|
||||||
|
if (prop.Model == null || prop.Kind != kind)
|
||||||
|
{
|
||||||
|
if (prop.Model != null)
|
||||||
|
{
|
||||||
|
prop.Model.gameObject.SetActive(false);
|
||||||
|
Object.Destroy(prop.Model.gameObject);
|
||||||
|
}
|
||||||
|
prop.Kind = kind;
|
||||||
|
prop.BuildState(kind);
|
||||||
|
AddModel(prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
prop.Done = false;
|
||||||
|
prop.Root.localPosition = canonicalPosition;
|
||||||
|
prop.Cue.gameObject.SetActive(true);
|
||||||
|
prop.RefreshState();
|
||||||
|
ApplyAccent(prop.Accent, accent);
|
||||||
|
prop.Root.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Complete(int slot)
|
||||||
|
{
|
||||||
|
if ((uint)slot >= Capacity)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Slot prop = slots[slot];
|
||||||
|
if (prop == null || !prop.Root.gameObject.activeSelf || prop.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prop.Done = true;
|
||||||
|
if (prop.Kind == StoryPropKind.Litter || prop.Kind == StoryPropKind.Supply)
|
||||||
|
{
|
||||||
|
prop.Root.gameObject.SetActive(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
prop.Cue.gameObject.SetActive(false);
|
||||||
|
prop.RefreshState();
|
||||||
|
ApplyAccent(prop.Accent, ReadyColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Animate(float elapsed)
|
||||||
|
{
|
||||||
|
for (int index = 0; index < slots.Length; index++)
|
||||||
|
{
|
||||||
|
Slot slot = slots[index];
|
||||||
|
if (slot == null || !slot.Root.gameObject.activeSelf)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (slot.Done)
|
||||||
|
{
|
||||||
|
if (slot.Rotor != null)
|
||||||
|
slot.Rotor.localRotation = Quaternion.Euler(0f, 0f, elapsed * -240f);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float offset = Mathf.Sin(elapsed * 4.5f + index * 1.31f);
|
||||||
|
slot.Beacon.localPosition = Vector3.up * (slot.BeaconY + 0.085f * offset);
|
||||||
|
slot.Beacon.localRotation = Quaternion.Euler(44f, elapsed * 65f + index * 35f, 45f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Slot CreateSlot()
|
||||||
|
{
|
||||||
|
Transform slot = Group(root, "Stage objective", Vector3.zero);
|
||||||
|
slot.gameObject.SetActive(false);
|
||||||
|
Material accent = MaterialFor("Objective accent", ReadyColor, glowing: true);
|
||||||
|
Transform cue = Group(slot, "Objective signal", Vector3.zero);
|
||||||
|
|
||||||
|
AddCue(cue, "Dark cue rim", 0.023f, 1.05f, dark);
|
||||||
|
AddCue(cue, "Accent cue", 0.035f, 1f, accent);
|
||||||
|
Transform beacon = Box(cue, "Hover beacon", Vector3.up * 1.4f, Vector3.one * 0.17f, accent);
|
||||||
|
beacon.localRotation = Quaternion.Euler(44f, 0f, 45f);
|
||||||
|
return new Slot(slot, cue, beacon, accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddModel(Slot prop)
|
||||||
|
{
|
||||||
|
switch (prop.Kind)
|
||||||
|
{
|
||||||
|
case StoryPropKind.Litter:
|
||||||
|
Litter(prop.Model);
|
||||||
|
prop.BeaconY = 0.88f;
|
||||||
|
break;
|
||||||
|
case StoryPropKind.Supply:
|
||||||
|
Supply(prop.Model);
|
||||||
|
prop.BeaconY = 1.26f;
|
||||||
|
break;
|
||||||
|
case StoryPropKind.Console:
|
||||||
|
Console(prop.Model, prop.Accent);
|
||||||
|
prop.BeaconY = 1.64f;
|
||||||
|
break;
|
||||||
|
case StoryPropKind.Hatch:
|
||||||
|
Hatch(prop);
|
||||||
|
prop.BeaconY = 1.88f;
|
||||||
|
break;
|
||||||
|
case StoryPropKind.Planter:
|
||||||
|
Planter(prop);
|
||||||
|
prop.BeaconY = 1.40f;
|
||||||
|
break;
|
||||||
|
case StoryPropKind.Signal:
|
||||||
|
Signal(prop.Model, prop.Accent);
|
||||||
|
prop.BeaconY = 1.7f;
|
||||||
|
break;
|
||||||
|
case StoryPropKind.Intake:
|
||||||
|
Intake(prop);
|
||||||
|
prop.BeaconY = 1.58f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
prop.Beacon.localPosition = Vector3.up * prop.BeaconY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Litter(Transform model)
|
||||||
|
{
|
||||||
|
Box(model, "Paper wrapper", new Vector3(-0.34f, 0.062f, 0.15f), new Vector3(0.37f, 0.071f, 0.29f), linen)
|
||||||
|
.localRotation = Quaternion.Euler(0f, -21f, 12f);
|
||||||
|
Box(model, "Printed wrapper stripe", new Vector3(-0.34f, 0.101f, 0.14f), new Vector3(0.32f, 0.019f, 0.057f), rust)
|
||||||
|
.localRotation = Quaternion.Euler(0f, -21f, 8f);
|
||||||
|
Transform can = Group(model, "Discarded drink can", new Vector3(0.25f, 0.16f, -0.17f));
|
||||||
|
can.localRotation = Quaternion.Euler(76f, 41f, 8f);
|
||||||
|
Cylinder(can, "Can shell", Vector3.zero, new Vector3(0.24f, 0.37f, 0.23f), rust);
|
||||||
|
Cylinder(can, "Can base", Vector3.down * 0.18f, new Vector3(0.25f, 0.035f, 0.24f), metal);
|
||||||
|
Cylinder(can, "Can lid", Vector3.up * 0.18f, new Vector3(0.25f, 0.035f, 0.24f), metal);
|
||||||
|
Cylinder(can, "Pull tab", new Vector3(0.036f, 0.201f, 0.03f), new Vector3(0.12f, 0.023f, 0.084f), dark);
|
||||||
|
Box(model, "Crumpled snack bag", new Vector3(0.31f, 0.09f, 0.31f), new Vector3(0.26f, 0.115f, 0.37f), safety)
|
||||||
|
.localRotation = Quaternion.Euler(-8f, 29f, 14f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Supply(Transform model)
|
||||||
|
{
|
||||||
|
Box(model, "Reusable crate", new Vector3(0f, 0.28f, 0f), new Vector3(1.04f, 0.48f, 0.78f), frame);
|
||||||
|
Box(model, "Crate lid", new Vector3(0f, 0.55f, 0f), new Vector3(1.08f, 0.12f, 0.81f), metal);
|
||||||
|
Box(model, "Label backing", new Vector3(0f, 0.29f, -0.398f), new Vector3(0.49f, 0.25f, 0.03f), linen);
|
||||||
|
Box(model, "Label print", new Vector3(0f, 0.318f, -0.419f), new Vector3(0.31f, 0.054f, 0.02f), frame);
|
||||||
|
Box(model, "Label print", new Vector3(-0.07f, 0.25f, -0.419f), new Vector3(0.17f, 0.039f, 0.02f), frame);
|
||||||
|
for (int side = -1; side <= 1; side += 2)
|
||||||
|
{
|
||||||
|
float x = side * 0.39f;
|
||||||
|
Box(model, "Corner brace", new Vector3(x, 0.3f, -0.405f), new Vector3(0.08f, 0.55f, 0.05f), dark);
|
||||||
|
Box(model, "Lid strap", new Vector3(x, 0.622f, 0f), new Vector3(0.08f, 0.031f, 0.82f), dark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Console(Transform model, Material status)
|
||||||
|
{
|
||||||
|
Box(model, "Base rails", new Vector3(0f, 0.08f, 0f), new Vector3(0.97f, 0.14f, 0.77f), dark);
|
||||||
|
Box(model, "Control pedestal", new Vector3(0f, 0.42f, 0.08f), new Vector3(0.77f, 0.7f, 0.55f), frame);
|
||||||
|
Transform panel = Group(model, "Monitor tilt", new Vector3(0f, 0.88f, 0.08f));
|
||||||
|
panel.localRotation = Quaternion.Euler(-19f, 0f, 0f);
|
||||||
|
Box(panel, "Monitor housing", Vector3.zero, new Vector3(0.98f, 0.44f, 0.32f), metal);
|
||||||
|
Box(panel, "Monitor bezel", new Vector3(0f, 0.013f, -0.171f), new Vector3(0.76f, 0.3f, 0.032f), dark);
|
||||||
|
Box(panel, "Current status", new Vector3(0f, 0.017f, -0.194f), new Vector3(0.53f, 0.082f, 0.023f), status);
|
||||||
|
Box(model, "Sloped button tray", new Vector3(0f, 0.65f, -0.25f), new Vector3(0.88f, 0.15f, 0.34f), linen);
|
||||||
|
for (int i = -1; i <= 1; i++)
|
||||||
|
Box(model, "Preset button", new Vector3(i * 0.23f, 0.733f, -0.293f), new Vector3(0.115f, 0.04f, 0.106f), i == 0 ? safety : frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Hatch(Slot slot)
|
||||||
|
{
|
||||||
|
Transform model = slot.Model;
|
||||||
|
Box(model, "Hatch frame", new Vector3(0f, 0.64f, 0.08f), new Vector3(1.33f, 1.18f, 0.35f), frame);
|
||||||
|
Box(model, "Hatch recess", new Vector3(0f, 0.59f, -0.107f), new Vector3(0.89f, 0.89f, 0.072f), dark);
|
||||||
|
Box(model, "Lintel signal", new Vector3(0f, 1.07f, -0.105f), new Vector3(0.56f, 0.09f, 0.056f), slot.Accent);
|
||||||
|
|
||||||
|
Box(model, "Shutter", new Vector3(0f, 0.6f, -0.153f), new Vector3(0.85f, 0.86f, 0.074f), metal);
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
Box(model, "Edge grip", new Vector3(0f, 0.34f + i * 0.2f, -0.197f), new Vector3(0.71f, 0.058f, 0.035f), frame);
|
||||||
|
Box(model, "Latch plate", new Vector3(0.23f, 0.55f, -0.205f), new Vector3(0.25f, 0.20f, 0.041f), dark);
|
||||||
|
Box(model, "Latch status", new Vector3(0.23f, 0.55f, -0.233f), new Vector3(0.145f, 0.064f, 0.029f), slot.Accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Planter(Slot slot)
|
||||||
|
{
|
||||||
|
Transform model = slot.Model;
|
||||||
|
Box(model, "Bin", new Vector3(0f, 0.27f, 0f), new Vector3(1.27f, 0.43f, 0.79f), frame);
|
||||||
|
Box(model, "Grow bed lip", new Vector3(0f, 0.474f, 0f), new Vector3(1.35f, 0.093f, 0.85f), metal);
|
||||||
|
Box(model, "Soil", new Vector3(0f, 0.526f, 0f), new Vector3(1.15f, 0.052f, 0.65f), soil);
|
||||||
|
Box(model, "Controller status", new Vector3(0f, 0.32f, -0.405f), new Vector3(0.36f, 0.067f, 0.042f), slot.Accent);
|
||||||
|
slot.Before = Group(model, "Dry seedlings", Vector3.zero);
|
||||||
|
slot.After = Group(model, "Recovered seedlings", Vector3.zero);
|
||||||
|
for (int i = -1; i <= 1; i++)
|
||||||
|
{
|
||||||
|
Vector3 basePoint = new(i * 0.36f, 0.55f, i % 2 == 0 ? -0.10f : 0.11f);
|
||||||
|
Vector3 bentTop = basePoint + new Vector3(0.12f, 0.20f, 0.019f);
|
||||||
|
Stick(slot.Before, "Bent stem", basePoint, bentTop, 0.043f, wilted);
|
||||||
|
Leaf(slot.Before, "Dry leaf", bentTop, bentTop + new Vector3(0.09f, -0.07f, 0.045f), 0.103f, wilted);
|
||||||
|
|
||||||
|
Vector3 tip = basePoint + Vector3.up * (i == 0 ? 0.44f : 0.36f);
|
||||||
|
Stick(slot.After, "New stem", basePoint, tip, 0.045f, leaf);
|
||||||
|
Leaf(slot.After, "New leaf", tip - Vector3.up * 0.09f, tip + new Vector3(-0.16f, 0.02f, 0.08f), 0.14f, leaf);
|
||||||
|
Leaf(slot.After, "New leaf", tip - Vector3.up * 0.12f, tip + new Vector3(0.17f, -0.022f, -0.08f), 0.14f, leafTip);
|
||||||
|
Leaf(slot.After, "New growth", tip - Vector3.up * 0.06f, tip + Vector3.up * 0.12f, 0.12f, leafTip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Signal(Transform model, Material status)
|
||||||
|
{
|
||||||
|
Box(model, "Interlock base", new Vector3(0f, 0.11f, 0f), new Vector3(0.84f, 0.19f, 0.72f), dark);
|
||||||
|
Box(model, "Interlock pole", new Vector3(0f, 0.48f, 0.02f), new Vector3(0.22f, 0.72f, 0.22f), metal);
|
||||||
|
Box(model, "Interlock terminal", new Vector3(0f, 0.87f, -0.03f), new Vector3(0.76f, 0.56f, 0.37f), frame);
|
||||||
|
Box(model, "Light panel", new Vector3(0f, 0.935f, -0.23f), new Vector3(0.55f, 0.195f, 0.055f), dark);
|
||||||
|
for (int i = -1; i <= 1; i++)
|
||||||
|
Box(model, "Interlock display", new Vector3(i * 0.143f, 0.94f, -0.268f), new Vector3(0.075f, 0.094f, 0.03f), status);
|
||||||
|
Cylinder(model, "Signal lens", new Vector3(0f, 1.18f, -0.03f), new Vector3(0.27f, 0.13f, 0.27f), status);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Intake(Slot slot)
|
||||||
|
{
|
||||||
|
Transform model = slot.Model;
|
||||||
|
Box(model, "Intake frame", new Vector3(0f, 0.51f, 0f), new Vector3(1.2f, 0.91f, 0.72f), frame);
|
||||||
|
Box(model, "Intake cap", new Vector3(0f, 0.97f, 0f), new Vector3(1.23f, 0.16f, 0.74f), metal);
|
||||||
|
Cylinder(model, "Fan shroud", new Vector3(0f, 0.54f, -0.381f), new Vector3(0.71f, 0.107f, 0.71f), dark)
|
||||||
|
.localRotation = Quaternion.Euler(90f, 0f, 0f);
|
||||||
|
slot.Rotor = Group(model, "Intake rotor", new Vector3(0f, 0.54f, -0.44f));
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
Transform spoke = Group(slot.Rotor, "Blade spoke", Vector3.zero);
|
||||||
|
spoke.localRotation = Quaternion.Euler(0f, 0f, i * 90f);
|
||||||
|
Box(spoke, "Fan blade", new Vector3(0.025f, 0.15f, 0f), new Vector3(0.123f, 0.27f, 0.045f), linen)
|
||||||
|
.localRotation = Quaternion.Euler(0f, 0f, 12f);
|
||||||
|
}
|
||||||
|
Sphere(slot.Rotor, "Fan hub", Vector3.zero, new Vector3(0.16f, 0.16f, 0.11f), metal);
|
||||||
|
Box(model, "Airflow sensor", new Vector3(0.34f, 0.96f, -0.38f), new Vector3(0.23f, 0.068f, 0.044f), slot.Accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddCue(Transform parent, string name, float height, float scale, Material material)
|
||||||
|
{
|
||||||
|
Transform cue = Group(parent, name, Vector3.up * height);
|
||||||
|
cue.localScale = new Vector3(scale, 1f, scale);
|
||||||
|
cue.gameObject.AddComponent<MeshFilter>().sharedMesh = floorCue;
|
||||||
|
MeshRenderer renderer = cue.gameObject.AddComponent<MeshRenderer>();
|
||||||
|
renderer.sharedMaterial = material;
|
||||||
|
renderer.shadowCastingMode = ShadowCastingMode.Off;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mesh MakeFloorCue()
|
||||||
|
{
|
||||||
|
const int sides = 24;
|
||||||
|
const int segments = sides * 2 / 3;
|
||||||
|
Vector3[] vertices = new Vector3[segments * 4];
|
||||||
|
int[] indices = new int[segments * 6];
|
||||||
|
int n = 0;
|
||||||
|
for (int i = 0; i < sides; i++)
|
||||||
|
{
|
||||||
|
if (i % 6 < 2)
|
||||||
|
continue;
|
||||||
|
float a = (i + 0.5f) * 2f * Mathf.PI / sides;
|
||||||
|
float b = (i + 1.5f) * 2f * Mathf.PI / sides;
|
||||||
|
Vector3 start = new(Mathf.Cos(a), 0f, Mathf.Sin(a));
|
||||||
|
Vector3 end = new(Mathf.Cos(b), 0f, Mathf.Sin(b));
|
||||||
|
int first = n * 4;
|
||||||
|
vertices[first] = start * 0.91f;
|
||||||
|
vertices[first + 1] = end * 0.91f;
|
||||||
|
vertices[first + 2] = end * 0.84f;
|
||||||
|
vertices[first + 3] = start * 0.84f;
|
||||||
|
int index = n * 6;
|
||||||
|
indices[index] = first;
|
||||||
|
indices[index + 1] = first + 2;
|
||||||
|
indices[index + 2] = first + 1;
|
||||||
|
indices[index + 3] = first;
|
||||||
|
indices[index + 4] = first + 3;
|
||||||
|
indices[index + 5] = first + 2;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mesh mesh = new() { name = "Story objective cue", vertices = vertices, triangles = indices };
|
||||||
|
mesh.RecalculateNormals();
|
||||||
|
return environment.Own(mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Material MaterialFor(string name, Color color, float metallic = 0f, bool glowing = false)
|
||||||
|
{
|
||||||
|
Material material = new(shader) { name = "Story " + name, color = color };
|
||||||
|
material.SetFloat("_Glossiness", 0.18f);
|
||||||
|
material.SetFloat("_Metallic", metallic);
|
||||||
|
if (glowing)
|
||||||
|
{
|
||||||
|
material.EnableKeyword("_EMISSION");
|
||||||
|
ApplyAccent(material, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return environment.Own(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ApplyAccent(Material material, Color color)
|
||||||
|
{
|
||||||
|
material.color = color;
|
||||||
|
material.SetColor("_EmissionColor", color * 0.41f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Transform Group(Transform parent, string name, Vector3 position)
|
||||||
|
{
|
||||||
|
Transform group = new GameObject(name).transform;
|
||||||
|
group.SetParent(parent, false);
|
||||||
|
group.localPosition = position;
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Transform Box(Transform parent, string name, Vector3 position, Vector3 size, Material material) =>
|
||||||
|
Shape(parent, name, PrimitiveType.Cube, position, size, material);
|
||||||
|
|
||||||
|
private static Transform Sphere(Transform parent, string name, Vector3 position, Vector3 size, Material material) =>
|
||||||
|
Shape(parent, name, PrimitiveType.Sphere, position, size, material);
|
||||||
|
|
||||||
|
private static Transform Cylinder(Transform parent, string name, Vector3 position, Vector3 size, Material material) =>
|
||||||
|
Shape(parent, name, PrimitiveType.Cylinder, position, new Vector3(size.x, size.y * 0.5f, size.z), material);
|
||||||
|
|
||||||
|
private static void Stick(Transform parent, string name, Vector3 start, Vector3 end, float width, Material material) =>
|
||||||
|
Cylinder(parent, name, (start + end) * 0.5f, new Vector3(width, (end - start).magnitude, width), material)
|
||||||
|
.localRotation = Quaternion.FromToRotation(Vector3.up, end - start);
|
||||||
|
|
||||||
|
private static void Leaf(Transform parent, string name, Vector3 start, Vector3 end, float width, Material material) =>
|
||||||
|
Sphere(parent, name, (start + end) * 0.5f, new Vector3(width, (end - start).magnitude, 0.063f), material)
|
||||||
|
.localRotation = Quaternion.FromToRotation(Vector3.up, end - start);
|
||||||
|
|
||||||
|
private static Transform Shape(Transform parent, string name, PrimitiveType kind, Vector3 position, Vector3 size, Material material)
|
||||||
|
{
|
||||||
|
GameObject solid = GameObject.CreatePrimitive(kind);
|
||||||
|
solid.name = name;
|
||||||
|
solid.transform.SetParent(parent, false);
|
||||||
|
solid.transform.localPosition = position;
|
||||||
|
solid.transform.localScale = size;
|
||||||
|
Collider collider = solid.GetComponent<Collider>();
|
||||||
|
if (collider != null)
|
||||||
|
{
|
||||||
|
collider.enabled = false;
|
||||||
|
Object.Destroy(collider);
|
||||||
|
}
|
||||||
|
solid.GetComponent<MeshRenderer>().sharedMaterial = material;
|
||||||
|
return solid.transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class Slot
|
||||||
|
{
|
||||||
|
public readonly Transform Root;
|
||||||
|
public readonly Transform Cue;
|
||||||
|
public readonly Transform Beacon;
|
||||||
|
public readonly Material Accent;
|
||||||
|
public Transform Model;
|
||||||
|
public Transform Before;
|
||||||
|
public Transform After;
|
||||||
|
public Transform Rotor;
|
||||||
|
public StoryPropKind Kind;
|
||||||
|
public bool Done;
|
||||||
|
public float BeaconY;
|
||||||
|
|
||||||
|
public Slot(Transform root, Transform cue, Transform beacon, Material accent)
|
||||||
|
{
|
||||||
|
Root = root;
|
||||||
|
Cue = cue;
|
||||||
|
Beacon = beacon;
|
||||||
|
Accent = accent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildState(StoryPropKind kind)
|
||||||
|
{
|
||||||
|
Model = Group(Root, kind.ToString(), Vector3.zero);
|
||||||
|
Before = null;
|
||||||
|
After = null;
|
||||||
|
Rotor = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshState()
|
||||||
|
{
|
||||||
|
if (Before != null)
|
||||||
|
Before.gameObject.SetActive(!Done);
|
||||||
|
if (After != null)
|
||||||
|
After.gameObject.SetActive(Done);
|
||||||
|
if (Rotor != null)
|
||||||
|
Rotor.localRotation = Quaternion.identity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/DomeShift/DomeStoryProps.cs.meta
Normal file
2
Assets/DomeShift/DomeStoryProps.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2289d55e7c9142cebcacbd10280684bf
|
||||||
@@ -13,6 +13,7 @@ namespace DomeShift
|
|||||||
private readonly Transform[] supplyItems = new Transform[3];
|
private readonly Transform[] supplyItems = new Transform[3];
|
||||||
private readonly Transform[] carriedItems = new Transform[3];
|
private readonly Transform[] carriedItems = new Transform[3];
|
||||||
private readonly Transform root;
|
private readonly Transform root;
|
||||||
|
private readonly Transform equipment;
|
||||||
private readonly Material hull;
|
private readonly Material hull;
|
||||||
private readonly Material trim;
|
private readonly Material trim;
|
||||||
private readonly Material metal;
|
private readonly Material metal;
|
||||||
@@ -41,6 +42,7 @@ namespace DomeShift
|
|||||||
{
|
{
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
root = Group(parent, "Shift equipment and crew", Vector3.zero);
|
root = Group(parent, "Shift equipment and crew", Vector3.zero);
|
||||||
|
equipment = Group(root, "Timed shift equipment", Vector3.zero);
|
||||||
hull = Surface("#10262E");
|
hull = Surface("#10262E");
|
||||||
trim = Surface("#2A5356", 0.18f, 0.28f);
|
trim = Surface("#2A5356", 0.18f, 0.28f);
|
||||||
metal = Surface("#6C9694", 0.32f, 0.35f);
|
metal = Surface("#6C9694", 0.32f, 0.35f);
|
||||||
@@ -90,6 +92,11 @@ namespace DomeShift
|
|||||||
doyle.gameObject.SetActive(isDoyle);
|
doyle.gameObject.SetActive(isDoyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetShiftEquipmentVisible(bool visible)
|
||||||
|
{
|
||||||
|
equipment.gameObject.SetActive(visible);
|
||||||
|
}
|
||||||
|
|
||||||
public void Tick(Vector2 motion, int carried, int repairedMask, float elapsed)
|
public void Tick(Vector2 motion, int carried, int repairedMask, float elapsed)
|
||||||
{
|
{
|
||||||
if (motion.sqrMagnitude > 0.01f)
|
if (motion.sqrMagnitude > 0.01f)
|
||||||
@@ -155,7 +162,7 @@ namespace DomeShift
|
|||||||
|
|
||||||
private void AddGenerator()
|
private void AddGenerator()
|
||||||
{
|
{
|
||||||
Transform unit = Group(root, "Generator", AtSite(0));
|
Transform unit = Group(equipment, "Generator", AtSite(0));
|
||||||
StationPad(unit, 0);
|
StationPad(unit, 0);
|
||||||
Box(unit, "Generator chassis", new Vector3(0f, 0.7f, 0.48f), new Vector3(2.32f, 1.08f, 1.26f), hull);
|
Box(unit, "Generator chassis", new Vector3(0f, 0.7f, 0.48f), new Vector3(2.32f, 1.08f, 1.26f), hull);
|
||||||
Box(unit, "Generator enamel", new Vector3(0f, 1.22f, 0.48f), new Vector3(2.24f, 0.25f, 1.2f), colors[0]);
|
Box(unit, "Generator enamel", new Vector3(0f, 1.22f, 0.48f), new Vector3(2.24f, 0.25f, 1.2f), colors[0]);
|
||||||
@@ -187,7 +194,7 @@ namespace DomeShift
|
|||||||
|
|
||||||
private void AddCoolant()
|
private void AddCoolant()
|
||||||
{
|
{
|
||||||
Transform unit = Group(root, "Coolant", AtSite(1));
|
Transform unit = Group(equipment, "Coolant", AtSite(1));
|
||||||
StationPad(unit, 1);
|
StationPad(unit, 1);
|
||||||
Cylinder(unit, "Reservoir base", new Vector3(0f, 0.22f, 0.53f), new Vector3(2.17f, 0.28f, 1.62f), hull);
|
Cylinder(unit, "Reservoir base", new Vector3(0f, 0.22f, 0.53f), new Vector3(2.17f, 0.28f, 1.62f), hull);
|
||||||
for (int side = -1; side <= 1; side += 2)
|
for (int side = -1; side <= 1; side += 2)
|
||||||
@@ -219,7 +226,7 @@ namespace DomeShift
|
|||||||
|
|
||||||
private void AddHydroponics()
|
private void AddHydroponics()
|
||||||
{
|
{
|
||||||
Transform unit = Group(root, "Hydroponics", AtSite(2));
|
Transform unit = Group(equipment, "Hydroponics", AtSite(2));
|
||||||
StationPad(unit, 2);
|
StationPad(unit, 2);
|
||||||
Planter(unit, new Vector3(0f, 0f, 0.62f), 2.62f, 1.26f, 6);
|
Planter(unit, new Vector3(0f, 0f, 0.62f), 2.62f, 1.26f, 6);
|
||||||
Box(unit, "Irrigation control", new Vector3(0f, 0.48f, -0.16f), new Vector3(0.9f, 0.44f, 0.32f), hull);
|
Box(unit, "Irrigation control", new Vector3(0f, 0.48f, -0.16f), new Vector3(0.9f, 0.44f, 0.32f), hull);
|
||||||
@@ -267,7 +274,7 @@ namespace DomeShift
|
|||||||
|
|
||||||
private void AddSupply(int index)
|
private void AddSupply(int index)
|
||||||
{
|
{
|
||||||
Transform shelf = Group(root, "Parts plinth " + (index + 1), AtSite(index + 3));
|
Transform shelf = Group(equipment, "Parts plinth " + (index + 1), AtSite(index + 3));
|
||||||
Cylinder(shelf, "Supply floor ring", new Vector3(0f, 0.013f, 0f), new Vector3(1.49f, 0.022f, 1.49f), colors[index]);
|
Cylinder(shelf, "Supply floor ring", new Vector3(0f, 0.013f, 0f), new Vector3(1.49f, 0.022f, 1.49f), colors[index]);
|
||||||
Cylinder(shelf, "Supply floor inset", new Vector3(0f, 0.028f, 0f), new Vector3(1.35f, 0.018f, 1.35f), hull);
|
Cylinder(shelf, "Supply floor inset", new Vector3(0f, 0.028f, 0f), new Vector3(1.35f, 0.018f, 1.35f), hull);
|
||||||
Cylinder(shelf, "Plinth", new Vector3(0f, 0.21f, 0f), new Vector3(0.83f, 0.35f, 0.83f), trim);
|
Cylinder(shelf, "Plinth", new Vector3(0f, 0.21f, 0f), new Vector3(0.83f, 0.35f, 0.83f), trim);
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ PlayerSettings:
|
|||||||
loadStoreDebugModeEnabled: 0
|
loadStoreDebugModeEnabled: 0
|
||||||
visionOSBundleVersion: 1.0
|
visionOSBundleVersion: 1.0
|
||||||
tvOSBundleVersion: 1.0
|
tvOSBundleVersion: 1.0
|
||||||
bundleVersion: 0.1.0
|
bundleVersion: 0.2.0
|
||||||
preloadedAssets: []
|
preloadedAssets: []
|
||||||
metroInputSource: 0
|
metroInputSource: 0
|
||||||
wsaTransparentSwapchain: 0
|
wsaTransparentSwapchain: 0
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -11,24 +11,35 @@ To play in the editor, add the project folder to Unity Hub, open it with **Unity
|
|||||||
| Input | Action |
|
| Input | Action |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 1 / 2 or left / right | Select Bud or Doyle on the title screen |
|
| 1 / 2 or left / right | Select Bud or Doyle on the title screen |
|
||||||
|
| S at the title | Start the story |
|
||||||
|
| P | Open the parametric Dome View from the title |
|
||||||
| X | Explore without a timer |
|
| X | Explore without a timer |
|
||||||
| Enter | Start the timed shift, resume, or retry |
|
| Enter | Start the timed shift, resume, or retry |
|
||||||
| WASD or arrow keys | Move |
|
| WASD or arrow keys | Move |
|
||||||
|
| Right mouse drag | Orbit the camera |
|
||||||
|
| Shift + right mouse drag or middle mouse drag | Pan the camera |
|
||||||
|
| Mouse wheel | Zoom |
|
||||||
|
| Home | Reset the current camera view |
|
||||||
|
| H | Show or hide the Dome View controls |
|
||||||
| Tab | Show or hide the region map |
|
| Tab | Show or hide the region map |
|
||||||
| C | Switch between follow camera and whole-dome view |
|
| C | Switch between follow camera and whole-dome view |
|
||||||
| V | Show the glass envelope or open the cutaway |
|
| V | Show the glass envelope or open the cutaway |
|
||||||
| E | Pick up or swap a spare, install it, or use the airlock |
|
| E | Pick up or swap a spare, install it, or use the airlock |
|
||||||
| Esc | Pause or resume |
|
| Esc | Pause or resume, or leave Dome View |
|
||||||
| R | Retry with the same character from results |
|
| R | Retry with the same character from results |
|
||||||
| B | Return to the title from results or the exploration pause menu |
|
| B | Return to the title from results or pause |
|
||||||
| M | Toggle sound |
|
| M | Toggle sound |
|
||||||
| F11 | Toggle fullscreen in the standalone player |
|
| F11 | Toggle fullscreen in the standalone player |
|
||||||
|
|
||||||
In the timed shift, take the fuse to the Technosphere generator, the mesh filter to the Tropical Lagoon cooling station, and the seed pack to Farm hydroponics. You can carry one part at a time. When the three stations are online, return to the Human Habitat airlock and press **E**. The shift lasts 150 seconds.
|
In the timed shift, take the fuse to the Technosphere generator, the mesh filter to the Tropical Lagoon cooling station, and the seed pack to Farm hydroponics. You can carry one part at a time. When the three stations are online, return to the Human Habitat airlock and press **E**. The shift lasts 150 seconds.
|
||||||
|
|
||||||
|
In **Story Mode**, play through five chapters from the accidental lockdown to Earth Day. Clear the rainforest alarm, clean up the hidden snack stash, reseal the Great Desert service hatch, repair the damage after the party, and make the reopening safe. Use the map to find active jobs and **E** to clean, carry, and repair. The homeostasis meter shows the dome’s recovery. The missions adapt the film’s events into playable objectives. [MGM trailer](https://www.youtube.com/watch?v=4xD1ujNkZXs) · [Film transcript](https://www.springfieldspringfield.co.uk/movie_script.php?movie=bio-dome)
|
||||||
|
|
||||||
## Customize the dome
|
## Customize the dome
|
||||||
|
|
||||||
Select **Dome Shift** in the scene Hierarchy and edit its **Dome Environment** component. The Inspector controls the footprint, roof height and bay count, glazing, random seed, terrain relief, and global and per-region density. Changes regenerate the Scene view preview. **Scene Cutaway** opens the shell in the editor, and **Frame the Bio-Dome** zooms to the facility. The player rebuilds the environment from the same values when the scene starts.
|
Open **Dome View** from the title to orbit, pan, and zoom around the complex. Adjust the footprint, roof, glazing, vegetation, terrain relief, or seed in the panel, then press **Apply changes** to regenerate the dome. Changes carry into gameplay for the current session.
|
||||||
|
|
||||||
|
To edit the project defaults, select **Dome Shift** in the scene Hierarchy and edit its **Dome Environment** component. Changes regenerate the Scene view preview. **Scene Cutaway** opens the shell in the editor, and **Frame the Bio-Dome** zooms to the facility. The Inspector also supports per-region density.
|
||||||
|
|
||||||
## Build releases
|
## Build releases
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user