diff --git a/Assets/Prefabs/Networked/Enemies/EnemyBase.prefab b/Assets/Prefabs/Networked/Enemies/EnemyBase.prefab index a9137a5..b665a91 100644 --- a/Assets/Prefabs/Networked/Enemies/EnemyBase.prefab +++ b/Assets/Prefabs/Networked/Enemies/EnemyBase.prefab @@ -114,7 +114,6 @@ MonoBehaviour: m_EditorClassIdentifier: flipTrans: {fileID: 0} body: {fileID: 0} ---- !u!114 &7159876145595507269 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} diff --git a/Assets/Prefabs/Networked/Enemies/Variants/Level1.meta b/Assets/Prefabs/Networked/Enemies/Variants/Difficulty1.meta similarity index 100% rename from Assets/Prefabs/Networked/Enemies/Variants/Level1.meta rename to Assets/Prefabs/Networked/Enemies/Variants/Difficulty1.meta diff --git a/Assets/Prefabs/Networked/Enemies/Variants/Level1/EnemyV1.prefab b/Assets/Prefabs/Networked/Enemies/Variants/Difficulty1/EnemyV1.prefab similarity index 100% rename from Assets/Prefabs/Networked/Enemies/Variants/Level1/EnemyV1.prefab rename to Assets/Prefabs/Networked/Enemies/Variants/Difficulty1/EnemyV1.prefab diff --git a/Assets/Prefabs/Networked/Enemies/Variants/Level1/EnemyV1.prefab.meta b/Assets/Prefabs/Networked/Enemies/Variants/Difficulty1/EnemyV1.prefab.meta similarity index 100% rename from Assets/Prefabs/Networked/Enemies/Variants/Level1/EnemyV1.prefab.meta rename to Assets/Prefabs/Networked/Enemies/Variants/Difficulty1/EnemyV1.prefab.meta diff --git a/Assets/Prefabs/Networked/Enemies/Variants/EnemyList.asset b/Assets/Prefabs/Networked/Enemies/Variants/EnemyList.asset new file mode 100644 index 0000000..3ca25d0 --- /dev/null +++ b/Assets/Prefabs/Networked/Enemies/Variants/EnemyList.asset @@ -0,0 +1,18 @@ +%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: af7974227ca2b6c4eb332e658d94fc34, type: 3} + m_Name: EnemyList + m_EditorClassIdentifier: + List: + - prefabs: + - {fileID: 4934207185621008411, guid: 854e7815477416848ba19ede927d8601, type: 3} + Difficulty: 1 diff --git a/Assets/Prefabs/Networked/Enemies/Variants/EnemyList.asset.meta b/Assets/Prefabs/Networked/Enemies/Variants/EnemyList.asset.meta new file mode 100644 index 0000000..6ae605f --- /dev/null +++ b/Assets/Prefabs/Networked/Enemies/Variants/EnemyList.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b5be1b6a03ce1d74ebd3f721d1332eca +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Networked/Enemies/Variants/NetworkedEnemies.asset b/Assets/Prefabs/Networked/Enemies/Variants/NetworkedEnemies.asset new file mode 100644 index 0000000..ca0359e --- /dev/null +++ b/Assets/Prefabs/Networked/Enemies/Variants/NetworkedEnemies.asset @@ -0,0 +1,21 @@ +%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: e651dbb3fbac04af2b8f5abf007ddc23, type: 3} + m_Name: NetworkedEnemies + m_EditorClassIdentifier: + IsDefault: 0 + List: + - Override: 0 + Prefab: {fileID: 4934207185621008411, guid: 854e7815477416848ba19ede927d8601, type: 3} + SourcePrefabToOverride: {fileID: 0} + SourceHashToOverride: 0 + OverridingTargetPrefab: {fileID: 0} diff --git a/Assets/Prefabs/Networked/Enemies/Variants/NetworkedEnemies.asset.meta b/Assets/Prefabs/Networked/Enemies/Variants/NetworkedEnemies.asset.meta new file mode 100644 index 0000000..6e53681 --- /dev/null +++ b/Assets/Prefabs/Networked/Enemies/Variants/NetworkedEnemies.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 64355e81cc3d52c4d8e2f01f078efcc4 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Networked/NetworkPrefabsList.asset b/Assets/Prefabs/Networked/NetworkPrefabsList.asset index 53768a2..ae4a4e9 100644 --- a/Assets/Prefabs/Networked/NetworkPrefabsList.asset +++ b/Assets/Prefabs/Networked/NetworkPrefabsList.asset @@ -29,8 +29,3 @@ MonoBehaviour: SourcePrefabToOverride: {fileID: 0} SourceHashToOverride: 0 OverridingTargetPrefab: {fileID: 0} - - Override: 0 - Prefab: {fileID: 7065654593080984807, guid: cfacc720818aabb4e9217dd1ae770886, type: 3} - SourcePrefabToOverride: {fileID: 0} - SourceHashToOverride: 0 - OverridingTargetPrefab: {fileID: 0} diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index d147a6d..bdf47c5 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -3725,14 +3725,10 @@ MonoBehaviour: enemyDifficulties: [] SpawnRadius: 22.6 NumEnemies: 6 - players: [] initialSpawnDelay: 5 SpawnCenter: {fileID: 5796191506433166635} timer: 0 - enemyList: - - prefabs: - - {fileID: 7065654593080984807, guid: cfacc720818aabb4e9217dd1ae770886, type: 3} - Difficulty: 0 + enemyList: {fileID: 11400000, guid: b5be1b6a03ce1d74ebd3f721d1332eca, type: 2} --- !u!1001 &4158834148864819266 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/MultiplayerTestingScenes/Multi-SetupLoad.unity b/Assets/Scenes/MultiplayerTestingScenes/Multi-SetupLoad.unity index a7969e8..4b67841 100644 --- a/Assets/Scenes/MultiplayerTestingScenes/Multi-SetupLoad.unity +++ b/Assets/Scenes/MultiplayerTestingScenes/Multi-SetupLoad.unity @@ -1213,6 +1213,7 @@ MonoBehaviour: Prefabs: NetworkPrefabsLists: - {fileID: 11400000, guid: 3ca514815d13ed84bae5371c002442c4, type: 2} + - {fileID: 11400000, guid: 64355e81cc3d52c4d8e2f01f078efcc4, type: 2} TickRate: 30 ClientConnectionBufferTimeout: 10 ConnectionApproval: 0 diff --git a/Assets/Scripts/Enemy/EnemySpawner.cs b/Assets/Scripts/Enemy/EnemySpawner.cs index 97a8527..3d1e3d1 100644 --- a/Assets/Scripts/Enemy/EnemySpawner.cs +++ b/Assets/Scripts/Enemy/EnemySpawner.cs @@ -20,10 +20,9 @@ public class EnemySpawner : NetworkBehaviour // Inspector [SerializeField] private float difficultyIncreasePerWave = 1f; [SerializeField] public float WaveTime = 20f; - [SerializeField] private List enemyDifficulties; [SerializeField] private float SpawnRadius = 10; [SerializeField] private int NumEnemies = 6; - [SerializeField] public GameObject[] players; + private GameObject[] players; [SerializeField] private float initialSpawnDelay = 5; [Space(10)] [SerializeField] private Transform SpawnCenter; @@ -32,12 +31,22 @@ public class EnemySpawner : NetworkBehaviour private bool nextWaveRequested = false; public float timer = 0f; private GameObject SpawnedEnenmyHolder; - [SerializeField] private List enemyList; + [SerializeField] private EnemyList enemyList; private bool SpawnerStarted = false; public static EnemySpawner instance; + private void OnEnable() + { + GameManager.OnPlayersReady += OnPlayersReady; + } + + private void OnPlayersReady(GameObject[] players) + { + this.players = players; + } + private void Awake() { if (instance == null) @@ -54,11 +63,6 @@ public class EnemySpawner : NetworkBehaviour { SpawnedEnenmyHolder = new GameObject("SpawnedEnenmyHolder"); - for (int i = 0; i < 6; i++) - { - enemyList.Add(new EnemyPrefabInfo() { Difficulty = i+1, prefabs = Resources.LoadAll("Enemies/" + (i+1)) }); - } - timer = WaveTime - initialSpawnDelay; if (IsServer || IsHost) // If server then start spawning @@ -87,7 +91,11 @@ public class EnemySpawner : NetworkBehaviour void SpawnWave(float difficulty) { - //SpawnStrongestFirst(difficulty); + if (enemyList.List.Any(x=>x.Difficulty < 0.1f)) + { + Debug.LogError("Difficulty on prefab too low!", enemyList); + return; + } if (Wave != 0 && Wave % 10 == 0) SpawnStrongestFirst(difficulty); @@ -97,16 +105,15 @@ public class EnemySpawner : NetworkBehaviour void SpawnStrongestFirst(float difficulty) { - var decendingList = enemyList.Where(x => x.Difficulty < difficulty).OrderByDescending(x => x.Difficulty).ToArray(); + var decendingList = enemyList.List.Where(x => x.Difficulty < difficulty).OrderByDescending(x => x.Difficulty).ToArray(); for (int i = 0; i < decendingList.Length; i++) { while (difficulty > decendingList[i].Difficulty) { - GameObject enemy = Instantiate(decendingList[i].prefabs[UnityEngine.Random.Range(0, decendingList[i].prefabs.Length)], GetRandomPointOnCircle(SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform); - difficulty -= decendingList[i].Difficulty; - enemy.GetComponent().Spawn(); + GameObject enemyToSpawn = decendingList[i].prefabs[UnityEngine.Random.Range(0, decendingList[i].prefabs.Length)]; + SpawnEnemy(enemyToSpawn); - enemy.GetComponent().targets = players.Select(x=>x.transform).ToArray(); + difficulty -= decendingList[i].Difficulty; } } } @@ -116,7 +123,7 @@ public class EnemySpawner : NetworkBehaviour difficulty *= 1.1f; while (difficulty > 1f) // Spawn until difficulty is less than 0.5f { - var validEnemies = enemyList.Where(x => x.Difficulty <= difficulty).ToArray(); + var validEnemies = enemyList.List.Where(x => x.Difficulty <= difficulty).ToArray(); int enemyIndex = UnityEngine.Random.Range(0, validEnemies.Length); var enemyToSpawn = validEnemies[enemyIndex]; difficulty -= enemyToSpawn.Difficulty; @@ -124,12 +131,18 @@ public class EnemySpawner : NetworkBehaviour int variant = UnityEngine.Random.Range(0, enemyToSpawn.prefabs.Length); GameObject variantToSpawn = enemyToSpawn.prefabs[variant]; - GameObject enemy = Instantiate(variantToSpawn, GetRandomPointOnCircle(SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform); - - enemy.GetComponent().targets = players.Select(x => x.transform).ToArray(); + SpawnEnemy(variantToSpawn); } } + void SpawnEnemy(GameObject enemyPrefab) + { + GameObject enemy = Instantiate(enemyPrefab, GetRandomPointOnCircle(SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform); + enemy.GetComponent().Spawn(); + + enemy.GetComponent().targets = players.Select(x => x.transform).ToArray(); + } + // Centrum is SpawnCenter public Vector3 GetRandomPointOnCircle(float radius) { diff --git a/Assets/Scripts/Enemy/Project.Scritps.Enemy.asmdef b/Assets/Scripts/Enemy/Project.Scritps.Enemy.asmdef index 7f8916a..c9f79a7 100644 --- a/Assets/Scripts/Enemy/Project.Scritps.Enemy.asmdef +++ b/Assets/Scripts/Enemy/Project.Scritps.Enemy.asmdef @@ -7,7 +7,8 @@ "GUID:055e16077a1232f4780a04598b3bfe00", "GUID:1031dfc67c8f1a645b71d679ac3bf7db", "GUID:0ba5c175a7b2c8345a4e996560a9d0ab", - "GUID:1491147abca9d7d4bb7105af628b223e" + "GUID:1491147abca9d7d4bb7105af628b223e", + "GUID:c0e1b40f519e6e84b8f4af9930403ecb" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs b/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs index 133e011..44b9e13 100644 --- a/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs +++ b/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs @@ -37,30 +37,6 @@ public class NetworkedGameSetup : NetworkBehaviour GameObject[] players; if (isServer) players = SpawnPlayers(playerIds); - else - players = GetPlayers(playerIds); - - //StartCoroutine(LateSetupProcedue(players)); - } - - private IEnumerator LateSetupProcedue(GameObject[] players) - { - yield return new WaitForSecondsRealtime(0.01f); - - InitRope(players); - - InitUpgrader(players); - - InitBlood(players); - - InitSpawner(players); - } - - private GameObject[] GetPlayers(List playerIds) - { - GameObject[] players = NetworkManager.SpawnManager.SpawnedObjects.Where(x => playerIds.Contains(x.Value.NetworkObjectId)).Select(x => x.Value.gameObject).ToArray(); - - return players; } private GameObject[] SpawnPlayers(List playerIds) @@ -76,58 +52,4 @@ public class NetworkedGameSetup : NetworkBehaviour return players; } - - private void InitRope(GameObject[] players) - { - if (players.Length == 1) - { - RopeSimulator.instance.BuildRope(players[0].GetComponent(), players[0].GetComponent()); - } - else // 2 players - { - RopeSimulator.instance.BuildRope(players[0].GetComponent(), players[1].GetComponent()); - } - } - - private void InitUpgrader(GameObject[] players) - { - return; // fuck this upgrade system - - Upgrader upgradeSystem = Upgrader.instance; - - if (players.Length == 1) - { - upgradeSystem.player1 = players[0]; - upgradeSystem.player2 = players[0]; - } - else // 2 players - { - upgradeSystem.player1 = players[0]; - upgradeSystem.player2 = players[1]; - } - } - - private void InitBlood(GameObject[] players) - { - BloodComputeShader bloodScript = BloodComputeShader.Instance; - - if (players.Length == 1) - { - bloodScript.mop1 = players[0].GetComponent(); - bloodScript.mop2 = players[0].GetComponent(); - } - else // 2 players - { - bloodScript.mop1 = players[0].GetComponent(); - bloodScript.mop2 = players[1].GetComponent(); - } - - } - - private void InitSpawner(GameObject[] players) - { - EnemySpawner spawner = EnemySpawner.instance; - - spawner.players = players; - } } diff --git a/Assets/Scripts/Multiplayer/ZDisablerV2.cs b/Assets/Scripts/Multiplayer/ZDisablerV2.cs index a2fc28e..aa73e04 100644 --- a/Assets/Scripts/Multiplayer/ZDisablerV2.cs +++ b/Assets/Scripts/Multiplayer/ZDisablerV2.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using Unity.Netcode; using UnityEngine; +using UnityEngine.AI; public class ZDisablerV2 : NetworkBehaviour { @@ -25,7 +26,7 @@ public class ZDisablerV2 : NetworkBehaviour switch (objectType) { - case MonoBehaviour monoBehaviour: + case Behaviour monoBehaviour: monoBehaviour.enabled = false; break;