Properties Panel Overhaul
Marking player location on galaxy map Fixed non-input field focus disabling global key map Player start ship is now always the same Loadout generator now demands exact match for item dimensions Thermal damage now triggers ItemDamaged event = player can die from cockpit wear! Properties panel now has a much more attractive UI Implemented curve control for properties UI Centralized number formatting in player settings Moved significant digits to player settings Added temperature unit option in player settings
This commit is contained in:
parent
ec1f8f56d4
commit
54f7e3a66f
152 changed files with 8691 additions and 179 deletions
75
Assets/Scripts/UI/CurveField.cs
Normal file
75
Assets/Scripts/UI/CurveField.cs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Msagl.DebugHelpers;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.UI.Extensions;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public class CurveField : MonoBehaviour
|
||||
{
|
||||
public int Segments = 16;
|
||||
public int SigDigs = 3;
|
||||
public TextMeshProUGUI Title;
|
||||
public TextMeshProUGUI MinLabel;
|
||||
public TextMeshProUGUI MidLabel;
|
||||
public TextMeshProUGUI MaxLabel;
|
||||
public UILineRenderer Line;
|
||||
public Image CurrentX;
|
||||
public Image CurrentY;
|
||||
|
||||
private BezierCurve _curve;
|
||||
//private Func<float, string> _xFunc;
|
||||
|
||||
public void SetCurrent(float x)
|
||||
{
|
||||
CurrentX.gameObject.SetActive(true);
|
||||
CurrentY.gameObject.SetActive(true);
|
||||
var xrect = CurrentX.GetComponent<RectTransform>();
|
||||
var yrect = CurrentY.GetComponent<RectTransform>();
|
||||
var y = _curve.Evaluate(x);
|
||||
xrect.anchorMin = new Vector2(x, 0);
|
||||
xrect.anchorMax = new Vector2(x, y);
|
||||
yrect.anchorMin = new Vector2(x, y);
|
||||
yrect.anchorMax = new Vector2(x, y);
|
||||
}
|
||||
|
||||
public void Show(string label, BezierCurve curve, Func<float, string> xFunc, bool showMax = false)
|
||||
{
|
||||
_curve = curve;
|
||||
//_xFunc = xFunc;
|
||||
CurrentX.gameObject.SetActive(false);
|
||||
CurrentY.gameObject.SetActive(false);
|
||||
Title.text = label;
|
||||
var points = new List<Vector2>();
|
||||
var keys = curve.Keys.Select(v => new Vector2(v.x, v.y));
|
||||
if (curve.Keys[0].x > .01f) keys = keys.Prepend(new Vector2(0, curve.Keys[0].y));
|
||||
if (curve.Keys[curve.Keys.Length-1].x < .99f) keys = keys.Append(new Vector2(1, curve.Keys[curve.Keys.Length-1].y));
|
||||
var keysArray = keys.ToArray();
|
||||
for (int i = 0; i < keysArray.Length - 1; i++)
|
||||
{
|
||||
for (int j = 0; j < Segments; j++)
|
||||
{
|
||||
var x = lerp(keysArray[i].x, keysArray[i + 1].x, (float) j / Segments);
|
||||
points.Add(new Vector2(x, curve.Evaluate(x)));
|
||||
}
|
||||
}
|
||||
points.Add(new Vector2(1, curve.Evaluate(1)));
|
||||
|
||||
Line.Points = points.ToArray();
|
||||
MinLabel.text = xFunc(0);
|
||||
MaxLabel.text = xFunc(1);
|
||||
if (showMax)
|
||||
{
|
||||
var midX = curve.Maximum;
|
||||
MidLabel.text = xFunc(midX);
|
||||
var rect = MidLabel.GetComponent<RectTransform>();
|
||||
rect.anchorMin = new Vector2(midX, rect.anchorMin.y);
|
||||
rect.anchorMax = new Vector2(midX, rect.anchorMax.y);
|
||||
}
|
||||
else MidLabel.text = xFunc(.5f);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/CurveField.cs.meta
Normal file
11
Assets/Scripts/UI/CurveField.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7ee1522de6af7de409ddcae9a0f6ccc9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -76,7 +76,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
|
||||
void Start()
|
||||
{
|
||||
PropertiesPanel.Context = GameManager.ItemManager;
|
||||
PropertiesPanel.GameManager = GameManager;
|
||||
foreach (var panel in InventoryPanels)
|
||||
{
|
||||
panel.OnBeginDragAsObservable().Subscribe(data =>
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
public Color CellBackgroundColor = new Color(0, 0, 0, .75f);
|
||||
public float MinTempRange = 1;
|
||||
public float DoubleClickTime = .5f;
|
||||
public float HitDamageThreshold = 1;
|
||||
|
||||
Subject<InventoryEventData> _onBeginDrag;
|
||||
Subject<InventoryEventData> _onDrag;
|
||||
|
|
@ -206,8 +207,8 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
var opacity = smoothstep(0, MinTempRange, tempRange);
|
||||
if(MinTempLabel)
|
||||
{
|
||||
MinTempLabel.text = $"{((int) (_displayedEntity.MinTemp - 273.15f)).ToString()}°C";
|
||||
MaxTempLabel.text = $"{((int) (_displayedEntity.MaxTemp - 273.15f)).ToString()}°C";
|
||||
MinTempLabel.text = ActionGameManager.PlayerSettings.FormatTemperature(_displayedEntity.MinTemp);
|
||||
MaxTempLabel.text = ActionGameManager.PlayerSettings.FormatTemperature(_displayedEntity.MaxTemp);
|
||||
}
|
||||
var hullData = GameManager.ItemManager.GetData(_displayedEntity.Hull) as HullData;
|
||||
for(var x = 0; x < _temperatureTexture.width; x++)
|
||||
|
|
@ -403,11 +404,11 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
RefreshCells(hitCells);
|
||||
}));
|
||||
|
||||
_subscriptions.Add(entity.ItemDamage.Subscribe(hit =>
|
||||
_subscriptions.Add(entity.ItemDamage.Where(hit=>hit.damage > HitDamageThreshold).Subscribe(hit =>
|
||||
{
|
||||
var data = entity.ItemManager.GetData(hit.item.EquippableItem);
|
||||
var hitCells = data.Shape.Coordinates.Select(v => v + hit.item.Position).ToArray();
|
||||
StartCoroutine(Pulse(hitCells, HitType.Armor, _hitSequence++));
|
||||
var hitCells = hit.item.InsetShape.Coordinates;
|
||||
if(gameObject.activeInHierarchy)
|
||||
StartCoroutine(Pulse(hitCells, HitType.Armor, _hitSequence++));
|
||||
RefreshCells(hitCells);
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,6 +176,13 @@ public class MainMenu : MonoBehaviour
|
|||
_nextMenu.panel.AddField("Name",
|
||||
() => ActionGameManager.PlayerSettings.Name,
|
||||
s => ActionGameManager.PlayerSettings.Name = s);
|
||||
_nextMenu.panel.AddField("Temperature Unit",
|
||||
() => (int) ActionGameManager.PlayerSettings.TemperatureUnit,
|
||||
i => ActionGameManager.PlayerSettings.TemperatureUnit = (TemperatureUnit) i,
|
||||
Enum.GetNames(typeof(TemperatureUnit)));
|
||||
_nextMenu.panel.AddField("Significant Digits",
|
||||
() => ActionGameManager.PlayerSettings.SignificantDigits,
|
||||
i => ActionGameManager.PlayerSettings.SignificantDigits = i);
|
||||
_nextMenu.panel.AddButton("Back",
|
||||
() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,9 +34,11 @@ public class PropertiesPanel : MonoBehaviour
|
|||
public PropertyButton PropertyButton;
|
||||
public ButtonField ButtonField;
|
||||
public IncrementField IncrementField;
|
||||
public StatSheet StatSheet;
|
||||
public CurveField CurveField;
|
||||
public RectTransform Content;
|
||||
[HideInInspector] public FlatFlatButton SelectedChild;
|
||||
[HideInInspector] public ItemManager Context;
|
||||
[HideInInspector] public ActionGameManager GameManager;
|
||||
|
||||
protected List<GameObject> Properties = new List<GameObject>();
|
||||
protected List<FlatFlatButton> Buttons = new List<FlatFlatButton>();
|
||||
|
|
@ -133,10 +135,19 @@ public class PropertiesPanel : MonoBehaviour
|
|||
return property;
|
||||
}
|
||||
|
||||
public StatSheet AddStatSheet()
|
||||
{
|
||||
var sheet = Instantiate(StatSheet, Content ?? transform);
|
||||
Properties.Add(sheet.gameObject);
|
||||
OnPropertyAdded?.Invoke(sheet.gameObject);
|
||||
RefreshPropertyValues += () => sheet.RefreshValues();
|
||||
return sheet;
|
||||
}
|
||||
|
||||
public PropertiesList AddList(string name) //, IEnumerable<(string, Func<string>)> elements)
|
||||
{
|
||||
var list = Instantiate(List, Content ?? transform);
|
||||
list.Context = Context;
|
||||
list.GameManager = GameManager;
|
||||
list.Dropdown = Dropdown;
|
||||
list.Title.text = name;
|
||||
// foreach (var element in elements)
|
||||
|
|
@ -165,6 +176,13 @@ public class PropertiesPanel : MonoBehaviour
|
|||
return attributeInstance;
|
||||
}
|
||||
|
||||
public CurveField AddCurveField()
|
||||
{
|
||||
var curveInstance = Instantiate(CurveField, Content ?? transform);
|
||||
Properties.Add(curveInstance.gameObject);
|
||||
return curveInstance;
|
||||
}
|
||||
|
||||
public virtual PropertyButton AddButton(string name, Action onClick)
|
||||
{
|
||||
var button = Instantiate(PropertyButton, Content ?? transform);
|
||||
|
|
@ -344,42 +362,43 @@ public class PropertiesPanel : MonoBehaviour
|
|||
OnPropertyAdded?.Invoke(field.gameObject);
|
||||
}
|
||||
|
||||
public void Inspect(Entity entity)
|
||||
{
|
||||
Clear();
|
||||
Title.text = entity.Name;
|
||||
var hullData = Context.GetData(entity.Hull) as HullData;
|
||||
AddSection(
|
||||
hullData.HullType == HullType.Ship ? "Ship" :
|
||||
hullData.HullType == HullType.Station ? "Station" :
|
||||
"Platform");
|
||||
//AddList(hullData.Name).Inspect(hull, entity);
|
||||
//PropertiesPanel.AddProperty("Hull", () => $"{hullData.Name}");
|
||||
AddEntityProperties(entity);
|
||||
//cargoList.SetExpanded(false,true);
|
||||
|
||||
RefreshValues();
|
||||
}
|
||||
// public void Inspect(Entity entity)
|
||||
// {
|
||||
// Clear();
|
||||
// Title.text = entity.Name;
|
||||
// var hullData = Context.GetData(entity.Hull) as HullData;
|
||||
// AddSection(
|
||||
// hullData.HullType == HullType.Ship ? "Ship" :
|
||||
// hullData.HullType == HullType.Station ? "Station" :
|
||||
// "Platform");
|
||||
// //AddList(hullData.Name).Inspect(hull, entity);
|
||||
// //PropertiesPanel.AddProperty("Hull", () => $"{hullData.Name}");
|
||||
// AddEntityProperties(entity);
|
||||
// //cargoList.SetExpanded(false,true);
|
||||
//
|
||||
// RefreshValues();
|
||||
// }
|
||||
|
||||
private void AddEntityProperties(Entity entity)
|
||||
{
|
||||
AddField("Name", () => entity.Name, name => entity.Name = name);
|
||||
AddProperty("Mass", () => $"{entity.Mass.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
}
|
||||
// private void AddEntityProperties(Entity entity)
|
||||
// {
|
||||
// AddField("Name", () => entity.Name, name => entity.Name = name);
|
||||
// AddProperty("Mass", () => $"{entity.Mass.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
// }
|
||||
|
||||
private void AddItemProperties(ItemInstance item)
|
||||
{
|
||||
var data = Context.ItemData.Get<ItemData>(item.Data);
|
||||
var data = ActionGameManager.CultCache.Get<ItemData>(item.Data);
|
||||
|
||||
AddProperty(data.Description);
|
||||
|
||||
var manufacturer = Context.ItemData.Get<Faction>(data.Manufacturer);
|
||||
AddProperty("Manufacturer", () => manufacturer?.Name ?? "GameCult");
|
||||
|
||||
if (item is SimpleCommodity simpleCommodity)
|
||||
AddProperty("Quantity", () => simpleCommodity.Quantity.ToString());
|
||||
|
||||
AddProperty("Mass", () => Context.GetMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
var sheet = AddStatSheet();
|
||||
var manufacturer = ActionGameManager.CultCache.Get<Faction>(data.Manufacturer);
|
||||
sheet.AddStat("Manufacturer", () => manufacturer?.Name ?? "GameCult");
|
||||
sheet.AddStat("Mass", () => ActionGameManager.PlayerSettings.Format(GameManager.ItemManager.GetMass(item)));
|
||||
|
||||
//AddProperty("Thermal Mass", () => Context.GetThermalMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
}
|
||||
|
||||
|
|
@ -387,38 +406,49 @@ public class PropertiesPanel : MonoBehaviour
|
|||
{
|
||||
if (item.Durability < .01f)
|
||||
{
|
||||
AddProperty("Item destroyed!");
|
||||
return;
|
||||
}
|
||||
|
||||
var gearData = Context.GetData(item);
|
||||
AddProperty("Durability", () => $"{(int)(item.Durability / gearData.Durability * 100)}%");
|
||||
var gearData = GameManager.ItemManager.GetData(item);
|
||||
|
||||
var sheet = AddStatSheet();
|
||||
foreach (var behavior in gearData.Behaviors)
|
||||
{
|
||||
var type = behavior.GetType();
|
||||
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) != null)
|
||||
if (behavior is StatModifierData statMod)
|
||||
{
|
||||
sheet.AddStat($"{statMod.Stat.Target.SplitCamelCase()}:{statMod.Stat.Stat.SplitCamelCase()}", () => $"{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{ActionGameManager.PlayerSettings.Format(statValueFunction(statMod.Modifier))}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var type = behavior.GetType();
|
||||
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) == null) continue;
|
||||
foreach (var field in type.GetFields().Where(f => f.GetCustomAttribute<RuntimeInspectable>() != null))
|
||||
{
|
||||
var fieldType = field.FieldType;
|
||||
if (fieldType == typeof(float))
|
||||
AddProperty(field.Name, () => $"{((float) field.GetValue(behavior)).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat(field.Name.SplitCamelCase(), () => $"{ActionGameManager.PlayerSettings.Format((float) field.GetValue(behavior))}");
|
||||
else if (fieldType == typeof(int))
|
||||
AddProperty(field.Name, () => $"{(int) field.GetValue(behavior)}");
|
||||
sheet.AddStat(field.Name.SplitCamelCase(), () => $"{(int) field.GetValue(behavior)}");
|
||||
else if (fieldType == typeof(PerformanceStat))
|
||||
{
|
||||
var stat = (PerformanceStat) field.GetValue(behavior);
|
||||
AddProperty(field.Name, () => $"{statValueFunction(stat).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat(field.Name.SplitCamelCase(), () => $"{ActionGameManager.PlayerSettings.Format(statValueFunction(stat))}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gearData.Behaviors.FirstOrDefault(b => b is WeaponData) is WeaponData weapon)
|
||||
{
|
||||
var range = AddCurveField();
|
||||
range.Show("Damage Range", weapon.DamageCurve, t => ActionGameManager.PlayerSettings.Format(lerp(statValueFunction(weapon.MinRange), statValueFunction(weapon.Range), t)));
|
||||
}
|
||||
}
|
||||
|
||||
private string GetTitle(EquippableItem item)
|
||||
{
|
||||
var data = Context.ItemData.Get<ItemData>(item.Data);
|
||||
var (tier, upgrades) = Context.GetTier(item);
|
||||
var data = ActionGameManager.CultCache.Get<ItemData>(item.Data);
|
||||
var (tier, upgrades) = GameManager.ItemManager.GetTier(item);
|
||||
return
|
||||
$"<color=#{ColorUtility.ToHtmlStringRGB(tier.Color.ToColor())}>{data.Name}</color><smallcaps><size=60%> ({tier.Name}{new string('+', upgrades)})";
|
||||
}
|
||||
|
|
@ -433,11 +463,24 @@ public class PropertiesPanel : MonoBehaviour
|
|||
AddItemProperties(item.EquippableItem);
|
||||
AddSpacer();
|
||||
|
||||
var gearData = GameManager.ItemManager.GetData(item.EquippableItem);
|
||||
var statusSheet = AddStatSheet();
|
||||
if (item.EquippableItem.Durability < .01f)
|
||||
statusSheet.AddStat("Durability", () => "Item Destroyed!");
|
||||
else statusSheet.AddStat("Durability", () => $"{(int)(item.EquippableItem.Durability / gearData.Durability * 100)}%");
|
||||
statusSheet.AddStat("Temperature", () => ActionGameManager.PlayerSettings.FormatTemperature(item.Temperature));
|
||||
|
||||
var heatCurve = AddCurveField();
|
||||
heatCurve.Show(
|
||||
"Thermal Performance",
|
||||
gearData.HeatPerformanceCurve,
|
||||
t => ActionGameManager.PlayerSettings.FormatTemperature(lerp(gearData.MinimumTemperature, gearData.MaximumTemperature, t)),
|
||||
true);
|
||||
RefreshPropertyValues += () => heatCurve.SetCurrent(unlerp(gearData.MinimumTemperature, gearData.MaximumTemperature, item.Temperature));
|
||||
AddEquippableItemProperties(item.EquippableItem, item.Evaluate);
|
||||
AddSpacer();
|
||||
|
||||
AddField("Override Shutdown", () => item.EquippableItem.OverrideShutdown, b => item.EquippableItem.OverrideShutdown = b);
|
||||
AddProperty("Temperature", () => (item.Temperature - 273.15f).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
|
||||
foreach (var behavior in item.Behaviors)
|
||||
{
|
||||
|
|
@ -464,7 +507,16 @@ public class PropertiesPanel : MonoBehaviour
|
|||
{
|
||||
Title.text = GetTitle(gear);
|
||||
AddSpacer();
|
||||
AddEquippableItemProperties(gear, stat => Context.Evaluate(stat, gear));
|
||||
var gearData = GameManager.ItemManager.GetData(gear);
|
||||
var statusSheet = AddStatSheet();
|
||||
statusSheet.AddStat("Durability", () => $"{(int)(gear.Durability / gearData.Durability * 100)}%");
|
||||
var heatCurve = AddCurveField();
|
||||
heatCurve.Show(
|
||||
"Thermal Performance",
|
||||
gearData.HeatPerformanceCurve,
|
||||
t => ActionGameManager.PlayerSettings.FormatTemperature(lerp(gearData.MinimumTemperature, gearData.MaximumTemperature, t)),
|
||||
true);
|
||||
AddEquippableItemProperties(gear, stat => GameManager.ItemManager.Evaluate(stat, gear));
|
||||
}
|
||||
|
||||
RefreshValues();
|
||||
|
|
@ -476,15 +528,16 @@ public class PropertiesPanel : MonoBehaviour
|
|||
AddProperty(data.Description).Label.fontStyle = FontStyles.Normal;
|
||||
if (data is EquippableItemData gearData)
|
||||
{
|
||||
AddProperty("Durability", () => gearData.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
AddProperty("Durability", () => ActionGameManager.PlayerSettings.Format(gearData.Durability));
|
||||
var sheet = AddStatSheet();
|
||||
foreach (var behavior in gearData.Behaviors)
|
||||
{
|
||||
if (behavior is StatModifierData statMod)
|
||||
{
|
||||
if(Math.Abs(statMod.Modifier.Min - statMod.Modifier.Max) < .001f)
|
||||
AddProperty("Stat Mod", () => $"{statMod.Stat.Target}:{statMod.Stat.Stat}{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{statMod.Modifier.Min.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat($"{statMod.Stat.Target}:{statMod.Stat.Stat}", () => $"{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{ActionGameManager.PlayerSettings.Format(statMod.Modifier.Min)}");
|
||||
else
|
||||
AddProperty("Stat Mod", () => $"{statMod.Stat.Target}:{statMod.Stat.Stat}{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{statMod.Modifier.Min.SignificantDigits(Context.GameplaySettings.SignificantDigits)}-{statMod.Modifier.Max.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat($"{statMod.Stat.Target}:{statMod.Stat.Stat}", () => $"{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{ActionGameManager.PlayerSettings.Format(statMod.Modifier.Min)}-{ActionGameManager.PlayerSettings.Format(statMod.Modifier.Max)}");
|
||||
}
|
||||
var type = behavior.GetType();
|
||||
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) != null)
|
||||
|
|
@ -493,16 +546,16 @@ public class PropertiesPanel : MonoBehaviour
|
|||
{
|
||||
var fieldType = field.FieldType;
|
||||
if (fieldType == typeof(float))
|
||||
AddProperty(field.Name, () => $"{((float) field.GetValue(behavior)).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat(field.Name, () => $"{ActionGameManager.PlayerSettings.Format((float) field.GetValue(behavior))}");
|
||||
else if (fieldType == typeof(int))
|
||||
AddProperty(field.Name, () => $"{(int) field.GetValue(behavior)}");
|
||||
sheet.AddStat(field.Name, () => $"{(int) field.GetValue(behavior)}");
|
||||
else if (fieldType == typeof(PerformanceStat))
|
||||
{
|
||||
var stat = (PerformanceStat) field.GetValue(behavior);
|
||||
if(Math.Abs(stat.Min - stat.Max) < .001f)
|
||||
AddProperty(field.Name, () => $"{stat.Min.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat(field.Name, () => $"{ActionGameManager.PlayerSettings.Format(stat.Min)}");
|
||||
else
|
||||
AddProperty(field.Name, () => $"{stat.Min.SignificantDigits(Context.GameplaySettings.SignificantDigits)}-{stat.Max.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat(field.Name, () => $"{ActionGameManager.PlayerSettings.Format(stat.Min)}-{ActionGameManager.PlayerSettings.Format(stat.Max)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,27 @@ guid: 8c2bf4a7080061d42a87046c37bf0c60
|
|||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
defaultReferences:
|
||||
- Spacer: {instanceID: 0}
|
||||
- Dropdown: {instanceID: 0}
|
||||
- Title: {instanceID: 0}
|
||||
- Section: {instanceID: 0}
|
||||
- List: {instanceID: 0}
|
||||
- Property: {instanceID: 0}
|
||||
- PropertyLabel: {instanceID: 0}
|
||||
- Attribute: {instanceID: 0}
|
||||
- InputField: {instanceID: 0}
|
||||
- RangedFloatField: {instanceID: 0}
|
||||
- ProgressField: {instanceID: 0}
|
||||
- EnumField: {instanceID: 0}
|
||||
- BoolField: {instanceID: 0}
|
||||
- PropertyButton: {instanceID: 0}
|
||||
- ButtonField: {instanceID: 0}
|
||||
- IncrementField: {instanceID: 0}
|
||||
- StatSheet: {fileID: 3416329628306957711, guid: 4f75723ed178a084e813965e84825bd4,
|
||||
type: 3}
|
||||
- Content: {instanceID: 0}
|
||||
- SelectedChild: {instanceID: 0}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
if (_capacitors.Length == 0)
|
||||
{
|
||||
EnergyFill.anchorMax = Vector2.up;
|
||||
EnergyLabel.text = _reactor.Draw.SignificantDigits(3);
|
||||
EnergyLabel.text = ActionGameManager.PlayerSettings.Format(_reactor.Draw);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -280,7 +280,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
var hullData = _entity.ItemManager.GetData(_hull);
|
||||
var dur = _hull.Durability / hullData.Durability;
|
||||
HullDurabilityFill.anchorMax = new Vector2(dur, 1);
|
||||
HullDurabilityLabel.text = $"{(dur*100).SignificantDigits(3)}%";
|
||||
HullDurabilityLabel.text = $"{ActionGameManager.PlayerSettings.Format(dur*100)}%";
|
||||
|
||||
foreach (var x in _schematicItems)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ public class SectorMap : MonoBehaviour
|
|||
public float LinkWidth;
|
||||
public float CriticalLinkWidth;
|
||||
public AnimationCurve IconScaleAnimation;
|
||||
public Color PlayerLocationLabelColor;
|
||||
public float PlayerLocationIconSize = 1.25f;
|
||||
|
||||
private SectorZone _currentPlayerLocation;
|
||||
private HashSet<SectorZone> _revealedZones = new HashSet<SectorZone>();
|
||||
private HashSet<(SectorZone, SectorZone)> _revealedLinks = new HashSet<(SectorZone, SectorZone)>();
|
||||
|
||||
|
|
@ -48,6 +51,29 @@ public class SectorMap : MonoBehaviour
|
|||
private Dictionary<SectorZone, SectorZoneUI> _zoneInstances = new Dictionary<SectorZone, SectorZoneUI>();
|
||||
private Queue<IEnumerable<SectorZone>> _queuedZoneReveals = new Queue<IEnumerable<SectorZone>>();
|
||||
|
||||
public void MarkPlayerLocation(SectorZone zone)
|
||||
{
|
||||
if (_currentPlayerLocation != null)
|
||||
{
|
||||
_zoneInstances[_currentPlayerLocation].Label.color = Color.white;
|
||||
_zoneInstances[_currentPlayerLocation].Label.fontStyle = FontStyles.Normal;
|
||||
_zoneInstances[_currentPlayerLocation].IconContainer.localScale = Vector3.one;
|
||||
}
|
||||
|
||||
_currentPlayerLocation = zone;
|
||||
if(_zoneInstances.ContainsKey(_currentPlayerLocation))
|
||||
{
|
||||
MarkPlayerLocation(_zoneInstances[_currentPlayerLocation]);
|
||||
}
|
||||
}
|
||||
|
||||
private void MarkPlayerLocation(SectorZoneUI zoneUI)
|
||||
{
|
||||
zoneUI.Label.color = PlayerLocationLabelColor;
|
||||
zoneUI.Label.fontStyle = FontStyles.Bold;
|
||||
zoneUI.IconContainer.localScale = new Vector3(PlayerLocationIconSize, PlayerLocationIconSize, 1);
|
||||
}
|
||||
|
||||
public void QueueZoneReveal(IEnumerable<SectorZone> zones)
|
||||
{
|
||||
_queuedZoneReveals.Enqueue(zones);
|
||||
|
|
@ -72,6 +98,8 @@ public class SectorMap : MonoBehaviour
|
|||
if (!_revealedZones.Contains(zone))
|
||||
{
|
||||
var zoneInstance = ZonePrototype.Instantiate<SectorZoneUI>();
|
||||
if(zone == _currentPlayerLocation)
|
||||
MarkPlayerLocation(zoneInstance);
|
||||
_zoneInstances[zone] = zoneInstance;
|
||||
var zoneInstanceTransform = zoneInstance.transform;
|
||||
zoneTransforms.Add(zoneInstanceTransform);
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
_viewSize = .25f;
|
||||
|
||||
Map.StartReveal(LinkAnimationDuration, IconAnimationDuration);
|
||||
Map.MarkPlayerLocation(GameManager.CurrentEntity.Zone.SectorZone);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
|
|
|
|||
|
|
@ -10,4 +10,5 @@ public class SectorZoneUI : MonoBehaviour
|
|||
public MeshRenderer Secondary;
|
||||
public MeshRenderer Influence;
|
||||
public TextMeshPro Label;
|
||||
public Transform IconContainer;
|
||||
}
|
||||
|
|
|
|||
24
Assets/Scripts/UI/StatSheet.cs
Normal file
24
Assets/Scripts/UI/StatSheet.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class StatSheet : MonoBehaviour
|
||||
{
|
||||
public PropertyLabel StatPrefab;
|
||||
|
||||
private List<(PropertyLabel property, Func<string> value)> _stats = new List<(PropertyLabel property, Func<string> value)>();
|
||||
|
||||
public void AddStat(string label, Func<string> value)
|
||||
{
|
||||
var instance = Instantiate(StatPrefab, transform);
|
||||
instance.Label.text = label;
|
||||
_stats.Add((instance, value));
|
||||
}
|
||||
|
||||
public void RefreshValues()
|
||||
{
|
||||
foreach(var stat in _stats)
|
||||
stat.property.Value.text = stat.value();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/StatSheet.cs.meta
Normal file
11
Assets/Scripts/UI/StatSheet.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b02298592479bca4691d1bb19c2a79cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -37,7 +37,7 @@ public class TradeMenu : MonoBehaviour
|
|||
if (GameManager.DockedEntity == null) return;
|
||||
_targetCargo = GameManager.DockingBay;
|
||||
TargetCargoLabel.text = "Docking Bay";
|
||||
Properties.Context = GameManager.ItemManager;
|
||||
Properties.GameManager = GameManager;
|
||||
|
||||
MinimumSizeFilter.Width.onEndEdit.RemoveAllListeners();
|
||||
MinimumSizeFilter.Width.onEndEdit.AddListener(_ => Populate());
|
||||
|
|
@ -210,7 +210,7 @@ public class TradeMenu : MonoBehaviour
|
|||
return 0;
|
||||
}));
|
||||
columns.Add(("Mass", 1,
|
||||
x => () => x.data.Mass.SignificantDigits(3),
|
||||
x => () => ActionGameManager.PlayerSettings.Format(x.data.Mass),
|
||||
data => data.Mass));
|
||||
columns.Add(("Price", 1,
|
||||
x => () => (x.item is CraftedItemInstance craftedItemInstance ? GameManager.ItemManager.GetPrice(craftedItemInstance) : x.data.Price).ToString("N0"),
|
||||
|
|
@ -252,7 +252,7 @@ public class TradeMenu : MonoBehaviour
|
|||
columns.Add((field.Name, 1, x =>
|
||||
{
|
||||
var behavior = ((EquippableItemData) x.data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
|
||||
return () => ((float) field.GetValue(behavior)).SignificantDigits(3);
|
||||
return () => ActionGameManager.PlayerSettings.Format((float) field.GetValue(behavior));
|
||||
}, data =>
|
||||
{
|
||||
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
|
||||
|
|
@ -273,7 +273,7 @@ public class TradeMenu : MonoBehaviour
|
|||
columns.Add((field.Name, 1, x =>
|
||||
{
|
||||
var behavior = ((EquippableItemData) x.data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
|
||||
return () => ((PerformanceStat) field.GetValue(behavior)).Max.SignificantDigits(3);
|
||||
return () => ActionGameManager.PlayerSettings.Format(((PerformanceStat) field.GetValue(behavior)).Max);
|
||||
}, data =>
|
||||
{
|
||||
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class TradeMenuDebug : MonoBehaviour
|
|||
{
|
||||
_targetCargo = GameManager.DockingBay;
|
||||
TargetCargoLabel.text = "Docking Bay";
|
||||
Properties.Context = GameManager.ItemManager;
|
||||
Properties.GameManager = GameManager;
|
||||
MinimumSizeFilter.Width.onEndEdit.AddListener(_ => Populate());
|
||||
MinimumSizeFilter.Height.onEndEdit.AddListener(_ => Populate());
|
||||
MaximumSizeFilter.Width.onEndEdit.AddListener(_ => Populate());
|
||||
|
|
@ -196,7 +196,7 @@ public class TradeMenuDebug : MonoBehaviour
|
|||
return 0;
|
||||
}));
|
||||
columns.Add(("Mass", 1,
|
||||
data => () => data.Mass.SignificantDigits(3),
|
||||
data => () => ActionGameManager.PlayerSettings.Format(data.Mass),
|
||||
data => data.Mass));
|
||||
columns.Add(("Price", 1,
|
||||
data => () => data.Price.ToString("N0"),
|
||||
|
|
@ -237,7 +237,7 @@ public class TradeMenuDebug : MonoBehaviour
|
|||
columns.Add((field.Name, 1, data =>
|
||||
{
|
||||
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
|
||||
return () => ((float) field.GetValue(behavior)).SignificantDigits(3);
|
||||
return () => ActionGameManager.PlayerSettings.Format((float) field.GetValue(behavior));
|
||||
}, data =>
|
||||
{
|
||||
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
|
||||
|
|
@ -258,7 +258,7 @@ public class TradeMenuDebug : MonoBehaviour
|
|||
columns.Add((field.Name, 1, data =>
|
||||
{
|
||||
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
|
||||
return () => ((PerformanceStat) field.GetValue(behavior)).Max.SignificantDigits(3);
|
||||
return () => ActionGameManager.PlayerSettings.Format(((PerformanceStat) field.GetValue(behavior)).Max);
|
||||
}, data =>
|
||||
{
|
||||
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
|
||||
|
|
|
|||
Loading…
Reference in a new issue