From d7f847d462f83046f96fe5f68c6b04232b14f0e9 Mon Sep 17 00:00:00 2001 From: "s3607057 (Angus Niven)" Date: Wed, 14 Aug 2019 17:47:31 +1000 Subject: [PATCH] Adjusted the spawning script & moved spawn points in the racetrack level to get the desired spawning arrangements - the middle point will be used only with an odd number of players, and the spawn points to the side will be used first. Also fixed a typo in RaceTrack.asset. --- Assets/Data/GameModes/RaceTrack.asset | 4 ++-- Assets/Scenes/RaceTrack 4-player alpha.unity | 4 ++-- Assets/Scripts/Managers/GameManager.cs | 18 ++++++++++++++++-- ProjectSettings/EditorBuildSettings.asset | 4 ++-- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Assets/Data/GameModes/RaceTrack.asset b/Assets/Data/GameModes/RaceTrack.asset index dabc283..388c4e0 100644 --- a/Assets/Data/GameModes/RaceTrack.asset +++ b/Assets/Data/GameModes/RaceTrack.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0eedf461cce898250d2873a3ff2a1f4ee0b60948e25aa522f883be11466a7bff -size 610 +oid sha256:7f5cdbec085a5c46b44e8e6ce1963d8899bbee24609c8da0aef8d81d1154db91 +size 609 diff --git a/Assets/Scenes/RaceTrack 4-player alpha.unity b/Assets/Scenes/RaceTrack 4-player alpha.unity index 56e60a6..706fcc4 100644 --- a/Assets/Scenes/RaceTrack 4-player alpha.unity +++ b/Assets/Scenes/RaceTrack 4-player alpha.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:538b6d0a9f674651ddf84328d0bf3e5dbef70f61102316f24cabf9ecba1b34c5 -size 2720169 +oid sha256:d2fcdafd3ea73e1e59c963afedb10dafee204cac96e5a3914fedd692e3d74a3b +size 2720958 diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index 1c19e0c..28a4847 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -151,11 +151,25 @@ public class GameManager : MonoBehaviour playerData = new Dictionary(); Block[] SpawnBlocks = FindObjectsOfType().Where(p => p.isSpawnable).ToArray(); - int spawnIndex = 0; + int blockIndex = 0; + foreach (Block block in SpawnBlocks) + { + Debug.Log("Block #" + blockIndex++ + " (" + block.transform.position.x + ", " + block.transform.position.y + ", " + block.transform.position.z + ")"); + } + + //int spawnIndex = 0; + //If we have an odd number of players, then we start at spawn point 0 (in the middle) + //If we have an even number, then we skip it + int spawnIndex = ((ClientList.Count() + 1) % 2); + + //int spawnIndex = 0; + foreach (ClientData client in ClientList) { + Debug.Log("spawnIndex = " + spawnIndex); Character newChar = Instantiate(characterPrefab); - Block startingBlock = SpawnBlocks[(spawnIndex++ % ClientList.ConnectedClients.Count)]; + //Block startingBlock = SpawnBlocks[(spawnIndex++ % ClientList.ConnectedClients.Count)]; + Block startingBlock = SpawnBlocks[spawnIndex++]; newChar.Initialise(startingBlock, client.Inventory, client.characterAnimal); newChar.transform.forward = startingBlock.SpawnDirection.ToVector(); playerData.Add(client.ID, new PlayerData(newChar,client)); diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 0f4a5ec..ccd998d 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d9be158173aa5555933e44bfa66f3ea19bb0cb9804d6a2aa9a10eb8742e1d91f -size 1888 +oid sha256:ca5f18261fab72b72752ecf93ad8fd347fea19843b3184e007e8cba55e6dff7b +size 2010