Zone Properties Panel

You can now click on a zone to view what resources are present
This commit is contained in:
hyperion51 2020-05-01 00:09:09 +01:00
commit ba681abeb6
10 changed files with 2475 additions and 352 deletions

View file

@ -1747,6 +1747,7 @@
<e p="TechArrow.cs" t="Include" />
<e p="TechNode.cs" t="Include" />
<e p="ZoneObject.cs" t="Include" />
<e p="ZonePropertiesResource.cs" t="Include" />
<e p="ZoneRenderer.cs" t="Include" />
<e p="ZoneShip.cs" t="Include" />
</e>

View file

@ -914,6 +914,7 @@
<Compile Include="Assets\Scripts\UI\TechArrow.cs" />
<Compile Include="Assets\Scripts\UI\TechNode.cs" />
<Compile Include="Assets\Scripts\UI\ZoneObject.cs" />
<Compile Include="Assets\Scripts\UI\ZonePropertiesResource.cs" />
<Compile Include="Assets\Scripts\UI\ZoneRenderer.cs" />
<Compile Include="Assets\Scripts\UI\ZoneShip.cs" />
<Compile Include="Assets\Scripts\UnityExtensions.cs" />

View file

@ -0,0 +1,387 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5427704876334193406
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5427704876334193401}
- component: {fileID: 5427704876334193403}
- component: {fileID: 3847163166094013926}
m_Layer: 5
m_Name: Resource
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5427704876334193401
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5427704876334193406}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 5427704876509448083}
- {fileID: 3885286060680318645}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &5427704876334193403
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5427704876334193406}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1679637790, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: 64
m_FlexibleWidth: 1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!114 &3847163166094013926
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5427704876334193406}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e422bcc206d214044ab697caaac9fd12, type: 3}
m_Name:
m_EditorClassIdentifier:
NameLabel: {fileID: 5427704876509448082}
QuantityLabel: {fileID: 7059630196601159823}
--- !u!1 &5427704876509448080
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5427704876509448083}
- component: {fileID: 5427704876509448093}
- component: {fileID: 5427704876509448082}
m_Layer: 5
m_Name: Name
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5427704876509448083
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5427704876509448080}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 5427704876334193401}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5427704876509448093
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5427704876509448080}
m_CullTransparentMesh: 0
--- !u!114 &5427704876509448082
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5427704876509448080}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Dolor
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 9dcd07b95faae7641a3ff6fccab43c32, type: 2}
m_sharedMaterial: {fileID: 21906973755630180, guid: 9dcd07b95faae7641a3ff6fccab43c32,
type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 1
m_textAlignment: 513
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_firstOverflowCharacterIndex: -1
m_linkedTextComponent: {fileID: 0}
m_isLinkedTextComponent: 0
m_isTextTruncated: 0
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_ignoreRectMaskCulling: 0
m_ignoreCulling: 1
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_VertexBufferAutoSizeReduction: 1
m_firstVisibleCharacter: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_textInfo:
textComponent: {fileID: 5427704876509448082}
characterCount: 5
spriteCount: 0
spaceCount: 0
wordCount: 1
linkCount: 0
lineCount: 1
pageCount: 1
materialCount: 1
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_spriteAnimator: {fileID: 0}
m_hasFontAssetChanged: 0
m_subTextObjects:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &6914432219637367135
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3885286060680318645}
- component: {fileID: 7069940623071928653}
- component: {fileID: 7059630196601159823}
m_Layer: 5
m_Name: Quantity
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3885286060680318645
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6914432219637367135}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 5427704876334193401}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7069940623071928653
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6914432219637367135}
m_CullTransparentMesh: 0
--- !u!114 &7059630196601159823
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6914432219637367135}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 123456789
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 9dcd07b95faae7641a3ff6fccab43c32, type: 2}
m_sharedMaterial: {fileID: 21906973755630180, guid: 9dcd07b95faae7641a3ff6fccab43c32,
type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_textAlignment: 516
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_firstOverflowCharacterIndex: -1
m_linkedTextComponent: {fileID: 0}
m_isLinkedTextComponent: 0
m_isTextTruncated: 0
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_ignoreRectMaskCulling: 0
m_ignoreCulling: 1
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_VertexBufferAutoSizeReduction: 1
m_firstVisibleCharacter: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_textInfo:
textComponent: {fileID: 7059630196601159823}
characterCount: 9
spriteCount: 0
spaceCount: 0
wordCount: 1
linkCount: 0
lineCount: 1
pageCount: 1
materialCount: 1
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_spriteAnimator: {fileID: 0}
m_hasFontAssetChanged: 0
m_subTextObjects:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c88ab84dc56cd384b9392a382d0f5441
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Resources/Test Galaxy.asset (Stored with Git LFS)

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -64,6 +64,7 @@ public class GameContext
var zoneData = Cache.Get<ZoneData>(zoneID);
// TODO: Associate planets with stored entities for planetary colonies
var planetsData = zoneData.Planets.Select(id => Cache.Get<PlanetData>(id)).ToArray();
var planetEntities = planetsData.ToDictionary(p => p,
p => new OrbitalEntity(this, null, Enumerable.Empty<Gear>(), Enumerable.Empty<ItemInstance>(), p.Belt ? Cache.Get<OrbitData>(p.Orbit).Parent : p.Orbit));

View file

@ -3,7 +3,9 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NaughtyAttributes;
using RethinkDb.Driver.Net;
using TMPro;
using UnityEngine;
using Unity.Mathematics;
using static Unity.Mathematics.math;
@ -12,34 +14,54 @@ using Random = UnityEngine.Random;
public class StrategyGameManager : MonoBehaviour
{
public bool TestMode;
[Section("Scene Links")]
public Camera Camera;
public TechTreeMsagl TechTree;
public MeshRenderer GalaxyBackground;
public Transform ZoneRoot;
public MeshRenderer ZoneBackground;
public MeshRenderer ZoneBoundary;
public ClickRaycaster ClickRaycaster;
[Section("Tab Links")]
public TabGroup PrimaryTabGroup;
public TabButton GalaxyTabButton;
public TabButton ZoneTabButton;
public TabButton TechTabButton;
public TechTreeMsagl TechTree;
[Section("Prefabs & Prototypes")]
public Prototype GalaxyZonePrototype;
public Prototype GalaxyZoneLinkPrototype;
public MeshRenderer GalaxyBackground;
public float GalaxyScale;
public ZoneObject ZoneObjectPrefab;
public ZoneShip ZoneShipPrefab;
public ParticleSystem BeltPrefab;
public Transform ZoneRoot;
[Section("Textures")]
public Texture2D PlanetoidSprite;
public Texture2D PlanetSprite;
public Texture2D GasGiantSprite;
public Texture2D OrbitalSprite;
public Texture2D SunSprite;
public Texture2D WormholeSprite;
[Section("UI Properties")]
public Color SelectedColor;
public Color UnselectedColor;
public float GalaxyScale;
public float ZoneSizeScale = .01f;
public float ZoneMassScale = .01f;
public float ZoneMassPower = .5f;
public MeshRenderer ZoneBackground;
public MeshRenderer ZoneBoundary;
public bool TestMode;
[Section("Zone Properties Panel")]
public RectTransform ZonePropertiesPanel;
public TextMeshProUGUI ZoneTitle;
public RectTransform[] ZonePlanetProperties;
public TextMeshProUGUI ZonePropertiesName;
public TextMeshProUGUI ZonePropertiesMass;
public Transform ZonePropertiesResourcesParent;
public ZonePropertiesResource ZonePropertiesResourcePrefab;
private DatabaseCache _cache;
private GameContext _context;
@ -55,6 +77,7 @@ public class StrategyGameManager : MonoBehaviour
private Dictionary<OrbitalEntity, ParticleSystem> _zoneBelts = new Dictionary<OrbitalEntity, ParticleSystem>();
private Dictionary<Ship, ZoneShip> _zoneShips = new Dictionary<Ship, ZoneShip>();
private List<ZoneObject> _wormholes = new List<ZoneObject>();
private List<ZonePropertiesResource> _zonePropertiesResources = new List<ZonePropertiesResource>();
private Vector3 _galaxyCameraPos = -Vector3.forward;
private float _galaxyOrthoSize = 50;
private Material _boundaryMaterial;
@ -147,6 +170,8 @@ public class StrategyGameManager : MonoBehaviour
_boundaryMaterial = ZoneBoundary.material;
_backgroundMaterial = ZoneBackground.material;
ClickRaycaster.OnClickMiss += () => ZonePropertiesPanel.gameObject.SetActive(false);
}
void spawn(string[] args)
@ -411,6 +436,8 @@ public class StrategyGameManager : MonoBehaviour
ZoneData zoneData = _cache.Get<ZoneData>(_populatedZone);
ZoneTitle.text = zoneData.Name;
if (TestMode && !zoneData.Visited)
{
float2 position;
@ -460,6 +487,27 @@ public class StrategyGameManager : MonoBehaviour
planetData.Mass > _context.GlobalData.GasGiantMass ? GasGiantSprite :
planetData.Mass > _context.GlobalData.PlanetMass ? PlanetSprite :
PlanetoidSprite);
planetObject.Icon.GetComponent<ClickableCollider>().OnClick += (collider, data) =>
{
ZonePropertiesPanel.gameObject.SetActive(true);
foreach (var zonePlanetProperty in ZonePlanetProperties)
zonePlanetProperty.gameObject.SetActive(true);
foreach (var zonePropertiesResource in _zonePropertiesResources)
Destroy(zonePropertiesResource.gameObject);
_zonePropertiesResources.Clear();
ZonePropertiesName.text = planetData.Name;
ZonePropertiesMass.text = $"{planetData.Mass}";
foreach (var resource in planetData.Resources)
{
var itemData = _context.Cache.Get<SimpleCommodityData>(resource.Key);
var resourceInstance = Instantiate(ZonePropertiesResourcePrefab, ZonePropertiesResourcesParent);
resourceInstance.NameLabel.text = itemData.Name;
resourceInstance.QuantityLabel.text = $"{resource.Value:0}";
_zonePropertiesResources.Add(resourceInstance);
}
};
}
else
{

View file

@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class ZonePropertiesResource : MonoBehaviour
{
public TextMeshProUGUI NameLabel;
public TextMeshProUGUI QuantityLabel;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e422bcc206d214044ab697caaac9fd12
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: