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:
Reinier Vens 2021-04-09 14:01:34 +01:00
commit ca1ce9859d
47 changed files with 5106 additions and 2385 deletions

View file

@ -1146,13 +1146,21 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
},
{
""name"": ""MainMenu"",
""type"": ""Button"",
""id"": ""a626132e-6205-4abb-9a45-4cce6446958b"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
}
],
""bindings"": [
{
""name"": """",
""id"": ""7eadec25-7b3f-4d69-92b7-c756f5f9b0dd"",
""path"": ""<Keyboard>/m"",
""path"": ""<Keyboard>/tab"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard&Mouse"",
@ -1181,6 +1189,17 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
""action"": ""Dock"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""7de0bb82-5492-49aa-aa56-8562b58ba8a8"",
""path"": ""<Keyboard>/escape"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard&Mouse"",
""action"": ""MainMenu"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
@ -1268,6 +1287,7 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
m_Global_MapToggle = m_Global.FindAction("Map Toggle", throwIfNotFound: true);
m_Global_Inventory = m_Global.FindAction("Inventory", throwIfNotFound: true);
m_Global_Dock = m_Global.FindAction("Dock", throwIfNotFound: true);
m_Global_MainMenu = m_Global.FindAction("MainMenu", throwIfNotFound: true);
}
public void Dispose()
@ -1634,6 +1654,7 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
private readonly InputAction m_Global_MapToggle;
private readonly InputAction m_Global_Inventory;
private readonly InputAction m_Global_Dock;
private readonly InputAction m_Global_MainMenu;
public struct GlobalActions
{
private @AetheriaInput m_Wrapper;
@ -1641,6 +1662,7 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
public InputAction @MapToggle => m_Wrapper.m_Global_MapToggle;
public InputAction @Inventory => m_Wrapper.m_Global_Inventory;
public InputAction @Dock => m_Wrapper.m_Global_Dock;
public InputAction @MainMenu => m_Wrapper.m_Global_MainMenu;
public InputActionMap Get() { return m_Wrapper.m_Global; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
@ -1659,6 +1681,9 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
@Dock.started -= m_Wrapper.m_GlobalActionsCallbackInterface.OnDock;
@Dock.performed -= m_Wrapper.m_GlobalActionsCallbackInterface.OnDock;
@Dock.canceled -= m_Wrapper.m_GlobalActionsCallbackInterface.OnDock;
@MainMenu.started -= m_Wrapper.m_GlobalActionsCallbackInterface.OnMainMenu;
@MainMenu.performed -= m_Wrapper.m_GlobalActionsCallbackInterface.OnMainMenu;
@MainMenu.canceled -= m_Wrapper.m_GlobalActionsCallbackInterface.OnMainMenu;
}
m_Wrapper.m_GlobalActionsCallbackInterface = instance;
if (instance != null)
@ -1672,6 +1697,9 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
@Dock.started += instance.OnDock;
@Dock.performed += instance.OnDock;
@Dock.canceled += instance.OnDock;
@MainMenu.started += instance.OnMainMenu;
@MainMenu.performed += instance.OnMainMenu;
@MainMenu.canceled += instance.OnMainMenu;
}
}
}
@ -1747,5 +1775,6 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
void OnMapToggle(InputAction.CallbackContext context);
void OnInventory(InputAction.CallbackContext context);
void OnDock(InputAction.CallbackContext context);
void OnMainMenu(InputAction.CallbackContext context);
}
}

View file

@ -83,15 +83,17 @@ public class ActionGameManager : MonoBehaviour
public Prototype LockIndicator;
public PlaceUIElementWorldspace[] Crosshairs;
public EventLog EventLog;
[FormerlySerializedAs("SectorRenderer")] public ZoneRenderer ZoneRenderer;
public ZoneRenderer ZoneRenderer;
public CinemachineVirtualCamera DockCamera;
public CinemachineVirtualCamera FollowCamera;
public CinemachineVirtualCamera WormholeCamera;
public CanvasGroup GameplayUI;
public MainMenu MainMenu;
public MenuPanel Menu;
public MapRenderer MenuMap;
//public SectorRenderer SectorRenderer;
public SectorMap SectorMap;
public VolumeSampling VolumeRenderer;
public SchematicDisplay SchematicDisplay;
public SchematicDisplay TargetSchematicDisplay;
public InventoryMenu Inventory;
@ -107,7 +109,7 @@ public class ActionGameManager : MonoBehaviour
// private CinemachineComposer _composer;
private DirectoryInfo _loadoutPath;
private bool _editMode;
private bool _paused;
private float _time;
private int _zoomLevelIndex;
private Entity _currentEntity;
@ -121,6 +123,7 @@ public class ActionGameManager : MonoBehaviour
private List<IDisposable> _shipSubscriptions = new List<IDisposable>();
private float _severeHeatstrokePhase;
private bool _uiHidden;
private bool _menuShown;
public AetheriaInput Input { get; private set; }
public EquippedDockingBay DockingBay { get; private set; }
@ -167,6 +170,11 @@ public class ActionGameManager : MonoBehaviour
SavePlayerSettings();
}
private void OnDisable()
{
Input.Dispose();
}
void Start()
{
EntityInstance.EffectManagerParent = EffectManagerParent;
@ -195,6 +203,7 @@ public class ActionGameManager : MonoBehaviour
Input.Global.MapToggle.performed += context =>
{
if (MainMenu.gameObject.activeSelf) return;
if (Menu.gameObject.activeSelf && Menu.CurrentTab == MenuTab.Map)
{
Cursor.lockState = CursorLockMode.Locked;
@ -220,6 +229,7 @@ public class ActionGameManager : MonoBehaviour
Input.Global.Inventory.performed += context =>
{
if (MainMenu.gameObject.activeSelf) return;
if (Menu.gameObject.activeSelf && Menu.CurrentTab == MenuTab.Inventory)
{
Cursor.lockState = CursorLockMode.Locked;
@ -243,6 +253,7 @@ public class ActionGameManager : MonoBehaviour
Input.Global.Dock.performed += context =>
{
if (MainMenu.gameObject.activeSelf) return;
if (CurrentEntity == null)
{
AkSoundEngine.PostEvent("UI_Fail", gameObject);
@ -255,6 +266,44 @@ public class ActionGameManager : MonoBehaviour
else Undock();
};
Input.Global.MainMenu.performed += context =>
{
if (CurrentEntity == null) return;
if (MainMenu.gameObject.activeSelf)
{
_paused = false;
VolumeRenderer.EnableDepth = true;
MainMenu.gameObject.SetActive(false);
if (_menuShown)
{
Menu.gameObject.SetActive(true);
}
else
{
GameplayUI.gameObject.SetActive(true);
Cursor.lockState = CursorLockMode.Locked;
Input.Player.Enable();
}
}
else
{
_paused = true;
VolumeRenderer.EnableDepth = false;
MainMenu.gameObject.SetActive(true);
_menuShown = Menu.gameObject.activeSelf;
if (_menuShown)
{
Menu.gameObject.SetActive(false);
}
else
{
GameplayUI.gameObject.SetActive(false);
Cursor.lockState = CursorLockMode.None;
Input.Player.Disable();
}
}
};
Input.Player.EnterWormhole.performed += context =>
{
if(CurrentEntity is Ship ship)
@ -274,6 +323,8 @@ public class ActionGameManager : MonoBehaviour
ship.OnEnteredWormhole += () =>
{
PopulateLevel(wormhole.Target);
foreach(var zone in wormhole.Target.AdjacentZones)
CurrentSector.DiscoveredZones.Add(zone);
SectorMap.QueueZoneReveal(wormhole.Target.AdjacentZones);
ship.ExitWormhole(ZoneRenderer.WormholeInstances.Keys.First(w=>w.Target==oldZone.SectorZone).Position,
Settings.GameplaySettings.WormholeExitVelocity * ItemManager.Random.NextFloat2Direction());
@ -320,27 +371,33 @@ public class ActionGameManager : MonoBehaviour
Input.Player.TargetReticle.performed += context =>
{
var underReticle = Zone.Entities.Where(x => x != CurrentEntity)
if (!CurrentEntity.VisibleHostiles.Any()) return;
var underReticle = CurrentEntity.VisibleHostiles.Where(x => x != CurrentEntity)
.MaxBy(x => dot(normalize(x.Position - CurrentEntity.Position), CurrentEntity.LookDirection));
CurrentEntity.Target.Value = CurrentEntity.Target.Value == underReticle ? null : underReticle;
};
Input.Player.TargetNearest.performed += context =>
{
CurrentEntity.Target.Value = Zone.Entities.Where(x=>x!=CurrentEntity)
.MaxBy(x => length(x.Position - CurrentEntity.Position));
if(CurrentEntity.VisibleHostiles.Any())
{
CurrentEntity.Target.Value = CurrentEntity.VisibleHostiles.Where(x => x != CurrentEntity)
.MaxBy(x => length(x.Position - CurrentEntity.Position));
}
};
Input.Player.TargetNext.performed += context =>
{
var targets = Zone.Entities.Where(x => x != CurrentEntity).OrderBy(x => length(x.Position - CurrentEntity.Position)).ToArray();
if (!CurrentEntity.VisibleHostiles.Any()) return;
var targets = CurrentEntity.VisibleHostiles.Where(x => x != CurrentEntity).OrderBy(x => length(x.Position - CurrentEntity.Position)).ToArray();
var currentTargetIndex = Array.IndexOf(targets, CurrentEntity.Target.Value);
CurrentEntity.Target.Value = targets[(currentTargetIndex + 1) % targets.Length];
};
Input.Player.TargetPrevious.performed += context =>
{
var targets = Zone.Entities.Where(x => x != CurrentEntity).OrderBy(x => length(x.Position - CurrentEntity.Position)).ToArray();
if (!CurrentEntity.VisibleHostiles.Any()) return;
var targets = CurrentEntity.VisibleHostiles.Where(x => x != CurrentEntity).OrderBy(x => length(x.Position - CurrentEntity.Position)).ToArray();
var currentTargetIndex = Array.IndexOf(targets, CurrentEntity.Target.Value);
CurrentEntity.Target.Value = targets[(currentTargetIndex + targets.Length - 1) % targets.Length];
};
@ -472,6 +529,18 @@ public class ActionGameManager : MonoBehaviour
StartGame();
ConsoleController.AddCommand("revealzones",
_ =>
{
foreach (var zones in CurrentSector.Zones
.Where(z=>!CurrentSector.DiscoveredZones.Contains(z))
.GroupBy(z=>z.Distance[CurrentSector.Entrance])
.OrderBy(g=>g.Key))
{
SectorMap.QueueZoneReveal(zones);
}
});
ConsoleController.AddCommand("give",
args =>
{
@ -601,6 +670,9 @@ public class ActionGameManager : MonoBehaviour
}
else
{
foreach(var group in CurrentSector.DiscoveredZones
.GroupBy(dz=>dz.Distance[CurrentSector.Entrance]))
SectorMap.QueueZoneReveal(group);
PopulateLevel(CurrentSector.Zones[PlayerSettings.CurrentRun.CurrentZone]);
var targetEntity = Zone.Entities[PlayerSettings.CurrentRun.CurrentZoneEntity];
if (targetEntity is OrbitalEntity orbitalEntity)
@ -826,15 +898,12 @@ public class ActionGameManager : MonoBehaviour
var deathTime = Time.time;
UnbindEntity();
CurrentEntity = null;
// Dialog.Clear();
// Dialog.Title.text = "You have died!";
// Dialog.Show(() =>
// {
// PlayerSettings.CurrentRun = null;
// StartGame();
// }, null, "Try again!");
// Dialog.transform.position = new Vector3(Screen.width / 2, Screen.height / 2);
//Dialog.MoveToCursor();
VolumeRenderer.EnableDepth = false;
MainMenu.gameObject.SetActive(true);
Menu.gameObject.SetActive(false);
PlayerSettings.CurrentRun = null;
SavePlayerSettings();
SaveState();
Observable.EveryUpdate()
.Where(_ => Time.time - deathTime < DeathPPTransitionTime)
.Subscribe(_ =>
@ -894,10 +963,10 @@ public class ActionGameManager : MonoBehaviour
void Update()
{
if(!_editMode)
if(!_paused)
{
_time += Time.deltaTime;
ItemManager.Time = Time.time;
// ItemManager.Time = _time;
if(CurrentEntity !=null && CurrentEntity.Parent==null)
{
foreach (var indicator in _visibleHostileIndicators)
@ -925,8 +994,8 @@ public class ActionGameManager : MonoBehaviour
ship.MovementDirection = Input.Player.Move.ReadValue<Vector2>();
}
}
Zone.Update(Time.deltaTime);
}
Zone.Update(Time.deltaTime);
}
private void LateUpdate()

View file

@ -8,7 +8,7 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class CapacitorData : BehaviorData
{
[Inspectable, JsonProperty("capacity"), Key(1), RuntimeInspectable]

View file

@ -8,7 +8,7 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class CockpitData : BehaviorData
{
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -8,7 +8,7 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class HeatStorageData : BehaviorData
{
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -7,7 +7,7 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class RadiatorData : BehaviorData
{
[Inspectable, JsonProperty("emissivity"), Key(1), RuntimeInspectable]

View file

@ -10,7 +10,7 @@ using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class ReactorData : BehaviorData
{
[Inspectable, JsonProperty("charge"), Key(1), RuntimeInspectable]

View file

@ -7,7 +7,7 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class ShieldData : BehaviorData
{
[Inspectable, JsonProperty("efficiency"), Key(1), RuntimeInspectable]

View file

@ -7,7 +7,7 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
public class ThrusterData : BehaviorData
{
[Inspectable, JsonProperty("thrust"), Key(1), RuntimeInspectable]

View file

@ -10,7 +10,8 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Union(0, typeof(InstantWeaponData)),
[Inspectable,
Union(0, typeof(InstantWeaponData)),
Union(1, typeof(LauncherData)),
Union(2, typeof(ConstantWeaponData)),
Union(3, typeof(ChargedWeaponData)),

View file

@ -8,7 +8,7 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(1000), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(1000), RuntimeInspectable]
public class WearData : BehaviorData
{
[InspectableTemperature, JsonProperty("perSecond"), Key(1)]

View file

@ -6,6 +6,7 @@ public class GlobalSettingsAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Class)]
public class ExternalEntryAttribute : Attribute { }
[AttributeUsage(AttributeTargets.All, Inherited = false)]
public class InspectableAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field)]

View file

@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using MessagePack.ReactivePropertyExtension;
using MessagePack.Resolvers;
public static class RegisterResolver
@ -15,7 +16,8 @@ public static class RegisterResolver
MathResolver.Instance,
TypeResolver.Instance,
NativeGuidResolver.Instance,
StandardResolver.Instance
StandardResolver.Instance,
ReactivePropertyResolver.Instance
);
var options = MessagePackSerializerOptions.Standard.WithResolver(resolver);
MessagePackSerializer.DefaultOptions = options;

View file

@ -393,7 +393,7 @@ public class DockingBayData : CargoBayData
public int2 MaxSize;
}
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[RethinkTable("Items"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class WeaponItemData : GearData
{
[Inspectable, JsonProperty("range"), Key(21)]

View file

@ -34,16 +34,16 @@ public class ItemManager
public CultCache ItemData { get; }
public GameplaySettings GameplaySettings { get; }
public double Time
{
get => _time;
set
{
_deltaTime = (float) (value - _time);
_time = value;
//Log($"GameContext delta time: {_deltaTime}");
}
}
// public double Time
// {
// get => _time;
// set
// {
// _deltaTime = (float) (value - _time);
// _time = value;
// //Log($"GameContext delta time: {_deltaTime}");
// }
// }
// private readonly Dictionary<CraftedItemData, int> Tier = new Dictionary<CraftedItemData, int>();

View file

@ -34,11 +34,15 @@ public class SavedGame
[Key(8)]
public SectorGenerationSettings Settings;
[Key(9)]
public int[] DiscoveredZones;
public SavedGame() { }
public SavedGame(Sector sector, Zone currentZone, Entity currentEntity)
{
DiscoveredZones = sector.DiscoveredZones.Select(dz => Array.IndexOf(sector.Zones, dz)).ToArray();
Settings = sector.Settings;
Factions = sector.HomeZones.Keys.Select(f => f.ID).ToArray();

View file

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using DataStructures.ViliWonka.Heap;
using MIConvexHull;
using JM.LinqFaster;
using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using Random = Unity.Mathematics.Random;
@ -14,6 +15,7 @@ public class Sector
{
public Dictionary<Faction, SectorZone> HomeZones = new Dictionary<Faction, SectorZone>();
public Dictionary<Faction, SectorZone> BossZones = new Dictionary<Faction, SectorZone>();
public HashSet<SectorZone> DiscoveredZones = new HashSet<SectorZone>();
public SectorGenerationSettings Settings { get; }
public Faction[] Factions { get; }
@ -46,6 +48,7 @@ public class Sector
PackedContents = zone.Contents
};
}).ToArray();
foreach (var i in savedGame.DiscoveredZones) DiscoveredZones.Add(Zones[i]);
for (var i = 0; i < Zones.Length; i++)
{
Zones[i].AdjacentZones = savedGame.Zones[i].AdjacentZones.Select(azi => Zones[azi]).ToList();
@ -165,6 +168,9 @@ public class Sector
// Entrance is the zone furthest from the exit
Entrance = Zones.MaxBy(z => Exit.Distance[z]);
DiscoveredZones.Add(Entrance);
foreach(var z in Entrance.AdjacentZones) DiscoveredZones.Add(z);
// Find all zones on the exit path where removing that zone would disconnect the entrance from the exit
// Disregard "corridor" zones with only two adjacent zones
var chokePoints = ExitPath

View file

@ -26,6 +26,7 @@ public class PlanetSettings
public ExponentialCurve FogTintRadius;
public ExponentialCurve LightRadius;
public ExponentialCurve BodyRadius;
public float AsteroidVerticalOffset = -5f;
public ExponentialLerp AsteroidSize;
public ExponentialLerp AsteroidHitpoints;
public ExponentialLerp AsteroidRespawnTime;

View file

@ -239,7 +239,7 @@ public class Zone
var pos = OrbitData.Evaluate((float) frac(_time / Settings.OrbitPeriod.Evaluate(beltData.Asteroids[i].Distance) +
beltData.Asteroids[i].Phase)) * beltData.Asteroids[i].Distance + orbitPosition;
belt.NewVelocities[i] = pos - belt.Positions[i].xz;
belt.NewPositions[i] = float3(pos.x, GetHeight(pos), pos.y);
belt.NewPositions[i] = float3(pos.x, GetHeight(pos) + Settings.AsteroidVerticalOffset, pos.y);
}
}

View file

@ -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;

View file

@ -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()
{

View file

@ -18,11 +18,21 @@ public class VolumeSampling : MonoBehaviour
{
public Material _volMaterial;
public Transform GridTransform;
//public int DownsampleBlurMask = 2;
private Camera _camera;
private RenderBuffer[] _mrt;
private RenderTexture _blurMask;
private Texture2D _disabledBlurMask;
public bool EnableDepth { get; set; } = true;
private void Start()
{
//Debug.Log($"Supported MRT count: {SystemInfo.supportedRenderTargetCount}");
_camera = GetComponent<Camera>();
_mrt = new RenderBuffer[2];
_blurMask = new RenderTexture(Screen.width, Screen.height, 0, GraphicsFormat.R8_UNorm);
_disabledBlurMask = Color.black.ToTexture();
}
[ImageEffectOpaque]
@ -43,6 +53,19 @@ public class VolumeSampling : MonoBehaviour
if(GridTransform != null)
_volMaterial.SetVector("_GridTransform", new Vector4(GridTransform.position.x,GridTransform.position.z,GridTransform.localScale.x));
Graphics.Blit( source, destination, _volMaterial, 0 );
_mrt[0] = destination.colorBuffer;
_mrt[1] = _blurMask.colorBuffer;
// Blit with a MRT.
Graphics.SetRenderTarget(_mrt, source.depthBuffer);
Graphics.Blit( source, _volMaterial, 0 );
//Graphics.Blit(rt1, destination);
if(EnableDepth)
Shader.SetGlobalTexture("_DoFBlurTex", _blurMask);
else
Shader.SetGlobalTexture("_DoFBlurTex", _disabledBlurMask);
}
}