Live Demo Tweaks
Copied Main Menu to gameplay scene Added Pause functionality (ESC key) Save & Restore discovered zones Applied vertical offset to asteroids (no more intersections!) Nebula shader optimized to improve early exit Nebula shader outputs light scattering to second render target Modified depth of field shader to use nebula light scattering
This commit is contained in:
parent
968783bf9c
commit
ca1ce9859d
47 changed files with 5106 additions and 2385 deletions
|
|
@ -42,12 +42,12 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
public Texture2D TemperatureColor;
|
||||
public ExponentialLerp TemperatureColorCurve;
|
||||
public ExponentialLerp TemperatureAlphaCurve;
|
||||
public float MaxTemperature;
|
||||
public bool FitToContent;
|
||||
public float CellHitPulseTime;
|
||||
public Color ToggleEnabledColor;
|
||||
public Color ToggleDisabledColor;
|
||||
public Color CellBackgroundColor = new Color(0, 0, 0, .75f);
|
||||
public float MinTempRange;
|
||||
|
||||
Subject<InventoryEventData> _onBeginDrag;
|
||||
Subject<InventoryEventData> _onDrag;
|
||||
|
|
|
|||
223
Assets/Scripts/UI/MainMenu.cs
Normal file
223
Assets/Scripts/UI/MainMenu.cs
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using static Unity.Mathematics.math;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class MainMenu : MonoBehaviour
|
||||
{
|
||||
public GameSettings Settings;
|
||||
public ConfirmationDialog Dialog;
|
||||
public bool InGame;
|
||||
public Prototype PanelPrototype;
|
||||
public float FadeTime = .5f;
|
||||
public float FadeDistance = 512;
|
||||
public float FadeAlphaExponent = 2;
|
||||
public float FadePositionExponent = 2;
|
||||
|
||||
private (PropertiesPanel panel, CanvasGroup group) _currentMenu, _nextMenu;
|
||||
private bool _fadeFromRight;
|
||||
private float _fadeLerp;
|
||||
private bool _fading;
|
||||
private Vector3 _panelPosition;
|
||||
//private Task<DatabaseCache> _databaseLoad;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Start loading the database in the background 'cause it takes a few seconds
|
||||
//_databaseLoad = Task.Run(() => ActionGameManager.Database);
|
||||
|
||||
RegisterResolver.Register();
|
||||
_panelPosition = PanelPrototype.transform.position;
|
||||
|
||||
var panel1 = PanelPrototype.Instantiate<PropertiesPanel>();
|
||||
_currentMenu = (panel1, panel1.GetComponent<CanvasGroup>());
|
||||
|
||||
var panel2 = PanelPrototype.Instantiate<PropertiesPanel>();
|
||||
_nextMenu = (panel2, panel2.GetComponent<CanvasGroup>());
|
||||
|
||||
_currentMenu.panel.gameObject.SetActive(false);
|
||||
//_saveDirectory = ActionGameManager.GameDataDirectory.CreateSubdirectory("Saves");
|
||||
|
||||
ShowMain();
|
||||
Fade(true);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_fading)
|
||||
{
|
||||
_fadeLerp += Time.deltaTime / FadeTime;
|
||||
|
||||
_currentMenu.panel.transform.position =
|
||||
_panelPosition + (_fadeFromRight ? Vector3.left : Vector3.right) * (FadeDistance * pow(_fadeLerp, FadePositionExponent));
|
||||
_nextMenu.panel.transform.position =
|
||||
_panelPosition + (_fadeFromRight ? Vector3.right : Vector3.left) * (FadeDistance * pow(1-_fadeLerp, FadePositionExponent));
|
||||
_currentMenu.group.alpha = pow(1 - _fadeLerp, FadeAlphaExponent);
|
||||
_nextMenu.group.alpha = pow(_fadeLerp, FadeAlphaExponent);
|
||||
|
||||
if (_fadeLerp > 1)
|
||||
{
|
||||
_fading = false;
|
||||
_currentMenu.panel.gameObject.SetActive(false);
|
||||
var temp = _currentMenu;
|
||||
_currentMenu = _nextMenu;
|
||||
_nextMenu = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string TitleSubtitle(string title, string subtitle) => $"{title}\n<smallcaps><size=50%>{subtitle}";
|
||||
|
||||
private void Fade(bool fromRight)
|
||||
{
|
||||
_nextMenu.panel.gameObject.SetActive(true);
|
||||
_nextMenu.group.alpha = 0;
|
||||
_fading = true;
|
||||
_fadeLerp = 0;
|
||||
_fadeFromRight = fromRight;
|
||||
}
|
||||
|
||||
private void ShowMain()
|
||||
{
|
||||
_nextMenu.panel.Clear();
|
||||
_nextMenu.panel.Title.text = TitleSubtitle("aetheria", "terminus");
|
||||
if (!InGame)
|
||||
{
|
||||
if(ActionGameManager.PlayerSettings.CurrentRun != null)
|
||||
_nextMenu.panel.AddButton("Continue",
|
||||
() =>
|
||||
{
|
||||
ActionGameManager.CurrentSector = new Sector(ActionGameManager.CultCache, ActionGameManager.PlayerSettings.CurrentRun);
|
||||
SceneManager.LoadScene("ARPG");
|
||||
});
|
||||
else
|
||||
_nextMenu.panel.AddButton("Continue", null);
|
||||
}
|
||||
_nextMenu.panel.AddButton("New Game",
|
||||
() =>
|
||||
{
|
||||
var generatorState = "Loading Database Contents";
|
||||
Action<string> setState = s => generatorState = s;
|
||||
|
||||
Fade(true);
|
||||
_nextMenu.panel.gameObject.SetActive(false);
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "Generating Galaxy";
|
||||
Dialog.AddProperty(() => generatorState);
|
||||
Dialog.Show();
|
||||
Settings.SectorGenerationSettings.NoisePosition = Random.value * 100;
|
||||
|
||||
var task = Task.Run(() => new Sector(Settings.SectorGenerationSettings, ActionGameManager.CultCache, 0, setState));
|
||||
task.ContinueWith(task => Observable.NextFrame().Subscribe(_ =>
|
||||
{
|
||||
ActionGameManager.PlayerSettings.CurrentRun = null;
|
||||
ActionGameManager.CurrentSector = task.Result;
|
||||
SceneManager.LoadScene("ARPG");
|
||||
}));
|
||||
});
|
||||
_nextMenu.panel.AddButton("Settings",
|
||||
() =>
|
||||
{
|
||||
ShowSettings();
|
||||
Fade(true);
|
||||
});
|
||||
_nextMenu.panel.AddButton("Quit", Application.Quit);
|
||||
}
|
||||
|
||||
private void ShowSettings()
|
||||
{
|
||||
_nextMenu.panel.Clear();
|
||||
_nextMenu.panel.Title.text = "settings";
|
||||
_nextMenu.panel.AddButton("Gameplay",
|
||||
() =>
|
||||
{
|
||||
ShowGameplaySettings();
|
||||
Fade(true);
|
||||
});
|
||||
_nextMenu.panel.AddButton("Graphics",
|
||||
() =>
|
||||
{
|
||||
ShowGraphicsSettings();
|
||||
Fade(true);
|
||||
});
|
||||
_nextMenu.panel.AddButton("Input",
|
||||
() =>
|
||||
{
|
||||
ShowInputSettings();
|
||||
Fade(true);
|
||||
});
|
||||
_nextMenu.panel.AddButton("Audio",
|
||||
() =>
|
||||
{
|
||||
ShowAudioSettings();
|
||||
Fade(true);
|
||||
});
|
||||
_nextMenu.panel.AddButton("Back",
|
||||
() =>
|
||||
{
|
||||
ShowMain();
|
||||
Fade(false);
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowGameplaySettings()
|
||||
{
|
||||
_nextMenu.panel.Clear();
|
||||
_nextMenu.panel.Title.text = TitleSubtitle("gameplay", "settings");
|
||||
_nextMenu.panel.AddField("Name",
|
||||
() => ActionGameManager.PlayerSettings.Name,
|
||||
s => ActionGameManager.PlayerSettings.Name = s);
|
||||
_nextMenu.panel.AddButton("Back",
|
||||
() =>
|
||||
{
|
||||
ActionGameManager.SavePlayerSettings();
|
||||
ShowSettings();
|
||||
Fade(false);
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowGraphicsSettings()
|
||||
{
|
||||
_nextMenu.panel.Clear();
|
||||
_nextMenu.panel.Title.text = TitleSubtitle("graphics", "settings");
|
||||
_nextMenu.panel.AddButton("Back",
|
||||
() =>
|
||||
{
|
||||
ShowSettings();
|
||||
Fade(false);
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowInputSettings()
|
||||
{
|
||||
_nextMenu.panel.Clear();
|
||||
_nextMenu.panel.Title.text = TitleSubtitle("input", "settings");
|
||||
_nextMenu.panel.AddButton("Back",
|
||||
() =>
|
||||
{
|
||||
ShowSettings();
|
||||
Fade(false);
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowAudioSettings()
|
||||
{
|
||||
_nextMenu.panel.Clear();
|
||||
_nextMenu.panel.Title.text = TitleSubtitle("audio", "settings");
|
||||
_nextMenu.panel.AddButton("Back",
|
||||
() =>
|
||||
{
|
||||
ShowSettings();
|
||||
Fade(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/MainMenu.cs.meta
Normal file
11
Assets/Scripts/UI/MainMenu.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3d7c7b928d043a3449b93bce9de03d1c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -19,10 +19,9 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
public float ZoomSpeed;
|
||||
public float MinViewSize = .1f;
|
||||
public float MaxViewSize = 2;
|
||||
public Button PathAnimationButton;
|
||||
public float PathAnimationDamping;
|
||||
public float PathAnimationDuration;
|
||||
public float PathAnimationDurationPadding = 1.1f;
|
||||
// public float PathAnimationDamping = .01f;
|
||||
// public float PathAnimationDuration = 30;
|
||||
// public float PathAnimationDurationPadding = 1.1f;
|
||||
public GameObject LegendPanel;
|
||||
public float LinkAnimationDuration;
|
||||
public float IconAnimationDuration;
|
||||
|
|
@ -34,7 +33,6 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
private Transform _sectorCameraTransform;
|
||||
private Image _outputImage;
|
||||
private RenderTexture _outputTexture;
|
||||
private Vector3[] _imageCorners = new Vector3[4];
|
||||
private int2 _size;
|
||||
private bool _init;
|
||||
private float _aspectRatio;
|
||||
|
|
@ -51,46 +49,40 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
_sectorBackgroundDepth = _sectorBackgroundTransform.position.z;
|
||||
_sectorCameraTransform = SectorCamera.transform;
|
||||
_sectorCameraDepth = _sectorCameraTransform.position.z;
|
||||
PathAnimationButton.onClick.AddListener(() =>
|
||||
{
|
||||
Map.StartCoroutine(AnimatePath());
|
||||
});
|
||||
// PathAnimationButton.onClick.AddListener(() =>
|
||||
// {
|
||||
// Map.StartCoroutine(AnimatePath());
|
||||
// });
|
||||
}
|
||||
|
||||
private IEnumerator AnimatePath()
|
||||
{
|
||||
var pathZones = ActionGameManager.CurrentSector.ExitPath;
|
||||
LegendPanel.SetActive(false);
|
||||
PathAnimationButton.gameObject.SetActive(false);
|
||||
foreach (var zones in ActionGameManager.CurrentSector.Zones
|
||||
.GroupBy(z=>z.Distance[ActionGameManager.CurrentSector.Entrance])
|
||||
.OrderBy(g=>g.Key))
|
||||
{
|
||||
Map.QueueZoneReveal(zones);
|
||||
}
|
||||
|
||||
var revealCount = ActionGameManager.CurrentSector.Entrance.Distance[ActionGameManager.CurrentSector.Exit];
|
||||
Map.StartReveal(
|
||||
PathAnimationDuration / revealCount * (LinkAnimationDuration / (IconAnimationDuration + LinkAnimationDuration)),
|
||||
PathAnimationDuration / revealCount * (IconAnimationDuration / (IconAnimationDuration + LinkAnimationDuration)));
|
||||
MainCamera.enabled = false;
|
||||
SectorCamera.targetTexture = null;
|
||||
Canvas.gameObject.SetActive(false);
|
||||
SectorCamera.gameObject.SetActive(true);
|
||||
|
||||
var pathAnimationLerp = 0f;
|
||||
while (pathAnimationLerp < 1)
|
||||
{
|
||||
var currentTargetZone = pathZones[(int) (pathZones.Length * pathAnimationLerp)];
|
||||
_position = lerp(_position, currentTargetZone.Position, PathAnimationDamping);
|
||||
pathAnimationLerp += Time.deltaTime / (PathAnimationDuration * PathAnimationDurationPadding);
|
||||
UpdateCamera();
|
||||
yield return null;
|
||||
}
|
||||
|
||||
LegendPanel.SetActive(true);
|
||||
PathAnimationButton.gameObject.SetActive(true);
|
||||
}
|
||||
// private IEnumerator AnimatePath()
|
||||
// {
|
||||
// var pathZones = ActionGameManager.CurrentSector.ExitPath;
|
||||
// LegendPanel.SetActive(false);
|
||||
// PathAnimationButton.gameObject.SetActive(false);
|
||||
//
|
||||
// var revealCount = ActionGameManager.CurrentSector.Entrance.Distance[ActionGameManager.CurrentSector.Exit];
|
||||
// Map.StartReveal(
|
||||
// PathAnimationDuration / revealCount * (LinkAnimationDuration / (IconAnimationDuration + LinkAnimationDuration)),
|
||||
// PathAnimationDuration / revealCount * (IconAnimationDuration / (IconAnimationDuration + LinkAnimationDuration)));
|
||||
// MainCamera.enabled = false;
|
||||
// SectorCamera.targetTexture = null;
|
||||
// Canvas.gameObject.SetActive(false);
|
||||
// SectorCamera.gameObject.SetActive(true);
|
||||
//
|
||||
// var pathAnimationLerp = 0f;
|
||||
// while (pathAnimationLerp < 1)
|
||||
// {
|
||||
// var currentTargetZone = pathZones[(int) (pathZones.Length * pathAnimationLerp)];
|
||||
// _position = lerp(_position, currentTargetZone.Position, PathAnimationDamping);
|
||||
// pathAnimationLerp += Time.deltaTime / (PathAnimationDuration * PathAnimationDurationPadding);
|
||||
// UpdateCamera();
|
||||
// yield return null;
|
||||
// }
|
||||
//
|
||||
// LegendPanel.SetActive(true);
|
||||
// PathAnimationButton.gameObject.SetActive(true);
|
||||
// }
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue