Playability
Fixed loadout generator tutorial edge cases Recreated missing items Created field shader & test scene
This commit is contained in:
parent
69aca09f63
commit
47e500e1ce
72 changed files with 3579 additions and 693 deletions
|
|
@ -10,7 +10,7 @@ using UnityEngine;
|
|||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class ClickCatcher : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, /*IPointerUpHandler, IPointerDownHandler,*/ IPointerClickHandler
|
||||
public class ClickCatcher : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, /*IPointerUpHandler, */IPointerDownHandler, IPointerClickHandler
|
||||
{
|
||||
//public bool EnableMouse => PointerIsInside && !_catching;
|
||||
public bool PointerIsInside { get; private set; }
|
||||
|
|
@ -19,6 +19,7 @@ public class ClickCatcher : MonoBehaviour, IPointerEnterHandler, IPointerExitHan
|
|||
public Subject<PointerEventData> OnEnter = new Subject<PointerEventData>();
|
||||
public Subject<PointerEventData> OnExit = new Subject<PointerEventData>();
|
||||
public Subject<PointerEventData> OnClick = new Subject<PointerEventData>();
|
||||
public Subject<PointerEventData> OnDown = new Subject<PointerEventData>();
|
||||
|
||||
// private float downTime;
|
||||
|
||||
|
|
@ -54,10 +55,10 @@ public class ClickCatcher : MonoBehaviour, IPointerEnterHandler, IPointerExitHan
|
|||
// OnClick?.Invoke(eventData);
|
||||
// }
|
||||
//
|
||||
// public void OnPointerDown(PointerEventData eventData)
|
||||
// {
|
||||
// downTime = Time.time;
|
||||
// }
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
OnDown.OnNext(eventData);
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,15 +19,17 @@ public class ClickRaycaster : MonoBehaviour
|
|||
void Start()
|
||||
{
|
||||
_clickCatcher = GetComponent<ClickCatcher>();
|
||||
_clickCatcher.OnClick.Subscribe(pointer =>
|
||||
_clickCatcher.OnDown.Subscribe(pointer =>
|
||||
{
|
||||
RaycastHit hit;
|
||||
Physics.Raycast(RayCamera.ScreenPointToRay(pointer.position), out hit, 1000, Layers.value);
|
||||
var ray = RayCamera.ScreenPointToRay(pointer.position);
|
||||
Physics.Raycast(ray, out hit, 1000, Layers.value);
|
||||
if (hit.collider != null)
|
||||
{
|
||||
//Debug.Log($"Clicked on gameobject {hit.collider.gameObject}");
|
||||
var clickable = hit.collider.GetComponent<ClickableCollider>();
|
||||
if (clickable != null)
|
||||
clickable.Click(pointer);
|
||||
clickable.Click(pointer, ray, hit);
|
||||
}
|
||||
else OnClickMiss?.Invoke(pointer);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ using UnityEngine.EventSystems;
|
|||
|
||||
public class ClickableCollider : MonoBehaviour
|
||||
{
|
||||
public event Action<ClickableCollider, PointerEventData> OnClick;
|
||||
public event Action<ClickableCollider, PointerEventData, Ray, RaycastHit> OnClick;
|
||||
|
||||
public void Click(PointerEventData eventData) => OnClick?.Invoke(this, eventData);
|
||||
public void Click(PointerEventData eventData, Ray ray, RaycastHit raycastHit) => OnClick?.Invoke(this, eventData, ray, raycastHit);
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
|
|
|
|||
30
Assets/Scripts/UI/FieldTester.cs
Normal file
30
Assets/Scripts/UI/FieldTester.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public class FieldTester : MonoBehaviour
|
||||
{
|
||||
public Camera Camera;
|
||||
public FieldDriver TestField;
|
||||
public PropertiesPanel Properties;
|
||||
|
||||
private AetheriaInput _input;
|
||||
private bool _forceThrust;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_input = new AetheriaInput();
|
||||
_input.Player.Enable();
|
||||
Properties.AddField("FOV", () => Camera.fieldOfView, f => Camera.fieldOfView = f, 15, 45);
|
||||
Properties.AddButton("Melee", () => TestField.Melee());
|
||||
Properties.AddField("Force Thrust", () => _forceThrust, b => _forceThrust = b);
|
||||
Properties.Inspect(TestField, true, true);
|
||||
Properties.AddProperty("Current Hits", () => TestField.HitCount.ToString());
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
TestField.Throttle = _forceThrust ? float2(0,1) : _input.Player.Move.ReadValue<Vector2>();
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/UI/FieldTester.cs.meta
Normal file
3
Assets/Scripts/UI/FieldTester.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 686a80c9880b431b94a9b0029d39cf1f
|
||||
timeCreated: 1659655755
|
||||
|
|
@ -101,7 +101,7 @@ public class SectorMap : MonoBehaviour
|
|||
if (!_revealedZones.Contains(zone))
|
||||
{
|
||||
var zoneInstance = ZonePrototype.Instantiate<SectorZoneUI>();
|
||||
zoneInstance.Clickable.OnClick += (clickableCollider, data) => ZoneClicked.OnNext(zone);
|
||||
zoneInstance.Clickable.OnClick += (clickableCollider, data, ray, hit) => ZoneClicked.OnNext(zone);
|
||||
if(zone == _currentPlayerLocation)
|
||||
MarkPlayerLocation(zoneInstance);
|
||||
_zoneInstances[zone] = zoneInstance;
|
||||
|
|
|
|||
|
|
@ -585,78 +585,74 @@ public class PropertiesPanel : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
// public void Inspect(object obj, bool inspectablesOnly = false, bool readWrite = false, bool topLevel = true)
|
||||
// {
|
||||
// if(topLevel)
|
||||
// Clear();
|
||||
//
|
||||
// var fields = obj.GetType().GetFields();
|
||||
// foreach (var field in fields)
|
||||
// Inspect(obj, field, inspectablesOnly, readWrite);
|
||||
//
|
||||
// if(topLevel)
|
||||
// foreach (var field in _propertyFields)
|
||||
// field.transform.SetSiblingIndex(_propertyFields.IndexOf(field));
|
||||
//
|
||||
// RefreshValues();
|
||||
// }
|
||||
//
|
||||
// public void Inspect(object obj, FieldInfo field, bool inspectablesOnly = false, bool readWrite = false)
|
||||
// {
|
||||
// var inspectable = field.GetCustomAttribute<InspectableFieldAttribute>();
|
||||
// if (inspectable == null && inspectablesOnly) return;
|
||||
// var type = field.FieldType;
|
||||
//
|
||||
// if (type == typeof(float))
|
||||
// {
|
||||
// if (readWrite)
|
||||
// {
|
||||
// var ranged = inspectable as RangedFloatInspectableAttribute;
|
||||
// if (ranged != null)
|
||||
// Inspect(field.Name.SplitCamelCase(), () => (float) field.GetValue(obj), f => field.SetValue(obj, f),
|
||||
// ranged.Min, ranged.Max);
|
||||
// else
|
||||
// Inspect(field.Name.SplitCamelCase(), () => (float) field.GetValue(obj), f => field.SetValue(obj, f));
|
||||
// } else Inspect(field.Name.SplitCamelCase(), () => ((float) field.GetValue(obj)).ToString("0.##"));
|
||||
// }
|
||||
// else if (type == typeof(int))
|
||||
// {
|
||||
// if (readWrite)
|
||||
// {
|
||||
// var ranged = inspectable as RangedIntInspectableAttribute;
|
||||
// if (ranged != null)
|
||||
// Inspect(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), f => field.SetValue(obj, f),
|
||||
// ranged.Min, ranged.Max);
|
||||
// else
|
||||
// Inspect(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), f => field.SetValue(obj, f));
|
||||
// } else Inspect(field.Name.SplitCamelCase(), () => ((int) field.GetValue(obj)).ToString());
|
||||
// }
|
||||
// else if (type.IsEnum)
|
||||
// {
|
||||
// if (readWrite)
|
||||
// Inspect(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), i => field.SetValue(obj, i),
|
||||
// Enum.GetNames(field.FieldType));
|
||||
// else
|
||||
// Inspect(field.Name.SplitCamelCase(), () => Enum.GetName(type, field.GetValue(obj)).SplitCamelCase());
|
||||
// }
|
||||
// else if (type == typeof(string))
|
||||
// {
|
||||
// if (readWrite)
|
||||
// Inspect(field.Name.SplitCamelCase(), () => (string) field.GetValue(obj), i => field.SetValue(obj, i));
|
||||
// else
|
||||
// Inspect(field.Name.SplitCamelCase(), () => (string) field.GetValue(obj));
|
||||
// }
|
||||
// //else if (field.FieldType == typeof(Color)) Inspect(field.Name, () => (Color) field.GetValue(obj), c => field.SetValue(obj, c));
|
||||
// else if (field.FieldType == typeof(bool)) Inspect(field.Name, () => (bool) field.GetValue(obj), b => field.SetValue(obj, b));
|
||||
// else if (type.GetCustomAttribute<InspectableFieldAttribute>() != null)
|
||||
// {
|
||||
// if(!_propertyFields.Any() || !_propertyFields.Last().gameObject.name.ToUpper().Contains("DIVIDER"))
|
||||
// _propertyFields.Add(Divider.Instantiate<Prototype>());
|
||||
// Inspect(field.GetValue(obj), inspectablesOnly, readWrite, false);
|
||||
// }
|
||||
// else
|
||||
// Debug.Log($"Field \"{field.Name}\" has unknown type {field.FieldType.Name}. No inspector was generated.");
|
||||
// }
|
||||
public void Inspect(object obj, bool inspectablesOnly = false, bool readWrite = false, bool topLevel = true)
|
||||
{
|
||||
var fields = obj.GetType().GetFields();
|
||||
foreach (var field in fields)
|
||||
Inspect(obj, field, inspectablesOnly, readWrite);
|
||||
|
||||
// if(topLevel)
|
||||
// foreach (var field in _propertyFields)
|
||||
// field.transform.SetSiblingIndex(_propertyFields.IndexOf(field));
|
||||
|
||||
RefreshValues();
|
||||
}
|
||||
|
||||
public void Inspect(object obj, FieldInfo field, bool inspectablesOnly = false, bool readWrite = false)
|
||||
{
|
||||
var inspectable = field.GetCustomAttribute<InspectableAttribute>();
|
||||
if (inspectable == null && inspectablesOnly) return;
|
||||
var type = field.FieldType;
|
||||
|
||||
if (type == typeof(float))
|
||||
{
|
||||
if (readWrite)
|
||||
{
|
||||
if (inspectable is InspectableRangedFloatAttribute ranged)
|
||||
AddField(field.Name.SplitCamelCase(), () => (float) field.GetValue(obj), f => field.SetValue(obj, f),
|
||||
ranged.Min, ranged.Max);
|
||||
else
|
||||
AddField(field.Name.SplitCamelCase(), () => (float) field.GetValue(obj), f => field.SetValue(obj, f));
|
||||
} else AddProperty(field.Name.SplitCamelCase(), () => ((float) field.GetValue(obj)).ToString("0.##"));
|
||||
}
|
||||
else if (type == typeof(int))
|
||||
{
|
||||
if (readWrite)
|
||||
{
|
||||
if (inspectable is InspectableRangedIntAttribute ranged)
|
||||
AddField(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), f => field.SetValue(obj, f),
|
||||
ranged.Min, ranged.Max);
|
||||
else
|
||||
AddField(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), f => field.SetValue(obj, f));
|
||||
} else AddProperty(field.Name.SplitCamelCase(), () => ((int) field.GetValue(obj)).ToString());
|
||||
}
|
||||
else if (type.IsEnum)
|
||||
{
|
||||
if (readWrite)
|
||||
AddField(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), i => field.SetValue(obj, i),
|
||||
Enum.GetNames(field.FieldType));
|
||||
else
|
||||
AddProperty(field.Name.SplitCamelCase(), () => Enum.GetName(type, field.GetValue(obj)).SplitCamelCase());
|
||||
}
|
||||
else if (type == typeof(string))
|
||||
{
|
||||
if (readWrite)
|
||||
AddField(field.Name.SplitCamelCase(), () => (string) field.GetValue(obj), i => field.SetValue(obj, i));
|
||||
else
|
||||
AddProperty(field.Name.SplitCamelCase(), () => (string) field.GetValue(obj));
|
||||
}
|
||||
//else if (field.FieldType == typeof(Color)) Inspect(field.Name, () => (Color) field.GetValue(obj), c => field.SetValue(obj, c));
|
||||
else if (field.FieldType == typeof(bool)) AddField(field.Name, () => (bool) field.GetValue(obj), b => field.SetValue(obj, b));
|
||||
else if (type.GetCustomAttribute<InspectableAttribute>() != null)
|
||||
{
|
||||
// if(!_propertyFields.Any() || !_propertyFields.Last().gameObject.name.ToUpper().Contains("DIVIDER"))
|
||||
// _propertyFields.Add(Divider.Instantiate<Prototype>());
|
||||
var list = AddList(field.Name);
|
||||
list.Inspect(field.GetValue(obj), inspectablesOnly, readWrite, false);
|
||||
}
|
||||
else
|
||||
Debug.Log($"Field \"{field.Name}\" has unknown type {field.FieldType.Name}. No inspector was generated.");
|
||||
}
|
||||
|
||||
public void RefreshValues()
|
||||
{
|
||||
|
|
|
|||
20
Assets/Scripts/UI/SpriteCursor.cs
Normal file
20
Assets/Scripts/UI/SpriteCursor.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class SpriteCursor : MonoBehaviour
|
||||
{
|
||||
public Canvas Canvas;
|
||||
private RectTransform _rectTransform;
|
||||
|
||||
void Start()
|
||||
{
|
||||
_rectTransform = GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
_rectTransform.anchoredPosition = Mouse.current.position.ReadValue() / Canvas.scaleFactor;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SpriteCursor.cs.meta
Normal file
11
Assets/Scripts/UI/SpriteCursor.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4fa6ea658c486044c8e34b8846940726
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue