Browse Source

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.
Josh_Dev_branch
s3607057 (Angus Niven) 5 years ago
parent
commit
d7f847d462
4 changed files with 22 additions and 8 deletions
  1. +2
    -2
      Assets/Data/GameModes/RaceTrack.asset
  2. +2
    -2
      Assets/Scenes/RaceTrack 4-player alpha.unity
  3. +16
    -2
      Assets/Scripts/Managers/GameManager.cs
  4. +2
    -2
      ProjectSettings/EditorBuildSettings.asset

+ 2
- 2
Assets/Data/GameModes/RaceTrack.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0eedf461cce898250d2873a3ff2a1f4ee0b60948e25aa522f883be11466a7bff
size 610
oid sha256:7f5cdbec085a5c46b44e8e6ce1963d8899bbee24609c8da0aef8d81d1154db91
size 609

+ 2
- 2
Assets/Scenes/RaceTrack 4-player alpha.unity View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:538b6d0a9f674651ddf84328d0bf3e5dbef70f61102316f24cabf9ecba1b34c5
size 2720169
oid sha256:d2fcdafd3ea73e1e59c963afedb10dafee204cac96e5a3914fedd692e3d74a3b
size 2720958

+ 16
- 2
Assets/Scripts/Managers/GameManager.cs View File

@ -151,11 +151,25 @@ public class GameManager : MonoBehaviour
playerData = new Dictionary<int, PlayerData>();
Block[] SpawnBlocks = FindObjectsOfType<Block>().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));

+ 2
- 2
ProjectSettings/EditorBuildSettings.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d9be158173aa5555933e44bfa66f3ea19bb0cb9804d6a2aa9a10eb8742e1d91f
size 1888
oid sha256:ca5f18261fab72b72752ecf93ad8fd347fea19843b3184e007e8cba55e6dff7b
size 2010

Loading…
Cancel
Save