From 9a2538c772b0956a9495ec390ec5207063842553 Mon Sep 17 00:00:00 2001 From: BOT Alex <44818698+MagicBOTAlex@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:18:17 +0100 Subject: [PATCH] Players now registers themselvs to gamemanager --- .../Prefabs/Networked/NetworkedPlayer.prefab | 61 ++++++++- Assets/Scenes/GameScene.unity | 118 ++++++++---------- Assets/Scripts/Managers/GameManager.cs | 110 +++++++--------- .../Multiplayer/ClientNetworkTransform.cs | 21 ++++ .../ClientNetworkTransform.cs.meta | 2 + .../Scripts/Multiplayer/NetworkedGameSetup.cs | 11 +- .../Multiplayer/NetworkedPlayerRegister.cs | 12 ++ .../NetworkedPlayerRegister.cs.meta | 2 + .../Project.Scripts.Multiplayer.asmdef | 3 +- Assets/Scripts/UI/SurvivalTimer.cs | 1 - Assets/Scripts/Upgrade/Upgrader.cs | 1 - ProjectSettings/EditorBuildSettings.asset | 1 + 12 files changed, 198 insertions(+), 145 deletions(-) create mode 100644 Assets/Scripts/Multiplayer/ClientNetworkTransform.cs create mode 100644 Assets/Scripts/Multiplayer/ClientNetworkTransform.cs.meta create mode 100644 Assets/Scripts/Multiplayer/NetworkedPlayerRegister.cs create mode 100644 Assets/Scripts/Multiplayer/NetworkedPlayerRegister.cs.meta diff --git a/Assets/Prefabs/Networked/NetworkedPlayer.prefab b/Assets/Prefabs/Networked/NetworkedPlayer.prefab index 170776e..fa27876 100644 --- a/Assets/Prefabs/Networked/NetworkedPlayer.prefab +++ b/Assets/Prefabs/Networked/NetworkedPlayer.prefab @@ -52,6 +52,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -89,7 +91,7 @@ SpriteRenderer: m_SpriteSortPoint: 0 --- !u!95 &8069942137008974672 Animator: - serializedVersion: 5 + serializedVersion: 7 m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} @@ -103,6 +105,7 @@ Animator: m_ApplyRootMotion: 0 m_LinearVelocityBlending: 0 m_StabilizeFeet: 0 + m_AnimatePhysics: 0 m_WarningMessage: m_HasTransformHierarchy: 1 m_AllowConstantClipSamplingOptimization: 1 @@ -116,6 +119,7 @@ CircleCollider2D: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1936012740462134995} m_Enabled: 1 + serializedVersion: 3 m_Density: 1 m_Material: {fileID: 0} m_IncludeLayers: @@ -139,9 +143,9 @@ CircleCollider2D: m_Bits: 4294967295 m_IsTrigger: 0 m_UsedByEffector: 0 - m_UsedByComposite: 0 + m_CompositeOperation: 0 + m_CompositeOrder: 0 m_Offset: {x: 0, y: 0} - serializedVersion: 2 m_Radius: 0.5 --- !u!114 &5062989152879916107 MonoBehaviour: @@ -318,6 +322,8 @@ GameObject: - component: {fileID: 5998872828059799024} - component: {fileID: 8582716114041666362} - component: {fileID: 4721273529951287494} + - component: {fileID: 93986863963319370} + - component: {fileID: -5630779774840087441} m_Layer: 7 m_Name: NetworkedPlayer m_TagString: Player @@ -355,7 +361,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3dbdb849a2f5df14d9e109a7776c5ac0, type: 3} m_Name: m_EditorClassIdentifier: - animationHandler: {fileID: 0} moveSpeed: 70 whipSmashSpeed: 2 whipSmashDamageMult: 2 @@ -468,7 +473,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} m_Name: m_EditorClassIdentifier: - GlobalObjectIdHash: 4009941625 + GlobalObjectIdHash: 2899378164 + InScenePlacedSourceGlobalObjectIdHash: 0 AlwaysReplicateAsRoot: 0 SynchronizeTransform: 1 ActiveSceneSynchronization: 0 @@ -527,6 +533,8 @@ TrailRenderer: m_ReflectionProbeUsage: 0 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -631,6 +639,49 @@ TrailRenderer: m_Autodestruct: 0 m_Emitting: 1 m_ApplyActiveColorSpace: 1 +--- !u!114 &93986863963319370 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1f57343bf29d26c4995925ddca512e41, type: 3} + m_Name: + m_EditorClassIdentifier: + UseUnreliableDeltas: 0 + SyncPositionX: 1 + SyncPositionY: 1 + SyncPositionZ: 0 + SyncRotAngleX: 0 + SyncRotAngleY: 0 + SyncRotAngleZ: 0 + SyncScaleX: 0 + SyncScaleY: 0 + SyncScaleZ: 0 + PositionThreshold: 0.001 + RotAngleThreshold: 0.01 + ScaleThreshold: 0.01 + UseQuaternionSynchronization: 0 + UseQuaternionCompression: 0 + UseHalfFloatPrecision: 0 + InLocalSpace: 0 + Interpolate: 1 + SlerpPosition: 0 +--- !u!114 &-5630779774840087441 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b84328426b0c0d34680fca7de411409b, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &6225877037457186740 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index a21b249..bf9e5bc 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -13,7 +13,7 @@ OcclusionCullingSettings: --- !u!104 &2 RenderSettings: m_ObjectHideFlags: 0 - serializedVersion: 9 + serializedVersion: 10 m_Fog: 0 m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_FogMode: 3 @@ -44,7 +44,6 @@ RenderSettings: LightmapSettings: m_ObjectHideFlags: 0 serializedVersion: 12 - m_GIWorkflowMode: 1 m_GISettings: serializedVersion: 2 m_BounceScale: 1 @@ -67,9 +66,6 @@ LightmapSettings: m_LightmapParameters: {fileID: 0} m_LightmapsBakeMode: 1 m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 m_ReflectionCompression: 2 m_MixedBakeMode: 2 m_BakeBackend: 1 @@ -223,15 +219,17 @@ MonoBehaviour: m_lineSpacingMax: 0 m_paragraphSpacing: 0 m_charWidthMaxAdj: 0 - m_enableWordWrapping: 1 + m_TextWrappingMode: 1 m_wordWrappingRatios: 0.4 m_overflowMode: 0 m_linkedTextComponent: {fileID: 0} parentLinkedComponent: {fileID: 0} m_enableKerning: 1 + m_ActiveFontFeatures: 6e72656b m_enableExtraPadding: 0 checkPaddingRequired: 0 m_isRichText: 1 + m_EmojiFallbackSupport: 1 m_parseCtrlCharacters: 1 m_isOrthographic: 1 m_isCullingEnabled: 0 @@ -402,6 +400,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -536,6 +536,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -582,52 +584,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ae39a1b1f810ba7a5bcfe4290cc2bbd6, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1 &652688743 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 652688745} - - component: {fileID: 652688744} - m_Layer: 0 - m_Name: gamemanage - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &652688744 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 652688743} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cfcb795658e5b9d8bbbf6d6e238c21a0, type: 3} - m_Name: - m_EditorClassIdentifier: - ReviveParticleSystem: {fileID: 160973951102418629, guid: cce5bb4f212e61847bff6ada16d93b59, type: 3} - ReviveText: {fileID: 730370596} ---- !u!4 &652688745 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 652688743} - serializedVersion: 2 - 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_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &659231496 stripped Transform: m_CorrespondingSourceObject: {fileID: 3862814901187971034, guid: 5846f4d0fc6a1a44ba388893e7ff9373, type: 3} @@ -682,6 +638,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -717,17 +675,6 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!114 &730370596 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 4591853661395341080, guid: 48e0e53445d42474895d37a321c39d1c, type: 3} - m_PrefabInstance: {fileID: 4158834148864819266} - 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 &941230147 GameObject: m_ObjectHideFlags: 0 @@ -777,6 +724,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -861,6 +810,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -945,6 +896,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -1029,6 +982,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -1105,6 +1060,7 @@ BoxCollider2D: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1282889729} m_Enabled: 1 + serializedVersion: 3 m_Density: 1 m_Material: {fileID: 0} m_IncludeLayers: @@ -1128,7 +1084,8 @@ BoxCollider2D: m_Bits: 4294967295 m_IsTrigger: 0 m_UsedByEffector: 0 - m_UsedByComposite: 0 + m_CompositeOperation: 0 + m_CompositeOrder: 0 m_Offset: {x: 0, y: 0} m_SpriteTilingProperty: border: {x: 0, y: 0, z: 0, w: 0} @@ -1139,7 +1096,6 @@ BoxCollider2D: drawMode: 0 adaptiveTiling: 0 m_AutoTiling: 0 - serializedVersion: 2 m_Size: {x: 3.37, y: 3.54} m_EdgeRadius: 0 --- !u!212 &1282889732 @@ -1159,6 +1115,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -1243,6 +1201,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -1327,6 +1287,8 @@ SpriteRenderer: m_ReflectionProbeUsage: 1 m_RayTracingMode: 0 m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -3671,6 +3633,10 @@ PrefabInstance: propertyPath: GlobalObjectIdHash value: 1441761078 objectReference: {fileID: 0} + - target: {fileID: 3147574454562838623, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3} + propertyPath: InScenePlacedSourceGlobalObjectIdHash + value: 2962533260 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -3678,6 +3644,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 809911508645467208, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3} insertIndex: -1 addedObject: {fileID: 1683288374126251323} + - targetCorrespondingSourceObject: {fileID: 809911508645467208, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3} + insertIndex: -1 + addedObject: {fileID: 1683288374126251330} m_SourcePrefab: {fileID: 100100000, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3} --- !u!114 &1683288374126251323 MonoBehaviour: @@ -3691,6 +3660,20 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3e42fe7862f026640ac0a6b53663804e, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &1683288374126251330 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1566837117} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cfcb795658e5b9d8bbbf6d6e238c21a0, type: 3} + m_Name: + m_EditorClassIdentifier: + ReviveParticleSystem: {fileID: 0} + ReviveText: {fileID: 0} --- !u!1001 &4158834148864819266 PrefabInstance: m_ObjectHideFlags: 0 @@ -3902,11 +3885,11 @@ PrefabInstance: value: 0 objectReference: {fileID: 0} - target: {fileID: 3603265075407754381, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} - propertyPath: players.Array.data[0] + propertyPath: 'players.Array.data[0]' value: objectReference: {fileID: 0} - target: {fileID: 3603265075407754381, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} - propertyPath: players.Array.data[1] + propertyPath: 'players.Array.data[1]' value: objectReference: {fileID: 0} - target: {fileID: 5959206239141280122, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} @@ -4764,4 +4747,3 @@ SceneRoots: - {fileID: 1872712131} - {fileID: 1481267923} - {fileID: 65889293} - - {fileID: 652688745} diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index 32df5d6..4d2b645 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -8,16 +8,9 @@ using UnityEngine.SceneManagement; public class GameManager : MonoBehaviour { public static GameManager Instance { get; private set; } + public List Players = new List(); - public Action OnPlayerDied; - - private string penisSuriveTime = ""; - - public int Revives { get; private set; } - - public GameObject ReviveParticleSystem; - - public TMPro.TextMeshProUGUI ReviveText; + public static Action OnPlayersReady; void Awake() { @@ -27,71 +20,60 @@ public class GameManager : MonoBehaviour } Instance = this; - Revives = 1; - ReviveText.text = Revives + "x"; } void Start() { + StartCoroutine(WaitForPlayers()); } - public void playerDied(GameObject who) + private IEnumerator WaitForPlayers() { - Debug.Log($"{who.name} died"); - if (Revives == 0) - { - AudioManager.Instance.StopAllAudio(); - AudioManager.PlaySound("Game_Over_Jingle", Vector3.zero); - SceneManager.LoadScene(3); - } - else - { - Revives--; - ReviveText.text = Revives + "x"; - Collider2D[] d = Physics2D.OverlapCircleAll(who.transform.position, 3f); - - Debug.Log(d); - - foreach (Collider2D c in d) - { - if (c.gameObject.CompareTag("Enemy")) - { - c.gameObject.GetComponent().TakeDamage(69420); - } - } - - var g = who.GetComponent(); - // heal - g.setMaxHealth(g.getMaxHealth(), true); - g.resetKillFlag(); - - // REVIVE SOUND HERE - AudioManager.PlaySound("Revive_SFX", who.transform.position); - RumbleManager.StartRumble(0, 0.3f, 0.1f, 3f); - RumbleManager.StartRumble(1, 0.3f, 0.1f, 3f); - - GameObject go = Instantiate(ReviveParticleSystem, who.transform.position, Quaternion.identity); - ParticleSystem ps = go.GetComponent(); - ps.Play(); - - go.AddComponent().Init(5f); - } + yield return new WaitUntil(()=>Players.Count == 2); + OnPlayersReady?.Invoke(Players.ToArray()); } - public void AddRevive() - { - Revives++; - ReviveText.text = Revives + "x"; - } + //public void playerDied(GameObject who) + //{ + // Debug.Log($"{who.name} died"); + // if (Revives == 0) + // { + // AudioManager.Instance.StopAllAudio(); + // AudioManager.PlaySound("Game_Over_Jingle", Vector3.zero); + // SceneManager.LoadScene(3); + // } + // else + // { + // Revives--; + // ReviveText.text = Revives + "x"; + // Collider2D[] d = Physics2D.OverlapCircleAll(who.transform.position, 3f); - public void setTime(string t) - { - penisSuriveTime = t; - } + // Debug.Log(d); - // Update is called once per frame - void Update() - { + // foreach (Collider2D c in d) + // { + // if (c.gameObject.CompareTag("Enemy")) + // { + // c.gameObject.GetComponent().TakeDamage(69420); + // } + // } + + // var g = who.GetComponent(); + // // heal + // g.setMaxHealth(g.getMaxHealth(), true); + // g.resetKillFlag(); + + // // REVIVE SOUND HERE + // AudioManager.PlaySound("Revive_SFX", who.transform.position); + // RumbleManager.StartRumble(0, 0.3f, 0.1f, 3f); + // RumbleManager.StartRumble(1, 0.3f, 0.1f, 3f); + + // GameObject go = Instantiate(ReviveParticleSystem, who.transform.position, Quaternion.identity); + // ParticleSystem ps = go.GetComponent(); + // ps.Play(); + + // go.AddComponent().Init(5f); + // } + //} - } } diff --git a/Assets/Scripts/Multiplayer/ClientNetworkTransform.cs b/Assets/Scripts/Multiplayer/ClientNetworkTransform.cs new file mode 100644 index 0000000..eb8bfcd --- /dev/null +++ b/Assets/Scripts/Multiplayer/ClientNetworkTransform.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.Netcode.Components; +using UnityEngine; + +/// +/// Used for syncing a transform with client side changes. This includes host. Pure server as owner isn't supported by this. Please use NetworkTransform +/// for transforms that'll always be owned by the server. +/// +[DisallowMultipleComponent] +public class ClientNetworkTransform : NetworkTransform +{ + /// + /// Used to determine who can write to this transform. Owner client only. + /// This imposes state to the server. This is putting trust on your clients. Make sure no security-sensitive features use this transform. + /// + protected override bool OnIsServerAuthoritative() + { + return false; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Multiplayer/ClientNetworkTransform.cs.meta b/Assets/Scripts/Multiplayer/ClientNetworkTransform.cs.meta new file mode 100644 index 0000000..911945b --- /dev/null +++ b/Assets/Scripts/Multiplayer/ClientNetworkTransform.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1f57343bf29d26c4995925ddca512e41 \ No newline at end of file diff --git a/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs b/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs index 2fb0a2b..06aeef9 100644 --- a/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs +++ b/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs @@ -35,12 +35,13 @@ public class NetworkedGameSetup : NetworkBehaviour bool isServer = SteamManager.IsServer || LocalManager.IsServer; GameObject[] players; - if (isServer) - players = SpawnPlayers(playerIds); - else - players = GetPlayers(playerIds); + players = SpawnPlayers(playerIds); + //if (isServer) + // players = SpawnPlayers(playerIds); + //else + // players = GetPlayers(playerIds); - StartCoroutine(LateSetupProcedue(players)); + //StartCoroutine(LateSetupProcedue(players)); } private IEnumerator LateSetupProcedue(GameObject[] players) diff --git a/Assets/Scripts/Multiplayer/NetworkedPlayerRegister.cs b/Assets/Scripts/Multiplayer/NetworkedPlayerRegister.cs new file mode 100644 index 0000000..7405b34 --- /dev/null +++ b/Assets/Scripts/Multiplayer/NetworkedPlayerRegister.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.Netcode; +using UnityEngine; + +public class NetworkedPlayerRegister : NetworkBehaviour +{ + public override void OnNetworkSpawn() + { + GameManager.Instance.Players.Add(this.gameObject); + } +} diff --git a/Assets/Scripts/Multiplayer/NetworkedPlayerRegister.cs.meta b/Assets/Scripts/Multiplayer/NetworkedPlayerRegister.cs.meta new file mode 100644 index 0000000..d2546c9 --- /dev/null +++ b/Assets/Scripts/Multiplayer/NetworkedPlayerRegister.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: b84328426b0c0d34680fca7de411409b \ No newline at end of file diff --git a/Assets/Scripts/Multiplayer/Project.Scripts.Multiplayer.asmdef b/Assets/Scripts/Multiplayer/Project.Scripts.Multiplayer.asmdef index 79cc588..931573e 100644 --- a/Assets/Scripts/Multiplayer/Project.Scripts.Multiplayer.asmdef +++ b/Assets/Scripts/Multiplayer/Project.Scripts.Multiplayer.asmdef @@ -12,7 +12,8 @@ "GUID:42d1898a72cfe6848ae89835fb20acd2", "GUID:ff1c299121c93f34ca827a253fc30a61", "GUID:1eb4e3e6c04cdc848bab71651b1e2ecd", - "GUID:62165c64e8180c441b8cfaa6b82208af" + "GUID:62165c64e8180c441b8cfaa6b82208af", + "GUID:c0e1b40f519e6e84b8f4af9930403ecb" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/Scripts/UI/SurvivalTimer.cs b/Assets/Scripts/UI/SurvivalTimer.cs index cb80453..c7efcd3 100644 --- a/Assets/Scripts/UI/SurvivalTimer.cs +++ b/Assets/Scripts/UI/SurvivalTimer.cs @@ -22,6 +22,5 @@ public class SurvivalTimer : MonoBehaviour int minutes = Mathf.FloorToInt(elapsedTime / 60); int seconds = Mathf.FloorToInt(elapsedTime % 60); timerText.text = string.Format("{00:00}:{01:00}", minutes, seconds); - GameManager.Instance.setTime(timerText.text); } } diff --git a/Assets/Scripts/Upgrade/Upgrader.cs b/Assets/Scripts/Upgrade/Upgrader.cs index 8f4d759..df90ba2 100644 --- a/Assets/Scripts/Upgrade/Upgrader.cs +++ b/Assets/Scripts/Upgrade/Upgrader.cs @@ -360,7 +360,6 @@ public class Upgrader : MonoBehaviour public void ReviveUpgrade() { description.text = upgrades.reviveUpgrade.name; - GameManager.Instance.AddRevive(); } IEnumerator updateBloodMeter() diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 0b05022..b3dc562 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -19,3 +19,4 @@ EditorBuildSettings: guid: 485a4a01988ea88d08f76e749dcbd6c0 m_configObjects: com.unity.input.settings: {fileID: 11400000, guid: de04e34f85a966e4da851d9b3d804fa1, type: 2} + m_UseUCBPForAssetBundles: 0