Initial ARPG Port
ARPG scene assets from old project are now correctly visualizing sectors generated by ZoneGenerator and updated by GameContext
This commit is contained in:
parent
1e2b474fc1
commit
d12d7c5c45
379 changed files with 42700 additions and 7253 deletions
11
Assets/Scripts/Sector Display/GasGiantObject.cs
Normal file
11
Assets/Scripts/Sector Display/GasGiantObject.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GasGiantObject : PlanetObject
|
||||
{
|
||||
public SunMaterial SunMaterial;
|
||||
public GradientMapper GradientMapper;
|
||||
public MeshRenderer GravityWaves;
|
||||
public WaveScroll WaveScroll;
|
||||
}
|
||||
11
Assets/Scripts/Sector Display/GasGiantObject.cs.meta
Normal file
11
Assets/Scripts/Sector Display/GasGiantObject.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 71ac44e29296d7541afb153524b80e14
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Assets/Scripts/Sector Display/PlanetObject.cs
Normal file
11
Assets/Scripts/Sector Display/PlanetObject.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlanetObject : MonoBehaviour
|
||||
{
|
||||
public MeshRenderer Body;
|
||||
public SnapToGrid GridSnap;
|
||||
public MeshRenderer GravityWell;
|
||||
public MeshRenderer Icon;
|
||||
}
|
||||
11
Assets/Scripts/Sector Display/PlanetObject.cs.meta
Normal file
11
Assets/Scripts/Sector Display/PlanetObject.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a4734f48262f7de46b0a34d7f3fdbe90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/Scripts/Sector Display/SectorDisplayProperties.cs
Normal file
21
Assets/Scripts/Sector Display/SectorDisplayProperties.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName = "Sector Display Properties", menuName = "Aetheria/Sector Display Properties")]
|
||||
public class SectorDisplayProperties : ScriptableObject
|
||||
{
|
||||
public float DefaultViewDistance;
|
||||
public float DefaultMinimapDistance;
|
||||
public ExponentialCurve BodyDiameter;
|
||||
public ExponentialCurve GravityDepth;
|
||||
public ExponentialCurve GravityRadius;
|
||||
public ExponentialCurve WaveDepth;
|
||||
public ExponentialCurve WaveRadius;
|
||||
public ExponentialCurve WaveFrequency;
|
||||
public ExponentialCurve WaveSpeed;
|
||||
public ExponentialCurve FogTintRadius;
|
||||
public ExponentialCurve LightRadius;
|
||||
public Gradient DefaultGradient;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0d957fc3cdc9310499a3a494a317fe0a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
141
Assets/Scripts/Sector Display/SectorRenderer.cs
Normal file
141
Assets/Scripts/Sector Display/SectorRenderer.cs
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cinemachine;
|
||||
using UnityEngine;
|
||||
|
||||
public class SectorRenderer : MonoBehaviour
|
||||
{
|
||||
public Transform FogCameraParent;
|
||||
public SectorDisplayProperties Properties;
|
||||
public Transform SectorRoot;
|
||||
public Transform SectorBrushes;
|
||||
public CinemachineVirtualCamera SceneCamera;
|
||||
public Camera[] FogCameras;
|
||||
public Camera[] MinimapCameras;
|
||||
public Material FogMaterial;
|
||||
public ActionGameManager Manager;
|
||||
public float FogFarFadeFraction = .125f;
|
||||
public float FarPlaneDistanceMultiplier = 2;
|
||||
|
||||
[Header("Prefabs")]
|
||||
public GameObject Belt;
|
||||
public PlanetObject Planet;
|
||||
public GasGiantObject GasGiant;
|
||||
public SunObject Sun;
|
||||
|
||||
[Header("Icons")]
|
||||
public Texture2D PlanetoidIcon;
|
||||
public Texture2D PlanetIcon;
|
||||
|
||||
private Dictionary<Guid, Transform> _planets = new Dictionary<Guid, Transform>();
|
||||
private Zone _zone;
|
||||
private float _viewDistance;
|
||||
|
||||
public float ViewDistance
|
||||
{
|
||||
set
|
||||
{
|
||||
_viewDistance = value;
|
||||
foreach (var camera in FogCameras)
|
||||
camera.orthographicSize = value;
|
||||
SceneCamera.m_Lens.FarClipPlane = value * FarPlaneDistanceMultiplier;
|
||||
FogMaterial.SetFloat("_DepthCeiling", value - FogFarFadeFraction * value);
|
||||
FogMaterial.SetFloat("_DepthBlend", FogFarFadeFraction * value);
|
||||
}
|
||||
}
|
||||
|
||||
public float MinimapDistance
|
||||
{
|
||||
set
|
||||
{
|
||||
foreach(var camera in MinimapCameras)
|
||||
camera.orthographicSize = value * 2;
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
LoadZone(Manager.CurrentZone);
|
||||
ViewDistance = Properties.DefaultViewDistance;
|
||||
MinimapDistance = Properties.DefaultMinimapDistance;
|
||||
Manager.ZoneChanged += (_, args) => LoadZone(args.NewZone);
|
||||
}
|
||||
|
||||
void LoadZone(Zone zone)
|
||||
{
|
||||
_zone = zone;
|
||||
SectorBrushes.localScale = zone.Data.Radius * 2 * Vector3.one;
|
||||
if (_planets.Count > 0)
|
||||
{
|
||||
foreach (var planet in _planets.Values)
|
||||
{
|
||||
Destroy(planet.gameObject);
|
||||
}
|
||||
_planets.Clear();
|
||||
}
|
||||
foreach(var p in zone.Planets.Values)
|
||||
LoadPlanet(p);
|
||||
}
|
||||
|
||||
void LoadPlanet(PlanetData planetData)
|
||||
{
|
||||
if (planetData is AsteroidBeltData beltData)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
PlanetObject planet;
|
||||
if (planetData is GasGiantData gasGiantData)
|
||||
{
|
||||
if (planetData is SunData sunData)
|
||||
{
|
||||
planet = Instantiate(Sun, SectorRoot);
|
||||
var sun = (SunObject) planet;
|
||||
sun.Light.color = sunData.LightColor;
|
||||
sun.Light.range = Properties.LightRadius.Evaluate(sunData.Mass);
|
||||
sun.FogTint.material.SetColor("_Color", sunData.FogTintColor);
|
||||
sun.FogTint.transform.localScale = Properties.FogTintRadius.Evaluate(sunData.Mass) * Vector3.one;
|
||||
}
|
||||
else planet = Instantiate(GasGiant, SectorRoot);
|
||||
|
||||
var gas = (GasGiantObject) planet;
|
||||
gas.GradientMapper.ApplyGradient(gasGiantData.Colors);
|
||||
gas.SunMaterial.AlbedoRotationSpeed = gasGiantData.AlbedoRotationSpeed;
|
||||
gas.SunMaterial.FirstOffsetRotationSpeed = gasGiantData.AlbedoRotationSpeed;
|
||||
gas.SunMaterial.SecondOffsetRotationSpeed = gasGiantData.AlbedoRotationSpeed;
|
||||
gas.SunMaterial.FirstOffsetDomainRotationSpeed = gasGiantData.AlbedoRotationSpeed;
|
||||
gas.SunMaterial.SecondOffsetDomainRotationSpeed = gasGiantData.AlbedoRotationSpeed;
|
||||
gas.GravityWaves.material.SetFloat("_Depth", Properties.WaveDepth.Evaluate(planetData.Mass));
|
||||
gas.GravityWaves.material.SetFloat("_Frequency", Properties.WaveFrequency.Evaluate(planetData.Mass));
|
||||
gas.WaveScroll.Speed = Properties.WaveSpeed.Evaluate(planetData.Mass);
|
||||
gas.GravityWaves.transform.localScale = Properties.WaveRadius.Evaluate(planetData.Mass) * Vector3.one;
|
||||
}
|
||||
else
|
||||
{
|
||||
planet = Instantiate(Planet, SectorRoot);
|
||||
planet.Icon.material.mainTexture = planetData.Mass > Manager.Context.GlobalData.PlanetMass ? PlanetIcon : PlanetoidIcon;
|
||||
}
|
||||
|
||||
var diameter = Properties.BodyDiameter.Evaluate(planetData.Mass);
|
||||
planet.Body.transform.localScale = diameter * Vector3.one;
|
||||
planet.GravityWell.transform.localScale = Properties.GravityRadius.Evaluate(planetData.Mass) * Vector3.one;
|
||||
planet.GravityWell.material.SetFloat("_Depth", Properties.GravityDepth.Evaluate(planetData.Mass));
|
||||
planet.GridSnap.Offset = diameter * 2;
|
||||
|
||||
_planets.Add(planetData.ID, planet.transform);
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
foreach (var planet in _planets)
|
||||
{
|
||||
planet.Value.position = ((Vector2) _zone.GetOrbitPosition(_zone.Planets[planet.Key].Orbit)).Flatland();
|
||||
}
|
||||
|
||||
var pos = FogCameraParent.position;
|
||||
FogMaterial.SetVector("_GridTransform", new Vector4(pos.x,pos.z,_viewDistance*2));
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Sector Display/SectorRenderer.cs.meta
Normal file
11
Assets/Scripts/Sector Display/SectorRenderer.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bed3b49fe74863340b2a75f3d0517e86
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 300
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
45
Assets/Scripts/Sector Display/SnapToGrid.cs
Normal file
45
Assets/Scripts/Sector Display/SnapToGrid.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SnapToGrid : MonoBehaviour
|
||||
{
|
||||
public bool SnapPosition = false;
|
||||
public bool SnapRotation = false;
|
||||
public bool ApplyForces = false;
|
||||
|
||||
// public float RotationDamping = .5f;
|
||||
// public float PositionDamping = .1f;
|
||||
public float ForceScale = 1;
|
||||
public float Offset = 0;
|
||||
public float NormalMultiplier = 100;
|
||||
public float GravityGradientStep = .01f;
|
||||
|
||||
private Rigidbody _body;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
_body = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void LateUpdate () {
|
||||
var pos = new Vector2(transform.position.x,transform.position.z);
|
||||
|
||||
if(SnapPosition)
|
||||
transform.position = new Vector3(pos.x, Gravity.GetHeight(pos) + Offset,pos.y);
|
||||
if (SnapRotation)
|
||||
{
|
||||
var normal = Gravity.GetNormal(pos, GravityGradientStep, NormalMultiplier);
|
||||
var forward = Vector3.Cross(transform.right, normal);
|
||||
transform.rotation = Quaternion.LookRotation(forward, normal);
|
||||
}
|
||||
|
||||
if (ApplyForces)
|
||||
{
|
||||
//var currentVelocity = _body.velocity;
|
||||
var force = Gravity.GetForce(pos) * ForceScale;
|
||||
_body.AddForce(force.x,0,force.y,ForceMode.Acceleration);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Sector Display/SnapToGrid.cs.meta
Normal file
11
Assets/Scripts/Sector Display/SnapToGrid.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ac1be54714e52c640b08fe5059519a37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
58
Assets/Scripts/Sector Display/SunMaterial.cs
Normal file
58
Assets/Scripts/Sector Display/SunMaterial.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
//[ExecuteInEditMode]
|
||||
public class SunMaterial : MonoBehaviour
|
||||
{
|
||||
public float SpeedMultiplier = 1;
|
||||
public float FirstOffsetDomainRotationSpeed = .01f;
|
||||
public float FirstOffsetRotationSpeed = .01f;
|
||||
public float SecondOffsetDomainRotationSpeed = .01f;
|
||||
public float SecondOffsetRotationSpeed = .01f;
|
||||
public float AlbedoRotationSpeed = .01f;
|
||||
public Vector3 LightingDirection;
|
||||
|
||||
private float _firstOffsetDomainRotation;
|
||||
private float _firstOffsetRotation;
|
||||
private float _secondOffsetDomainRotation;
|
||||
private float _secondOffsetRotation;
|
||||
private float _albedoRotation;
|
||||
|
||||
private Material _material;
|
||||
private Orbit _orbit;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
var mesh = GetComponent<MeshRenderer>();
|
||||
if (mesh == null)
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_material = mesh.material;
|
||||
|
||||
_firstOffsetDomainRotation = Random.value * Mathf.PI;
|
||||
_firstOffsetRotation = Random.value * Mathf.PI;
|
||||
_secondOffsetDomainRotation = Random.value * Mathf.PI;
|
||||
_secondOffsetRotation = Random.value * Mathf.PI;
|
||||
_albedoRotation = Random.value * Mathf.PI;
|
||||
}
|
||||
|
||||
private void OnWillRenderObject()
|
||||
{
|
||||
_firstOffsetDomainRotation = FirstOffsetDomainRotationSpeed * SpeedMultiplier * Time.time;
|
||||
_firstOffsetRotation = FirstOffsetRotationSpeed * SpeedMultiplier * Time.time;
|
||||
_secondOffsetDomainRotation = SecondOffsetDomainRotationSpeed * SpeedMultiplier * Time.time;
|
||||
_secondOffsetRotation = SecondOffsetRotationSpeed * SpeedMultiplier * Time.time;
|
||||
_albedoRotation = AlbedoRotationSpeed * SpeedMultiplier * Time.time;
|
||||
|
||||
_material.SetVector("_LightingDirection", LightingDirection);
|
||||
_material.SetMatrix("_FirstOffsetDomainRotation", Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, Mathf.Rad2Deg * _firstOffsetDomainRotation, 0), Vector3.one));
|
||||
_material.SetMatrix("_FirstOffsetRotation", Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(Mathf.Rad2Deg * Mathf.Sin(_firstOffsetRotation), Mathf.Rad2Deg * Mathf.Cos(_firstOffsetRotation), 0), Vector3.one));
|
||||
_material.SetMatrix("_SecondOffsetDomainRotation", Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, Mathf.Rad2Deg * _secondOffsetDomainRotation, 0), Vector3.one));
|
||||
_material.SetMatrix("_SecondOffsetRotation", Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(Mathf.Rad2Deg * Mathf.Sin(_secondOffsetRotation), Mathf.Rad2Deg * Mathf.Cos(_secondOffsetRotation), 0), Vector3.one));
|
||||
_material.SetMatrix("_AlbedoRotation", Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, Mathf.Rad2Deg * _albedoRotation, 0), Vector3.one));
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Sector Display/SunMaterial.cs.meta
Normal file
11
Assets/Scripts/Sector Display/SunMaterial.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3c2eb8fe081f14940a7208cbdc3d97f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Scripts/Sector Display/SunObject.cs
Normal file
9
Assets/Scripts/Sector Display/SunObject.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SunObject : GasGiantObject
|
||||
{
|
||||
public MeshRenderer FogTint;
|
||||
public Light Light;
|
||||
}
|
||||
11
Assets/Scripts/Sector Display/SunObject.cs.meta
Normal file
11
Assets/Scripts/Sector Display/SunObject.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4eb3240728e3b024db554fa4f864dda7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/Scripts/Sector Display/VolumeSampling.cs
Normal file
39
Assets/Scripts/Sector Display/VolumeSampling.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Drives the volume render.
|
||||
/// </summary>
|
||||
//[ExecuteInEditMode]
|
||||
[RequireComponent( typeof( Camera ) ), ImageEffectAllowedInSceneView]
|
||||
public class VolumeSampling : MonoBehaviour
|
||||
{
|
||||
public Material _volMaterial;
|
||||
public Transform GridTransform;
|
||||
private Camera _camera;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_camera = GetComponent<Camera>();
|
||||
}
|
||||
|
||||
[ImageEffectOpaque]
|
||||
void OnRenderImage(RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
// check for no shader / shader compile error
|
||||
if( _volMaterial == null )
|
||||
{
|
||||
Graphics.Blit(source, destination);
|
||||
return;
|
||||
}
|
||||
|
||||
// Shader needs this matrix to generate world space rays
|
||||
_volMaterial.SetMatrix("_CamProj", (_camera.projectionMatrix * _camera.worldToCameraMatrix).inverse);
|
||||
|
||||
// Shader needs to know the position and scale of cameras used to render input textures
|
||||
if(GridTransform != null)
|
||||
_volMaterial.SetVector("_GridTransform", new Vector4(GridTransform.position.x,GridTransform.position.z,GridTransform.localScale.x*4));
|
||||
|
||||
Graphics.Blit( source, destination, _volMaterial, 0 );
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Sector Display/VolumeSampling.cs.meta
Normal file
11
Assets/Scripts/Sector Display/VolumeSampling.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8c03374f22d0a3d4882018de66894a84
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/Scripts/Sector Display/WaveScroll.cs
Normal file
20
Assets/Scripts/Sector Display/WaveScroll.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WaveScroll : MonoBehaviour
|
||||
{
|
||||
public float Speed = 1;
|
||||
|
||||
private Material _material;
|
||||
private float _phase;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
_material = GetComponent<MeshRenderer>().material;
|
||||
}
|
||||
|
||||
void Update () {
|
||||
_material.SetFloat("_Phase", _phase+=Time.deltaTime*Speed);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Sector Display/WaveScroll.cs.meta
Normal file
11
Assets/Scripts/Sector Display/WaveScroll.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 59ee45f9f67763845b92c04c774eaaf9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue