From f340e992ecb735a5b6bf5d2556a256acc9721e5d Mon Sep 17 00:00:00 2001 From: Reinier Vens Date: Tue, 9 Mar 2021 02:26:58 +0000 Subject: [PATCH] Game Loop Player spawns in starter ship, is presented with a game over screen when they die, with the option to start over --- .../Materials/Jittered Grid Fog Marching.mat | 6 +- Assets/Materials/UI/Map Gravity Lines.mat | 2 +- Assets/Resources/Settings.asset | 4 +- Assets/Scenes/ARPG.unity | 156 +++++++++-- .../Postprocessing Profile Death.asset | 3 + .../Postprocessing Profile Death.asset.meta | 8 + .../Postprocessing Profile Heatstroke.asset | 4 +- ...processing Profile Severe Heatstroke.asset | 4 +- .../Postprocessing Profile.asset | 4 +- Assets/Scripts/Gameplay/ActionGameManager.cs | 254 ++++++++++-------- Assets/Scripts/ServerShared/Entity.cs | 43 +-- Assets/Scripts/ServerShared/Zone.cs | 4 + Assets/Scripts/UI/ConfirmationDialog.cs | 7 +- GameData/AetherDB.msgpack | Bin 62061 -> 62061 bytes 14 files changed, 340 insertions(+), 159 deletions(-) create mode 100644 Assets/Scenes/ARPG_Profiles/Postprocessing Profile Death.asset create mode 100644 Assets/Scenes/ARPG_Profiles/Postprocessing Profile Death.asset.meta diff --git a/Assets/Materials/Jittered Grid Fog Marching.mat b/Assets/Materials/Jittered Grid Fog Marching.mat index 9361282d0..cf0d57d91 100644 --- a/Assets/Materials/Jittered Grid Fog Marching.mat +++ b/Assets/Materials/Jittered Grid Fog Marching.mat @@ -43,7 +43,7 @@ Material: - _AlphaFloor: 0 - _DepthBlend: 512 - _DepthCeiling: 4096 - - _Gamma: 0.45 + - _Gamma: 0.5 - _GridCeilingBlend: -300 - _GridCeilingDensity: 0.01 - _GridCeilingFollow: 0 @@ -59,7 +59,7 @@ Material: - _NoiseStrength: 75 - _SafetyDistance: 50 - _StepExponent: 2 - - _TintExponent: 4 + - _TintExponent: 8 m_Colors: - - _Tint: {r: 0.75, g: 0.75, b: 0.75, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_BuildTextureStacks: [] diff --git a/Assets/Materials/UI/Map Gravity Lines.mat b/Assets/Materials/UI/Map Gravity Lines.mat index 49aa30d41..408eb100a 100644 --- a/Assets/Materials/UI/Map Gravity Lines.mat +++ b/Assets/Materials/UI/Map Gravity Lines.mat @@ -86,7 +86,7 @@ Material: - _Mode: 0 - _OcclusionStrength: 1 - _Parallax: 0.02 - - _Scale: 4.933006 + - _Scale: 8.983329 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 diff --git a/Assets/Resources/Settings.asset b/Assets/Resources/Settings.asset index 432331c09..9a27aac40 100644 --- a/Assets/Resources/Settings.asset +++ b/Assets/Resources/Settings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:28d4bbe38944332d1532370d7ef2ad18549e00beca1abbb0e8d329d402f87b32 -size 8653 +oid sha256:5d093dd0324dada913dfe998d44e6311d737a3bcfa22a78a1228496245d00881 +size 8652 diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity index e338f9418..6d6539fca 100644 --- a/Assets/Scenes/ARPG.unity +++ b/Assets/Scenes/ARPG.unity @@ -1609,7 +1609,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &134113272 MonoBehaviour: @@ -2332,7 +2332,7 @@ Transform: - {fileID: 488792361} - {fileID: 970624070} m_Father: {fileID: 1665127616} - m_RootOrder: 7 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &204301709 GameObject: @@ -4230,6 +4230,18 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &346333149 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1713457305180270767, guid: 2758dfa2744d7ad4d8877545189d116e, + type: 3} + m_PrefabInstance: {fileID: 1554374157} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &359038938 GameObject: m_ObjectHideFlags: 3 @@ -8090,6 +8102,8 @@ MonoBehaviour: ButtonGroup: {fileID: 947321577} Cancel: {fileID: 1176624628} Confirm: {fileID: 843760693} + ConfirmText: {fileID: 1183272246} + CancelText: {fileID: 346333149} --- !u!114 &620555925 MonoBehaviour: m_ObjectHideFlags: 0 @@ -8972,7 +8986,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &677710706 GameObject: @@ -10750,6 +10764,54 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &803284854 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 803284855} + - component: {fileID: 803284856} + m_Layer: 8 + m_Name: Death Postprocessing + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &803284855 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 803284854} + 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: 906767442} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &803284856 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 803284854} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8b9a305e18de0c04dbd257a21cd47087, type: 3} + m_Name: + m_EditorClassIdentifier: + sharedProfile: {fileID: 11400000, guid: 793d6584f1c67544abb5ac31b8d2a57d, type: 2} + isGlobal: 1 + blendDistance: 0 + weight: 0 + priority: 3 --- !u!1 &804489111 GameObject: m_ObjectHideFlags: 0 @@ -11180,7 +11242,7 @@ Transform: - {fileID: 1075335641} - {fileID: 166261017} m_Father: {fileID: 1665127616} - m_RootOrder: 8 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &831892783 GameObject: @@ -11243,12 +11305,12 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 837424433} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: 1665127616} - m_RootOrder: 5 + m_Father: {fileID: 906767442} + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &837424435 MonoBehaviour: @@ -11852,6 +11914,40 @@ Transform: m_Father: {fileID: 1665127616} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &906767441 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 906767442} + m_Layer: 0 + m_Name: PostProcessing + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &906767442 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 906767441} + 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: 937280108} + - {fileID: 1404901905} + - {fileID: 837424434} + - {fileID: 803284855} + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &906882333 GameObject: m_ObjectHideFlags: 0 @@ -12358,12 +12454,12 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 937280107} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: 1665127616} - m_RootOrder: 3 + m_Father: {fileID: 906767442} + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &937280109 MonoBehaviour: @@ -13313,8 +13409,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 39f95af24dd29a645895a57a75460b0c, type: 3} m_Name: m_EditorClassIdentifier: + StarterShipTemplate: Longinus TargetSpottedBlinkFrequency: 20 TargetSpottedBlinkOffset: -0.25 + DeathPPTransitionTime: 0 + DeathPP: {fileID: 0} HeatstrokePP: {fileID: 1404901906} SevereHeatstrokePP: {fileID: 837424435} HostileTargetIndicator: {fileID: 1787772783} @@ -13357,7 +13456,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1009503731 MonoBehaviour: @@ -13927,7 +14026,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1019449643 MonoBehaviour: @@ -14061,7 +14160,7 @@ Transform: - {fileID: 1108843909} - {fileID: 1647230682} m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} --- !u!1 &1060591358 GameObject: @@ -15061,6 +15160,18 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &1183272246 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1713457305180270767, guid: 2758dfa2744d7ad4d8877545189d116e, + type: 3} + m_PrefabInstance: {fileID: 1593845000} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1187323005 GameObject: m_ObjectHideFlags: 0 @@ -16820,12 +16931,12 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1404901904} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: 1665127616} - m_RootOrder: 4 + m_Father: {fileID: 906767442} + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1404901906 MonoBehaviour: @@ -17929,7 +18040,7 @@ Transform: m_LocalScale: {x: 2.3802, y: 2.3802, z: 2.3802} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 19.345, y: 0, z: 0} --- !u!1 &1523113324 GameObject: @@ -18343,7 +18454,7 @@ Transform: - {fileID: 1537342002} - {fileID: 39508928} m_Father: {fileID: 1665127616} - m_RootOrder: 6 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1547889400 MonoBehaviour: @@ -18409,7 +18520,7 @@ PrefabInstance: - target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e, type: 3} propertyPath: m_AnchoredPosition.x - value: 0 + value: 55.675 objectReference: {fileID: 0} - target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e, type: 3} @@ -19439,7 +19550,7 @@ PrefabInstance: - target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e, type: 3} propertyPath: m_AnchoredPosition.x - value: 0 + value: 60.98 objectReference: {fileID: 0} - target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e, type: 3} @@ -20074,9 +20185,6 @@ Transform: - {fileID: 887677623} - {fileID: 393266592} - {fileID: 2115559090} - - {fileID: 937280108} - - {fileID: 1404901905} - - {fileID: 837424434} - {fileID: 1547889399} - {fileID: 199435031} - {fileID: 826773974} @@ -23566,7 +23674,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2101419017 GameObject: diff --git a/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Death.asset b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Death.asset new file mode 100644 index 000000000..dd707b620 --- /dev/null +++ b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Death.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec11ada2de5bddcc73f1d0172f95887a2bee6ce4c028292a6b33cbb6c96ac78f +size 26338 diff --git a/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Death.asset.meta b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Death.asset.meta new file mode 100644 index 000000000..93492321b --- /dev/null +++ b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Death.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 793d6584f1c67544abb5ac31b8d2a57d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Heatstroke.asset b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Heatstroke.asset index dd942ff07..c9cddbe1b 100644 --- a/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Heatstroke.asset +++ b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Heatstroke.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:59eae226239b838c23ad3ab9517acc279af0601e97ddc04805c79824114c8c6d -size 25079 +oid sha256:82263a7dffcddf1055069801de1a5fee4d14e2f849e7fdc10dd5364beb65a2fb +size 25722 diff --git a/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Severe Heatstroke.asset b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Severe Heatstroke.asset index 522cc9b9e..a917e5853 100644 --- a/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Severe Heatstroke.asset +++ b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Severe Heatstroke.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:52a2533eeb2847de31677711ed51feac8cf27919be1b2e749e14941bcfcac565 -size 25736 +oid sha256:86b9752b18cb67690613fa799847e345bd9e70b730fea0dc538b6460236e144d +size 26377 diff --git a/Assets/Scenes/ARPG_Profiles/Postprocessing Profile.asset b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile.asset index 2173785a7..58a75ec3c 100644 --- a/Assets/Scenes/ARPG_Profiles/Postprocessing Profile.asset +++ b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1234dcaed3b2de3e54d94614162415c17688e02eb570d9da58d27c4daa961db1 -size 25029 +oid sha256:567805de3c4efaf1908e2e0faa4822c68fc3ca7e8037433660ace6d22cdd2ede +size 25673 diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index a6a19e4c5..0fcaa0dff 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -23,8 +23,11 @@ using Random = UnityEngine.Random; public class ActionGameManager : MonoBehaviour { + public string StarterShipTemplate = "Longinus"; public float TargetSpottedBlinkFrequency = 20; public float TargetSpottedBlinkOffset = -.25f; + public float DeathPPTransitionTime; + public PostProcessVolume DeathPP; public PostProcessVolume HeatstrokePP; public PostProcessVolume SevereHeatstrokePP; public Prototype HostileTargetIndicator; @@ -65,7 +68,6 @@ public class ActionGameManager : MonoBehaviour private Ship _currentShip; // private ShipInput _shipInput; - private List _shipAgents = new List(); private float2 _shipYawPitch; private float3 _viewDirection; private (HardpointData[] hardpoints, Transform[] barrels, PlaceUIElementWorldspace crosshair)[] _articulationGroups; @@ -118,6 +120,10 @@ public class ActionGameManager : MonoBehaviour if (CurrentShip != null) { CurrentShip.Deactivate(); + if (CurrentShip.Zone != null) + { + CurrentShip.Zone.Entities.Remove(CurrentShip); + } CurrentShip.Zone = Zone; Zone.Entities.Add(CurrentShip); CurrentShip.Activate(); @@ -126,7 +132,64 @@ public class ActionGameManager : MonoBehaviour SectorRenderer.LoadZone(Zone); if (CurrentShip != null) + { + DisposeEntityBinding(); BindToEntity(); + } + + var testCorp = new MegaCorporation(); + testCorp.Name = "TestCorp"; + testCorp.PlayerHostile = true; + + var stationType = ItemData.GetAll().First(x=>x.HullType==HullType.Station); + var stationHull = ItemManager.CreateInstance(stationType) as EquippableItem; + var stationParent = Zone.PlanetInstances.Values.OrderByDescending(p => p.BodyData.Mass.Value).ElementAt(3); + var stationParentOrbit = stationParent.Orbit.Data.ID; + var stationParentPos = Zone.GetOrbitPosition(stationParentOrbit); + var stationPos = stationParentPos + ItemManager.Random.NextFloat2Direction() * stationParent.GravityWellRadius.Value * .1f; + var stationOrbit = Zone.CreateOrbit(stationParentOrbit, stationPos); + var station = new OrbitalEntity(ItemManager, Zone, stationHull, stationOrbit.ID); + //station.Faction = testCorp; + Zone.Entities.Add(station); + var dockingBayData = ItemData.GetAll().First(); + var dockingBay = ItemManager.CreateInstance(dockingBayData) as EquippableItem; + station.TryEquip(dockingBay); + station.Activate(); + + var turretLoadout = Loadouts.First(x => x.Name == "Turret"); + + for(int i=0; i<3; i++) + { + var planet = Zone.PlanetInstances.Values.OrderByDescending(p => p.BodyData.Mass.Value).ElementAt(4+i); + var planetOrbit = planet.Orbit.Data.ID; + var planetPos = Zone.GetOrbitPosition(planetOrbit); + for (int j = 0; j < 2; j++) + { + var pos = planetPos + ItemManager.Random.NextFloat2Direction() * planet.GravityWellRadius.Value * (.1f + .1f * j); + var orbit = Zone.CreateOrbit(planetOrbit, pos); + var turret = EntityPack.Unpack(ItemManager, Zone, turretLoadout, orbit.ID, true); + turret.Activate(); + turret.Name = $"Turret {i}-{(char) ('A' + j)}"; + turret.Faction = testCorp; + Zone.Entities.Add(turret); + } + } + + var enemyShipLoadout = Loadouts.First(x => ((HullData) ItemManager.GetData(x.Hull)).HullType == HullType.Ship); + var enemyShip = EntityPack.Unpack(ItemManager, Zone, enemyShipLoadout, true); + enemyShip.Faction = testCorp; + enemyShip.Activate(); + Zone.Entities.Add(enemyShip); + Zone.Agents.Add(CreateAgent(enemyShip)); + } + + private Agent CreateAgent(Ship ship) + { + var agent = new Minion(ship); + var task = new PatrolOrbitsTask(); + task.Circuit = Zone.Orbits.OrderBy(_ => Random.value).Take(4).Select(x => x.Key).ToArray(); + agent.Task = task; + return agent; } void Start() @@ -154,8 +217,8 @@ public class ActionGameManager : MonoBehaviour .Select(fi => MessagePackSerializer.Deserialize(File.ReadAllBytes(fi.FullName)))); //var zoneFile = Path.Combine(_filePath.FullName, "Home.zone"); - - GenerateLevel(); + + #region Input Handling _input = new AetheriaInput(); _input.Global.Enable(); @@ -419,6 +482,9 @@ public class ActionGameManager : MonoBehaviour #endregion + #endregion + + StartGame(); // ConsoleController.AddCommand("editmode", _ => ToggleEditMode()); ConsoleController.AddCommand("savezone", args => { @@ -426,69 +492,6 @@ public class ActionGameManager : MonoBehaviour Zone.Data.Name = args[0]; SaveZone(); }); - - var testCorp = new MegaCorporation(); - testCorp.Name = "TestCorp"; - testCorp.PlayerHostile = true; - - var stationType = ItemData.GetAll().First(x=>x.HullType==HullType.Station); - var stationHull = ItemManager.CreateInstance(stationType) as EquippableItem; - var stationParent = Zone.PlanetInstances.Values.OrderByDescending(p => p.BodyData.Mass.Value).ElementAt(3); - var stationParentOrbit = stationParent.Orbit.Data.ID; - var stationParentPos = Zone.GetOrbitPosition(stationParentOrbit); - var stationPos = stationParentPos + ItemManager.Random.NextFloat2Direction() * stationParent.GravityWellRadius.Value * .1f; - var stationOrbit = Zone.CreateOrbit(stationParentOrbit, stationPos); - var station = new OrbitalEntity(ItemManager, Zone, stationHull, stationOrbit.ID); - station.Faction = testCorp; - Zone.Entities.Add(station); - var dockingBayData = ItemData.GetAll().First(); - var dockingBay = ItemManager.CreateInstance(dockingBayData) as EquippableItem; - station.TryEquip(dockingBay); - station.Activate(); - - var turretLoadout = Loadouts.First(x => x.Name == "Turret"); - - for(int i=0; i<3; i++) - { - var planet = Zone.PlanetInstances.Values.OrderByDescending(p => p.BodyData.Mass.Value).ElementAt(4+i); - var planetOrbit = planet.Orbit.Data.ID; - var planetPos = Zone.GetOrbitPosition(planetOrbit); - for (int j = 0; j < 2; j++) - { - var pos = planetPos + ItemManager.Random.NextFloat2Direction() * planet.GravityWellRadius.Value * (.1f + .1f * j); - var orbit = Zone.CreateOrbit(planetOrbit, pos); - var turret = EntityPack.Unpack(ItemManager, Zone, turretLoadout, orbit.ID, true); - turret.Activate(); - turret.Name = $"Turret {i}-{(char) ('A' + j)}"; - turret.Faction = testCorp; - Zone.Entities.Add(turret); - } - } - - var enemyShipLoadout = Loadouts.First(x => ((HullData) ItemManager.GetData(x.Hull)).HullType == HullType.Ship); - var enemyShip = EntityPack.Unpack(ItemManager, Zone, enemyShipLoadout, true); - enemyShip.Faction = testCorp; - enemyShip.Activate(); - Zone.Entities.Add(enemyShip); - var agent = new Minion(enemyShip); - var task = new PatrolOrbitsTask(); - task.Circuit = Zone.Orbits.OrderBy(_ => Random.value).Take(4).Select(x => x.Key).ToArray(); - agent.Task = task; - _shipAgents.Add(agent); - - DockedEntity = station; - SectorRenderer.PerspectiveEntity = DockedEntity; - DockingBay = station.DockingBays.First(); - DockCamera.enabled = true; - FollowCamera.enabled = false; - DockCamera.Follow = SectorRenderer.EntityInstances[station].transform; - var parentOrbit = Zone.Orbits[station.OrbitData].Data.Parent; - var parentPlanet = SectorRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit == parentOrbit).Key]; - DockCamera.LookAt = parentPlanet.Body.transform; - Menu.ShowTab(MenuTab.Inventory); - Cursor.lockState = CursorLockMode.None; - _input.Player.Disable(); - GameplayUI.SetActive(false); // MapButton.onClick.AddListener(() => // { @@ -501,6 +504,20 @@ public class ActionGameManager : MonoBehaviour //InventoryPanel.Display(ItemManager, entity); } + private void StartGame() + { + GenerateLevel(); + CurrentShip = EntityPack.Unpack(ItemManager, Zone, Loadouts.First(x => x.Name == StarterShipTemplate), true); + CurrentShip.Zone = Zone; + Zone.Entities.Add(CurrentShip); + CurrentShip.Activate(); + BindToEntity(); + CurrentShip.ExitWormhole( + SectorRenderer.WormholeInstances.Keys.First().Position, + ItemManager.Random.NextFloat2Direction() * Settings.GameplaySettings.WormholeExitVelocity); + EnterOverworld(); + } + public void Dock() { if (CurrentShip.Parent != null) return; @@ -512,8 +529,7 @@ public class ActionGameManager : MonoBehaviour var bay = entity.TryDock(CurrentShip); if (bay != null) { - foreach(var subscription in _shipSubscriptions) subscription.Dispose(); - _shipSubscriptions.Clear(); + DisposeEntityBinding(); DockedEntity = entity; SectorRenderer.PerspectiveEntity = DockedEntity; DockingBay = bay; @@ -525,11 +541,6 @@ public class ActionGameManager : MonoBehaviour var parentPlanet = SectorRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit == parentOrbit).Key]; DockCamera.LookAt = parentPlanet.Body.transform; Menu.ShowTab(MenuTab.Inventory); - Cursor.lockState = CursorLockMode.None; - _input.Player.Disable(); - GameplayUI.SetActive(false); - if(_lockingIndicators!=null) foreach(var (_, indicator, _) in _lockingIndicators) - indicator.GetComponent().ReturnToPool(); AkSoundEngine.PostEvent("Dock", gameObject); return; } @@ -564,35 +575,9 @@ public class ActionGameManager : MonoBehaviour } else if (CurrentShip.Parent.TryUndock(CurrentShip)) { - Menu.gameObject.SetActive(false); - DockedEntity = null; - DockingBay = null; - //_shipInput = new ShipInput(_input.Player, _currentShip); - DockCamera.enabled = false; - FollowCamera.enabled = true; - BindToEntity(); - _lockingIndicators = CurrentShip.GetBehaviors() - .Select(x => - { - var i = LockIndicator.Instantiate(); - return (x, i, i.GetComponent()); - }).ToArray(); - - // CurrentShip.HullDamage.Subscribe(f => - // { - // if (float.IsNaN(CurrentShip.Hull.Durability)) - // Debug.Log("WTF!"); - // }); - - //_shipSubscriptions.Add(CurrentShip.HeatstrokeRisk.Subscribe(_ => _severeHeatstrokePhase = 0)); - - Cursor.lockState = CursorLockMode.Locked; - GameplayUI.SetActive(true); - _input.Player.Enable(); - ShipPanel.Display(CurrentShip, true); - SchematicDisplay.ShowShip(CurrentShip); + EnterOverworld(); AkSoundEngine.PostEvent("Undock", gameObject); } else @@ -603,6 +588,39 @@ public class ActionGameManager : MonoBehaviour } } + private void DisposeEntityBinding() + { + foreach (var indicator in _visibleHostileIndicators) + { + Destroy(indicator.Value.gameObject); + } + + _visibleHostileIndicators.Clear(); + if(_lockingIndicators!=null) foreach(var (_, indicator, _) in _lockingIndicators) + indicator.GetComponent().ReturnToPool(); + _input.Player.Disable(); + Cursor.lockState = CursorLockMode.None; + GameplayUI.SetActive(false); + + foreach(var subscription in _shipSubscriptions) subscription.Dispose(); + _shipSubscriptions.Clear(); + } + + private void EnterOverworld() + { + Menu.gameObject.SetActive(false); + DockedEntity = null; + DockingBay = null; + DockCamera.enabled = false; + FollowCamera.enabled = true; + + Cursor.lockState = CursorLockMode.Locked; + GameplayUI.SetActive(true); + _input.Player.Enable(); + ShipPanel.Display(CurrentShip, true); + SchematicDisplay.ShowShip(CurrentShip); + } + private void BindToEntity() { SectorRenderer.PerspectiveEntity = CurrentShip; @@ -627,9 +645,6 @@ public class ActionGameManager : MonoBehaviour foreach (var group in _articulationGroups) group.crosshair.gameObject.SetActive(true); - foreach(var subscription in _shipSubscriptions) subscription.Dispose(); - _shipSubscriptions.Clear(); - _shipSubscriptions.Add(CurrentShip.Target.Subscribe(target => { TargetIndicator.gameObject.SetActive(CurrentShip.Target.Value != null); @@ -656,6 +671,37 @@ public class ActionGameManager : MonoBehaviour _visibleHostileIndicators[removeEvent.Value].GetComponent().ReturnToPool(); _visibleHostileIndicators.Remove(removeEvent.Value); })); + + _shipSubscriptions.Add(CurrentShip.Death.Subscribe(_ => + { + var deathTime = Time.time; + DisposeEntityBinding(); + CurrentShip = null; + ConfirmationDialog.Clear(); + ConfirmationDialog.Title.text = "You have died!"; + ConfirmationDialog.Show(StartGame, null, "Try again!"); + Observable.EveryUpdate() + .Select(_ => (Time.time - deathTime) / DeathPPTransitionTime) + .Where(t => t < 1) + .Subscribe(t => + { + HeatstrokePP.weight = 1 - t; + SevereHeatstrokePP.weight = 1 - t; + DeathPP.weight = t; + }, () => + { + HeatstrokePP.weight = 0; + SevereHeatstrokePP.weight = 0; + DeathPP.weight = 1; + }); + })); + + _lockingIndicators = CurrentShip.GetBehaviors() + .Select(x => + { + var i = LockIndicator.Instantiate(); + return (x, i, i.GetComponent()); + }).ToArray(); } public void SaveZone() => File.WriteAllBytes( @@ -720,8 +766,6 @@ public class ActionGameManager : MonoBehaviour max(Settings.HeatstrokePhasingFloor, sin(Time.time * Settings.HeatstrokePhasingFrequency)); } } - foreach(var agent in _shipAgents) - agent.Update(Time.deltaTime); Zone.Update(_time, Time.deltaTime); SectorRenderer.GameTime = _time; } diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index 89b4099c4..73f4cfec1 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -118,11 +118,13 @@ public abstract class Entity public Subject HullDamage = new Subject(); public Subject Docked = new Subject(); public Subject HeatstrokeRisk = new Subject(); + public Subject HeatstrokeDeath = new Subject(); public UniRx.IObservable ItemDestroyed; public UniRx.IObservable HullArmorDepleted; public UniRx.IObservable HardpointArmorDepleted; public UniRx.IObservable WeaponDestroyed; + public UniRx.IObservable Death; private List _subscriptions = new List(); @@ -175,6 +177,7 @@ public abstract class Entity ItemDestroyed = ItemDamage.Where(x => x.item.EquippableItem.Durability < .01f).Select(x=>x.item); WeaponDestroyed = ItemDestroyed.Select(x => x.Behaviors.FirstOrDefault(b => b is Weapon) as Weapon).Where(x => x != null); HullArmorDepleted = ArmorDamage.Where(x => Armor[x.pos.x, x.pos.y] < .01f).Select(x => x.pos); + Death = HullDamage.Select(_ => Unit.Default).Where(_ => Hull.Durability < .01f).Merge(HeatstrokeDeath); EntityInfoGathered.ObserveReplace().Subscribe(replace => { @@ -742,26 +745,32 @@ public abstract class Entity UpdateTemperature(delta); - if(Cockpit != null) - { - if (Cockpit.Item.Temperature > ItemManager.GameplaySettings.HeatstrokeTemperature) - { - var previous = Heatstroke; - Heatstroke = saturate( - Heatstroke + - pow(Cockpit.Item.Temperature - ItemManager.GameplaySettings.HeatstrokeTemperature, ItemManager.GameplaySettings.HeatstrokeExponent) * - ItemManager.GameplaySettings.HeatstrokeMultiplier * delta); - if(previous < ItemManager.GameplaySettings.SevereHeatstrokeRiskThreshold && Heatstroke > ItemManager.GameplaySettings.SevereHeatstrokeRiskThreshold) - HeatstrokeRisk.OnNext(Unit.Default); - } - else - { - Heatstroke = saturate(Heatstroke - ItemManager.GameplaySettings.HeatstrokeRecoverySpeed * delta); - } - } if (_active) { + if(Cockpit != null) + { + if (Cockpit.Item.Temperature > ItemManager.GameplaySettings.HeatstrokeTemperature) + { + var previous = Heatstroke; + Heatstroke = saturate( + Heatstroke + + pow(Cockpit.Item.Temperature - ItemManager.GameplaySettings.HeatstrokeTemperature, ItemManager.GameplaySettings.HeatstrokeExponent) * + ItemManager.GameplaySettings.HeatstrokeMultiplier * delta); + if(previous < ItemManager.GameplaySettings.SevereHeatstrokeRiskThreshold && Heatstroke > ItemManager.GameplaySettings.SevereHeatstrokeRiskThreshold) + HeatstrokeRisk.OnNext(Unit.Default); + if(Heatstroke > 1) + { + HeatstrokeDeath.OnNext(Unit.Default); + Deactivate(); + } + } + else + { + Heatstroke = saturate(Heatstroke - ItemManager.GameplaySettings.HeatstrokeRecoverySpeed * delta); + } + } + foreach (var equippedItem in _orderedEquipment) { equippedItem.Update(delta); diff --git a/Assets/Scripts/ServerShared/Zone.cs b/Assets/Scripts/ServerShared/Zone.cs index 7287dd816..583c8bdb8 100644 --- a/Assets/Scripts/ServerShared/Zone.cs +++ b/Assets/Scripts/ServerShared/Zone.cs @@ -31,6 +31,7 @@ public class Zone private float _time; private Random _random; + public List Agents = new List(); public ZoneData Data { get; } private List BeltUpdates = new List(); @@ -107,6 +108,9 @@ public class Zone BeltUpdates.Add(Task.Run(() => UpdateAsteroidTransformsAsync(belt.Key))); } + foreach(var agent in Agents) + agent.Update(deltaTime); + foreach (var entity in Entities) entity.Update(deltaTime); } diff --git a/Assets/Scripts/UI/ConfirmationDialog.cs b/Assets/Scripts/UI/ConfirmationDialog.cs index 22fa4a280..7fdd13b4d 100644 --- a/Assets/Scripts/UI/ConfirmationDialog.cs +++ b/Assets/Scripts/UI/ConfirmationDialog.cs @@ -5,6 +5,7 @@ using System; using System.Collections; using System.Collections.Generic; +using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UI; @@ -15,6 +16,8 @@ public class ConfirmationDialog : PropertiesPanel public GameObject ButtonGroup; public Button Cancel; public Button Confirm; + public TextMeshProUGUI ConfirmText; + public TextMeshProUGUI CancelText; private Action _onCancel; private Action _onConfirm; @@ -52,15 +55,17 @@ public class ConfirmationDialog : PropertiesPanel gameObject.SetActive(false); } - public void Show(Action onConfirm = null, Action onCancel = null) + public void Show(Action onConfirm = null, Action onCancel = null, string confirmText = "OK", string cancelText = "Cancel") { gameObject.SetActive(true); _onConfirm = onConfirm; Confirm.gameObject.SetActive(onConfirm!=null); + ConfirmText.text = confirmText; _onCancel = onCancel; Cancel.gameObject.SetActive(onCancel!=null); + CancelText.text = cancelText; ButtonGroup.SetActive(onConfirm!=null || onCancel!=null); diff --git a/GameData/AetherDB.msgpack b/GameData/AetherDB.msgpack index 6c1df56db120775aa52f8d79f223df537f6cd4b2..130a6416b0e799d42abf09ce7584c3a02d9b0131 100644 GIT binary patch delta 77 zcmaF+g!%0g<_$YcnH&~u-eqbdGr9Vy=w!`_a+3uXi%zx+;+~v7v2OG6pi*mrpI3H? eZLL4**t_6PS;4&RmpA+L{bqtG+nhd;EfD~TGb6?T delta 86 zcmV-c0IC1&1+dCS sAcT{#Od6BW?^?6PQg=I(CU+8(Zk-0RRF3lklc_TmlRi?3v*nS9V1GC!MF0Q*