I'm soo close to online multiplayer. I can almost taste it!

This commit is contained in:
BOTAlex 2024-02-14 16:29:24 +01:00
parent 91b3c89657
commit 5fb3197aba
13 changed files with 235 additions and 25 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: be3350a372dbcf64d8639b5b0bd12cd5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c0011418c9d75434988a06b6df93b283, type: 3}
m_Name: ParrelSyncProjectSettings
m_EditorClassIdentifier:
m_OptionalSymbolicLinkFolders: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 305a7adc29a0ab94e9c01c35d9975a01
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,68 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4905596560188172618
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2120591286217292487}
- component: {fileID: 9026571847668357918}
- component: {fileID: 3790448570997958578}
m_Layer: 0
m_Name: NetworkedGameSetup
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2120591286217292487
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4905596560188172618}
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!114 &9026571847668357918
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4905596560188172618}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 1962602005
AlwaysReplicateAsRoot: 0
SynchronizeTransform: 1
ActiveSceneSynchronization: 0
SceneMigrationSynchronization: 1
SpawnWithObservers: 1
DontDestroyWithOwner: 0
AutoObjectParentSync: 1
--- !u!114 &3790448570997958578
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4905596560188172618}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 42a55d924c00a4749b9c44597675fd36, type: 3}
m_Name:
m_EditorClassIdentifier:
PlayerPrefab: {fileID: 3120938410244321186, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}

View File

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

View File

@ -3478,24 +3478,72 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1536317696
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2120591286217292487, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2120591286217292487, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2120591286217292487, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2120591286217292487, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2120591286217292487, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2120591286217292487, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2120591286217292487, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2120591286217292487, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2120591286217292487, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2120591286217292487, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4905596560188172618, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: m_Name
value: NetworkedGameSetup
objectReference: {fileID: 0}
- target: {fileID: 9026571847668357918, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
propertyPath: GlobalObjectIdHash
value: 1962602005
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 056d6e4ea47c75e4d8ef3371fffe0315, type: 3}
--- !u!1 &1566837117 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 809911508645467208, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
m_PrefabInstance: {fileID: 1683288374126251321}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1566837126
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: 42a55d924c00a4749b9c44597675fd36, type: 3}
m_Name:
m_EditorClassIdentifier:
PlayerPrefab: {fileID: 0}
--- !u!1 &1600052931
GameObject:
m_ObjectHideFlags: 0
@ -3693,13 +3741,25 @@ PrefabInstance:
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 809911508645467208, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
insertIndex: -1
addedObject: {fileID: 1566837126}
addedObject: {fileID: 1683288374126251323}
m_SourcePrefab: {fileID: 100100000, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
--- !u!4 &1683288374126251322 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3032075919872812610, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
m_PrefabInstance: {fileID: 1683288374126251321}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1683288374126251323
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: 3e42fe7862f026640ac0a6b53663804e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &4158834148864819266
PrefabInstance:
m_ObjectHideFlags: 0
@ -3714,7 +3774,7 @@ PrefabInstance:
objectReference: {fileID: 5796191506433166634}
- target: {fileID: 2404937059918327841, guid: 48e0e53445d42474895d37a321c39d1c, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2458716502903188221, guid: 48e0e53445d42474895d37a321c39d1c, type: 3}
propertyPath: rope
@ -3816,6 +3876,10 @@ PrefabInstance:
propertyPath: m_Name
value: UI
objectReference: {fileID: 0}
- target: {fileID: 7301411897347746173, guid: 48e0e53445d42474895d37a321c39d1c, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
@ -4759,6 +4823,7 @@ SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 1683288374126251321}
- {fileID: 1536317696}
- {fileID: 4158834148864819266}
- {fileID: 1600052934}
- {fileID: 480860136}

View File

@ -127,6 +127,8 @@ public class BloodComputeShader : MonoBehaviour
// Update is called once per frame
void Update()
{
if (mop1 == null || mop2 == null) return;
bloodCompute.SetFloat("deltaTime", Time.deltaTime);
bloodCompute.SetInt("numParticles", numParticles);
bloodCompute.SetFloat("size", size);

View File

@ -23,8 +23,6 @@ public class AudioManager : MonoBehaviour
{
Destroy(this);
}
DontDestroyOnLoad(gameObject);
}
private void OnDisable()

View File

@ -33,7 +33,7 @@ public class RumbleManager : MonoBehaviour
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
//DontDestroyOnLoad(gameObject);
for (int i = 0; i < Gamepad.all.Count; i++)
{
playerRumbles[i] = new List<RumbleEffect>(); // Initialize list for each connected controller

View File

@ -10,14 +10,18 @@ public class NetworkedGameSetup : NetworkBehaviour
{
[SerializeField] private GameObject PlayerPrefab;
private void Start()
private void Awake()
{
if (NetworkManager.Singleton == null || NetworkManager.Singleton.SceneManager == null) return;
DontDestroyOnLoad(this);
NetworkManager.Singleton.SceneManager.OnLoadEventCompleted += SceneLoaded;
}
private void SceneLoaded(string sceneName, LoadSceneMode loadSceneMode, List<ulong> clientsCompleted, List<ulong> clientsTimedOut)
{
if (!sceneName.ToLower().Contains("game")) return;
NetworkManager.Singleton.SceneManager.OnLoadEventCompleted -= SceneLoaded; // Only run once
StartSetupProcedure(clientsCompleted);
}
@ -29,7 +33,12 @@ public class NetworkedGameSetup : NetworkBehaviour
players = SpawnPlayers(playerIds);
else
players = GetPlayers(playerIds);
InitRope(players);
InitUpgrader(players);
InitBlood(players);
}
private GameObject[] GetPlayers(List<ulong> playerIds)
@ -67,4 +76,19 @@ public class NetworkedGameSetup : NetworkBehaviour
ropeSim.BuildRope(players[0].GetComponent<RopeJoint>(), players[1].GetComponent<RopeJoint>());
}
private void InitUpgrader(GameObject[] players)
{
Upgrader upgradeSystem = Upgrader.instance;
upgradeSystem.player1 = players[0];
upgradeSystem.player2 = players[1];
}
private void InitBlood(GameObject[] players)
{
BloodComputeShader bloodScript = BloodComputeShader.Instance;
bloodScript.mop1 = players[0].GetComponent<Mop>();
bloodScript.mop2 = players[1].GetComponent<Mop>();
}
}

View File

@ -9,7 +9,9 @@
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:dfa0fc7c5444edd619a15e6f8c8f242a",
"GUID:42d1898a72cfe6848ae89835fb20acd2"
"GUID:42d1898a72cfe6848ae89835fb20acd2",
"GUID:ff1c299121c93f34ca827a253fc30a61",
"GUID:1eb4e3e6c04cdc848bab71651b1e2ecd"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@ -8,7 +8,6 @@ using UnityEngine.InputSystem.DualShock;
[RequireComponent(typeof(PlayerInput))]
public class PlayerMovement : MonoBehaviour
{
public PlayerAnimationHandler animationHandler;
public float moveSpeed = 5f;
private Rigidbody2D rb;
@ -55,10 +54,10 @@ public class PlayerMovement : MonoBehaviour
private void Update()
{
if (playerInput.movement != Vector2.zero)
animationHandler.Run(true);
else
animationHandler.Run(false);
//if (playerInput.movement != Vector2.zero)
// animationHandler.Run(true);
//else
// animationHandler.Run(false);
}
private void FixedUpdate()

View File

@ -63,6 +63,20 @@ public class Upgrader : MonoBehaviour
public Image BloodMeter;
public TMPro.TextMeshProUGUI description;
public static Upgrader instance;
private void Awake()
{
if (instance == null)
{
instance = this;
}
else
{
Destroy(this);
}
}
// Start is called before the first frame update
void Start()
{