Game Loop Galaxy Integration
Added sector map in Galaxy tab of in-game menu Added player flag to Ship (replaces AGM.PlayerEntities) Refactored sector map to depend on AGM Moved sector generation to main menu Main menu now supports resuming previous playthrough Database and player settings now statically available via AGM AGM saves current game state in PlayerSettings on exit Sector generation is now asynchronous Added progress callbacks to sector gen + progress dialog in menu Confirmation Dialog / properties panel can now display dynamic text entry Added zone title to Zone map Eliminated ZoneData class (properties moved to ZonePack) Sector, Zone and Entity serialization now fully functional Entity settings now separate from player settings Cleaned up old unused networking message classes Name files now integrated with database cache Added ability to save/load additive DB cache files in database panel Cleaned up Wwise sound setup - removed redundant items & fixed spelling errors Deleted Wwise cache + added to .gitignore
This commit is contained in:
parent
6986ff2562
commit
73651bf16a
130 changed files with 13423 additions and 4406 deletions
|
|
@ -18,26 +18,20 @@ public class ConfirmationDialog : PropertiesPanel
|
|||
public Button Confirm;
|
||||
public TextMeshProUGUI ConfirmText;
|
||||
public TextMeshProUGUI CancelText;
|
||||
|
||||
public bool LockDialog { get; set; }
|
||||
|
||||
private Action _onCancel;
|
||||
private Action _onConfirm;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Cancel.onClick.AddListener(() =>
|
||||
{
|
||||
_onCancel?.Invoke();
|
||||
End();
|
||||
});
|
||||
Confirm.onClick.AddListener(() =>
|
||||
{
|
||||
_onConfirm?.Invoke();
|
||||
End();
|
||||
});
|
||||
Cancel.onClick.AddListener(() => End());
|
||||
Confirm.onClick.AddListener(() => End());
|
||||
if (CancelClickCatcher != null)
|
||||
CancelClickCatcher.OnClick += data =>
|
||||
{
|
||||
_onCancel?.Invoke();
|
||||
if (LockDialog) return;
|
||||
End();
|
||||
};
|
||||
|
||||
|
|
@ -49,12 +43,19 @@ public class ConfirmationDialog : PropertiesPanel
|
|||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void End()
|
||||
public void End(bool success = false)
|
||||
{
|
||||
CancelClickCatcher.gameObject.SetActive(false);
|
||||
if(success) _onConfirm?.Invoke();
|
||||
else _onCancel?.Invoke();
|
||||
CancelClickCatcher?.gameObject.SetActive(false);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void MoveToCursor()
|
||||
{
|
||||
transform.position = Mouse.current.position.ReadValue();
|
||||
}
|
||||
|
||||
public void Show(Action onConfirm = null, Action onCancel = null, string confirmText = "OK", string cancelText = "Cancel")
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
|
@ -69,7 +70,6 @@ public class ConfirmationDialog : PropertiesPanel
|
|||
|
||||
ButtonGroup.SetActive(onConfirm!=null || onCancel!=null);
|
||||
|
||||
transform.position = Mouse.current.position.ReadValue();
|
||||
CancelClickCatcher.gameObject.SetActive(true);
|
||||
CancelClickCatcher?.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class ConsoleView : MonoBehaviour {
|
|||
{
|
||||
//AcceptingInput = false;
|
||||
//_console = new ConsoleController();
|
||||
Application.logMessageReceived += (condition, trace, type) => ConsoleController.Instance.AppendLogLine("<color=" + (type == LogType.Error ? "red" : type == LogType.Warning ? "yellow" : "white") + ">" + condition + "</color>");
|
||||
Application.logMessageReceived += OnLogCallback;
|
||||
|
||||
SetVisibility(false);
|
||||
|
||||
|
|
@ -56,8 +56,14 @@ public class ConsoleView : MonoBehaviour {
|
|||
|
||||
// var sizeFitter = GetComponentInChildren<ContentSizeFitter>().on
|
||||
}
|
||||
|
||||
~ConsoleView() {
|
||||
|
||||
private void OnLogCallback(string condition, string trace, LogType type)
|
||||
{
|
||||
ConsoleController.Instance.AppendLogLine("<color=" + (type == LogType.Error ? "red" : type == LogType.Warning ? "yellow" : "white") + ">" + condition + "</color>");
|
||||
}
|
||||
|
||||
~ConsoleView() {
|
||||
Application.logMessageReceived -= OnLogCallback;
|
||||
ConsoleController.Instance.VisibilityChanged -= OnVisibilityChanged;
|
||||
ConsoleController.Instance.LogChanged -= OnLogChanged;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
Dialog.Title.text = "Unable to move item!";
|
||||
Dialog.AddProperty("Verify that cargo bays are empty before un-equipping them.");
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +207,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
Dialog.Title.text = "Unable to destroy item!";
|
||||
Dialog.AddProperty("Verify that cargo bays are empty before un-equipping them.");
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -389,6 +391,8 @@ public class InventoryMenu : MonoBehaviour
|
|||
|
||||
panel.OnBackgroundClick.Subscribe(data =>
|
||||
{
|
||||
if (GameManager.CurrentEntity == null) return; // Only show ship settings if there's a ship, duh!
|
||||
|
||||
PropertiesPanel.Clear();
|
||||
PropertiesPanel.AddField("Shutdown Threshold",
|
||||
() => GameManager.CurrentEntity.Settings.ShutdownPerformance,
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ using UnityEngine.UI;
|
|||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.Serialization;
|
||||
using static Unity.Mathematics.math;
|
||||
using int2 = Unity.Mathematics.int2;
|
||||
|
||||
public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public ConfirmationDialog ConfirmationDialog;
|
||||
[FormerlySerializedAs("ConfirmationDialog")] public ConfirmationDialog Dialog;
|
||||
public bool Flip;
|
||||
public GameSettings Settings;
|
||||
public ActionGameManager GameManager;
|
||||
|
|
@ -113,9 +114,10 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
ConfirmationDialog.Clear();
|
||||
ConfirmationDialog.Title.text = "Can't select entity, you can only pilot a ship!";
|
||||
ConfirmationDialog.Show();
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "Can't select entity, you can only pilot a ship!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -157,11 +159,11 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
{
|
||||
var entity = EntitySerializer.Unpack(GameManager.ItemManager, GameManager.Zone, pack, true);
|
||||
entity.SetParent(GameManager.DockedEntity);
|
||||
GameManager.PlayerEntities.Add(entity);
|
||||
GameManager.Credits -= pack.Price(GameManager.ItemManager);
|
||||
GameManager.CurrentEntity = entity;
|
||||
if(entity is Ship ship)
|
||||
{
|
||||
ship.IsPlayerShip = true;
|
||||
GameManager.DockingBay.DockedShip = ship;
|
||||
}
|
||||
Display(entity);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -13,7 +14,8 @@ using int2 = Unity.Mathematics.int2;
|
|||
|
||||
public class MapRenderer : MonoBehaviour
|
||||
{
|
||||
public Canvas Canvas;
|
||||
public ActionGameManager GameManager;
|
||||
public TextMeshProUGUI Title;
|
||||
public Camera MapOverlayCamera;
|
||||
public Camera GravityCamera;
|
||||
public Camera TintCamera;
|
||||
|
|
@ -41,6 +43,7 @@ public class MapRenderer : MonoBehaviour
|
|||
MapOverlayCamera.gameObject.SetActive(true);
|
||||
GravityCamera.gameObject.SetActive(true);
|
||||
TintCamera.gameObject.SetActive(true);
|
||||
Title.text = $"Zone: {GameManager.Zone.SectorZone.Name}";
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
|
|
@ -75,8 +78,6 @@ public class MapRenderer : MonoBehaviour
|
|||
_tintTexture.Release();
|
||||
_tintTexture = null;
|
||||
}
|
||||
var canvasCorners = new Vector3[4];
|
||||
Canvas.GetComponent<RectTransform>().GetWorldCorners(canvasCorners);
|
||||
_mapTexture = new RenderTexture(_size.x, _size.y, 0, RenderTextureFormat.Default);
|
||||
MapOverlayCamera.targetTexture = _mapTexture;
|
||||
OverlayDisplay.material.SetTexture("_DetailTex", _mapTexture);
|
||||
|
|
|
|||
|
|
@ -72,5 +72,6 @@ public enum MenuTab
|
|||
{
|
||||
Map,
|
||||
Inventory,
|
||||
Trade
|
||||
Trade,
|
||||
Galaxy
|
||||
}
|
||||
|
|
@ -95,6 +95,19 @@ public class PropertiesPanel : MonoBehaviour
|
|||
return section;
|
||||
}
|
||||
|
||||
public Property AddProperty(Func<string> read)
|
||||
{
|
||||
if (read == null) throw new ArgumentException("Attempted to add property with null read function!");
|
||||
|
||||
var property = Instantiate(Property, Content ?? transform);
|
||||
property.Label.text = read();
|
||||
|
||||
RefreshPropertyValues += () => property.Label.text = read();
|
||||
Properties.Add(property.gameObject);
|
||||
OnPropertyAdded?.Invoke(property.gameObject);
|
||||
return property;
|
||||
}
|
||||
|
||||
public Property AddProperty(string name, Func<string> read = null)
|
||||
{
|
||||
Property property;
|
||||
|
|
@ -348,7 +361,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
public void AddItemProperties(Entity entity, ItemInstance item)
|
||||
{
|
||||
var data = Context.ItemData.Get<ItemData>(item.Data);
|
||||
AddProperty(data.Description).Label.fontStyle = FontStyles.Normal;
|
||||
AddProperty(data.Description);//.Label.fontStyle = FontStyles.Normal;
|
||||
var manufacturer = Context.ItemData.Get<MegaCorporation>(data.Manufacturer);
|
||||
if (manufacturer != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
|
|
@ -16,7 +17,6 @@ public class SectorMap : MonoBehaviour
|
|||
public Camera InfluenceCamera;
|
||||
public Prototype InfluenceRendererPrototype;
|
||||
public MeshRenderer SectorRenderer;
|
||||
public SectorGenerationSettings Settings;
|
||||
public Prototype ZonePrototype;
|
||||
public Prototype LinkPrototype;
|
||||
public Prototype IconPrototype;
|
||||
|
|
@ -38,40 +38,34 @@ public class SectorMap : MonoBehaviour
|
|||
|
||||
private Dictionary<MegaCorporation, (RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)> _factionMaterials =
|
||||
new Dictionary<MegaCorporation, (RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)>();
|
||||
|
||||
void Start()
|
||||
|
||||
public void Start()
|
||||
{
|
||||
var filePath = new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData");
|
||||
var cache = new DatabaseCache();
|
||||
cache.Load(Path.Combine(filePath.FullName, "AetherDB.msgpack"));
|
||||
|
||||
var megas = cache.GetAll<MegaCorporation>();
|
||||
|
||||
var random = new Unity.Mathematics.Random((uint) (DateTime.Now.Ticks % uint.MaxValue));
|
||||
var sectorMegas = megas.OrderBy(x => Random.value).Take(Settings.MegaCount).ToArray();
|
||||
foreach (var mega in sectorMegas)
|
||||
if (ActionGameManager.CurrentSector == null)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
foreach (var mega in ActionGameManager.CurrentSector.Factions)
|
||||
{
|
||||
var primary = Instantiate(ZonePrimaryMaterial);
|
||||
primary.SetColor("_TintColor", (mega.PrimaryColor * MegaPrimaryBoost).ToColor());
|
||||
primary.SetColor("_Color", (mega.PrimaryColor * MegaPrimaryBoost).ToColor());
|
||||
var secondary = Instantiate(ZoneSecondaryMaterial);
|
||||
secondary.SetColor("_TintColor", (mega.SecondaryColor * MegaSecondaryBoost).ToColor());
|
||||
secondary.SetColor("_Color", (mega.SecondaryColor * MegaSecondaryBoost).ToColor());
|
||||
var link = Instantiate(ZoneLinkMaterial);
|
||||
link.SetColor("_TintColor", (mega.PrimaryColor * MegaLinkBoost).ToColor());
|
||||
_factionMaterials.Add(mega, (new RenderTexture(1024, 1024, 1, RenderTextureFormat.RHalf), primary, secondary, link));
|
||||
mega.NameGenerator = new MarkovNameGenerator(ref random, UnityHelpers.LoadAsset<TextAsset>(mega.GeonameFile).text, Settings);
|
||||
link.SetColor("_Color", (mega.PrimaryColor * MegaLinkBoost).ToColor());
|
||||
_factionMaterials.Add(mega, (new RenderTexture(1024, 1024, 0, RenderTextureFormat.RHalf), primary, secondary, link));
|
||||
var legendElement = LegendPrototype.Instantiate<LegendElement>();
|
||||
legendElement.Primary.color = mega.PrimaryColor.ToColor();
|
||||
legendElement.Secondary.color = mega.SecondaryColor.ToColor();
|
||||
legendElement.Label.text = mega.ShortName;
|
||||
}
|
||||
|
||||
Settings.NoisePosition = Random.value * 100;
|
||||
var sector = new Sector(Settings, sectorMegas, ref random);
|
||||
var visitedZones = new HashSet<SectorZone>();
|
||||
Debug.Log($"Found {sector.Zones.Count(z=>!z.AdjacentZones.Any())} orphaned zones!");
|
||||
//Debug.Log($"Found {sector.Zones.Count(z=>!z.AdjacentZones.Any())} orphaned zones!");
|
||||
|
||||
var zoneInstances = new Dictionary<SectorZone, SectorZoneUI>();
|
||||
foreach (var zone in sector.Zones)
|
||||
foreach (var zone in ActionGameManager.CurrentSector.Zones)
|
||||
{
|
||||
var zoneInstance = ZonePrototype.Instantiate<SectorZoneUI>();
|
||||
zoneInstances[zone] = zoneInstance;
|
||||
|
|
@ -109,10 +103,10 @@ public class SectorMap : MonoBehaviour
|
|||
zoneText.text = zone.Name;
|
||||
var zoneTextTransform = zoneText.GetComponent<RectTransform>();
|
||||
zoneTextTransform.pivot = new Vector2(sign(linkDirection.x)/2+.5f,sign(linkDirection.y)/2+.5f);
|
||||
zoneTextTransform.localPosition = new Vector3(-linkDirection.x * LabelDistance, -linkDirection.y * LabelDistance);
|
||||
zoneTextTransform.localPosition = new Vector3(-linkDirection.x * LabelDistance, -linkDirection.y * LabelDistance, -1);
|
||||
visitedZones.Add(zone);
|
||||
|
||||
if (zone == sector.Entrance)
|
||||
if (zone == ActionGameManager.CurrentSector.Entrance)
|
||||
{
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
iconInstance.material.mainTexture = EntranceIcon;
|
||||
|
|
@ -122,7 +116,7 @@ public class SectorMap : MonoBehaviour
|
|||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
if (zone == sector.Exit)
|
||||
if (zone == ActionGameManager.CurrentSector.Exit)
|
||||
{
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
iconInstance.material.mainTexture = ExitIcon;
|
||||
|
|
@ -132,15 +126,16 @@ public class SectorMap : MonoBehaviour
|
|||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
var homeMega = sector.HomeZones.Keys.FirstOrDefault(m => sector.HomeZones[m] == zone);
|
||||
var homeMega = ActionGameManager.CurrentSector.HomeZones.Keys
|
||||
.FirstOrDefault(m => ActionGameManager.CurrentSector.HomeZones[m] == zone);
|
||||
if (homeMega != null)
|
||||
{
|
||||
var backgroundInstance = IconBackgroundPrototype.Instantiate<MeshRenderer>();
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
|
||||
backgroundInstance.material.SetColor("_TintColor", homeMega.SecondaryColor.ToColor());
|
||||
backgroundInstance.material.SetColor("_Color", homeMega.SecondaryColor.ToColor());
|
||||
iconInstance.material.mainTexture = HomeIcon;
|
||||
iconInstance.material.SetColor("_TintColor", homeMega.PrimaryColor.ToColor());
|
||||
iconInstance.material.SetColor("_Color", homeMega.PrimaryColor.ToColor());
|
||||
|
||||
var backgroundTransform = backgroundInstance.transform;
|
||||
var iconTransform = iconInstance.transform;
|
||||
|
|
@ -155,15 +150,16 @@ public class SectorMap : MonoBehaviour
|
|||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
var bossMega = sector.BossZones.Keys.FirstOrDefault(m => sector.BossZones[m] == zone);
|
||||
var bossMega = ActionGameManager.CurrentSector.BossZones.Keys
|
||||
.FirstOrDefault(m => ActionGameManager.CurrentSector.BossZones[m] == zone);
|
||||
if (bossMega != null)
|
||||
{
|
||||
var backgroundInstance = IconBackgroundPrototype.Instantiate<MeshRenderer>();
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
|
||||
backgroundInstance.material.SetColor("_TintColor", bossMega.SecondaryColor.ToColor());
|
||||
backgroundInstance.material.SetColor("_Color", bossMega.SecondaryColor.ToColor());
|
||||
iconInstance.material.mainTexture = BossIcon;
|
||||
iconInstance.material.SetColor("_TintColor", bossMega.PrimaryColor.ToColor());
|
||||
iconInstance.material.SetColor("_Color", bossMega.PrimaryColor.ToColor());
|
||||
|
||||
var backgroundTransform = backgroundInstance.transform;
|
||||
var iconTransform = iconInstance.transform;
|
||||
|
|
@ -188,10 +184,10 @@ public class SectorMap : MonoBehaviour
|
|||
}
|
||||
|
||||
// Render Influence Textures
|
||||
foreach (var mega in sectorMegas)
|
||||
foreach (var mega in ActionGameManager.CurrentSector.Factions)
|
||||
{
|
||||
var influenceRenderer = InfluenceRendererPrototype.Instantiate<MeshRenderer>();
|
||||
foreach (var zone in sector.Zones)
|
||||
foreach (var zone in ActionGameManager.CurrentSector.Zones)
|
||||
{
|
||||
var instance = zoneInstances[zone];
|
||||
var influence = 0f;
|
||||
|
|
@ -214,21 +210,16 @@ public class SectorMap : MonoBehaviour
|
|||
influenceRenderer.material.mainTexture = _factionMaterials[mega].influence;
|
||||
influenceRenderer.material.SetColor("_Color1", mega.PrimaryColor.ToColor());
|
||||
influenceRenderer.material.SetColor("_Color2", mega.SecondaryColor.ToColor());
|
||||
influenceRenderer.material.SetFloat("_FillTilt", random.NextFloat(PI));
|
||||
influenceRenderer.material.SetFloat("_FillTilt", Random.value * PI);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
SectorRenderer.material.SetFloat("CloudAmplitude", Settings.CloudAmplitude);
|
||||
SectorRenderer.material.SetFloat("CloudExponent", Settings.CloudExponent);
|
||||
SectorRenderer.material.SetFloat("NoisePosition", Settings.NoisePosition);
|
||||
SectorRenderer.material.SetFloat("Zoom", Settings.Zoom);
|
||||
SectorRenderer.material.SetFloat("NoiseAmplitude", Settings.NoiseAmplitude);
|
||||
SectorRenderer.material.SetFloat("NoiseOffset", Settings.NoiseOffset);
|
||||
SectorRenderer.material.SetFloat("NoiseGain", Settings.NoiseGain);
|
||||
SectorRenderer.material.SetFloat("NoiseLacunarity", Settings.NoiseLacunarity);
|
||||
SectorRenderer.material.SetFloat("NoiseFrequency", Settings.NoiseFrequency);
|
||||
|
||||
SectorRenderer.material.SetFloat("CloudAmplitude", ActionGameManager.CurrentSector.Settings.CloudAmplitude);
|
||||
SectorRenderer.material.SetFloat("CloudExponent", ActionGameManager.CurrentSector.Settings.CloudExponent);
|
||||
SectorRenderer.material.SetFloat("NoisePosition", ActionGameManager.CurrentSector.Settings.NoisePosition);
|
||||
SectorRenderer.material.SetFloat("NoiseAmplitude", ActionGameManager.CurrentSector.Settings.NoiseAmplitude);
|
||||
SectorRenderer.material.SetFloat("NoiseOffset", ActionGameManager.CurrentSector.Settings.NoiseOffset);
|
||||
SectorRenderer.material.SetFloat("NoiseGain", ActionGameManager.CurrentSector.Settings.NoiseGain);
|
||||
SectorRenderer.material.SetFloat("NoiseLacunarity", ActionGameManager.CurrentSector.Settings.NoiseLacunarity);
|
||||
SectorRenderer.material.SetFloat("NoiseFrequency", ActionGameManager.CurrentSector.Settings.NoiseFrequency);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ public class TradeMenu : MonoBehaviour
|
|||
data => () =>
|
||||
{
|
||||
if (data is HullData)
|
||||
return GameManager.PlayerEntities.Count(s => s.Hull.Data == data.ID && s.Parent == GameManager.DockedEntity).ToString();
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data == data.ID && s is Ship {IsPlayerShip: true}).ToString();
|
||||
if(data is SimpleCommodityData)
|
||||
return (_targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0).ToString();
|
||||
return (_targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Count : 0).ToString();
|
||||
|
|
@ -280,7 +280,7 @@ public class TradeMenu : MonoBehaviour
|
|||
data =>
|
||||
{
|
||||
if (data is HullData)
|
||||
return GameManager.PlayerEntities.Count(s => s.Hull.Data == data.ID && s.Parent == GameManager.DockedEntity);
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data == data.ID && s is Ship {IsPlayerShip: true});
|
||||
if(data is SimpleCommodityData)
|
||||
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0;
|
||||
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Count : 0;
|
||||
|
|
@ -344,6 +344,7 @@ public class TradeMenu : MonoBehaviour
|
|||
|
||||
Populate();
|
||||
});
|
||||
Dialog.MoveToCursor();
|
||||
});
|
||||
ContextMenu.Show();
|
||||
}
|
||||
|
|
@ -358,10 +359,9 @@ public class TradeMenu : MonoBehaviour
|
|||
var hull = GameManager.ItemManager.CreateInstance(data) as EquippableItem;
|
||||
Entity entity;
|
||||
if(data.HullType==HullType.Ship)
|
||||
entity = new Ship(GameManager.ItemManager, GameManager.Zone, hull, GameManager.Settings.DefaultEntitySettings);
|
||||
else entity = new OrbitalEntity(GameManager.ItemManager, GameManager.Zone, hull, Guid.Empty, GameManager.Settings.DefaultEntitySettings);
|
||||
entity = new Ship(GameManager.ItemManager, GameManager.Zone, hull, GameManager.Settings.GameplaySettings.DefaultEntitySettings) {IsPlayerShip = true};
|
||||
else entity = new OrbitalEntity(GameManager.ItemManager, GameManager.Zone, hull, Guid.Empty, GameManager.Settings.GameplaySettings.DefaultEntitySettings);
|
||||
entity.SetParent(GameManager.DockedEntity);
|
||||
GameManager.PlayerEntities.Add(entity);
|
||||
|
||||
GameManager.Credits -= data.Price;
|
||||
}
|
||||
|
|
@ -370,6 +370,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Dialog.Clear();
|
||||
Dialog.Title.text = "Unable to buy: Insufficient Credits!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -388,6 +389,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Dialog.Clear();
|
||||
Dialog.Title.text = "Unable to buy: Insufficient Cargo Space!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -396,6 +398,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Dialog.Clear();
|
||||
Dialog.Title.text = "Unable to buy: Insufficient Credits!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -421,6 +424,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Dialog.Clear();
|
||||
Dialog.Title.text = "Unable to buy: Insufficient Cargo Space!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -429,6 +433,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Dialog.Clear();
|
||||
Dialog.Title.text = "Unable to buy: Insufficient Credits!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -448,7 +453,7 @@ public class TradeMenu : MonoBehaviour
|
|||
_targetCargo = GameManager.DockingBay;
|
||||
TargetCargoLabel.text = "Docking Bay";
|
||||
});
|
||||
foreach (var ship in GameManager.CurrentEntity.Parent.Children.Where(GameManager.PlayerEntities.Contains))
|
||||
foreach (var ship in GameManager.CurrentEntity.Parent.Children.Where(e => e is Ship {IsPlayerShip: true}))
|
||||
{
|
||||
foreach (var bay in ship.CargoBays.Select((bay, index) => (bay, index)))
|
||||
ContextMenu.AddOption($"{ship.Name} Bay {bay.index}",
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
using System;
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ZoneRenderer : MonoBehaviour
|
||||
{
|
||||
public Camera FollowCamera;
|
||||
public RenderTexture GravityTexture;
|
||||
public MeshRenderer GravityRenderer;
|
||||
|
||||
private int _resX, _resY;
|
||||
private float _ratio;
|
||||
private Camera _camera;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_camera = GetComponent<Camera>();
|
||||
}
|
||||
|
||||
private void OnPreRender()
|
||||
{
|
||||
_camera.transform.position = FollowCamera.transform.position;
|
||||
if (Screen.width != _resX || Screen.height != _resY)
|
||||
{
|
||||
_resX = Screen.width;
|
||||
_resY = Screen.height;
|
||||
_ratio = (float) _resX / _resY;
|
||||
if (GravityTexture != null)
|
||||
{
|
||||
GravityTexture?.Release();
|
||||
}
|
||||
GravityTexture = new RenderTexture(_resX, _resY, 0, RenderTextureFormat.RFloat);
|
||||
}
|
||||
|
||||
GravityRenderer.material.mainTexture = GravityTexture;
|
||||
|
||||
var size = _camera.orthographicSize = FollowCamera.orthographicSize;
|
||||
|
||||
GravityRenderer.transform.position = new Vector3(transform.position.x, transform.position.y, .25f);
|
||||
GravityRenderer.transform.localScale = new Vector3(size * 2 * _ratio, size * 2, 1);
|
||||
|
||||
_camera.targetTexture = GravityTexture;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 04277e392af12204397c334ea824f957
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue