From 365b6605cdad8ff173575263331169ebaa7dd41e Mon Sep 17 00:00:00 2001 From: Claire Peta Date: Thu, 3 Oct 2019 13:30:19 +1000 Subject: [PATCH] Update to the block spawning script, added the call line to where the new map section is added to update the spawning positions(commented out for now) also started looking into handling a client disconnecting and removing them from the client list to avoid errors --- .../GameMode/ColorGameMode/RacetrackGameMode.cs | 6 ++---- Assets/Scripts/Managers/GameManager.cs | 2 +- Assets/Scripts/Networking/Server/ClientList.cs | 1 + Assets/Scripts/blockSpawn.cs | 13 +++++++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/GameMode/ColorGameMode/RacetrackGameMode.cs b/Assets/Scripts/GameMode/ColorGameMode/RacetrackGameMode.cs index 91f43d7..a634eba 100644 --- a/Assets/Scripts/GameMode/ColorGameMode/RacetrackGameMode.cs +++ b/Assets/Scripts/GameMode/ColorGameMode/RacetrackGameMode.cs @@ -10,6 +10,7 @@ using System.Linq; public class RacetrackGameMode : GameMode { public MapManager mapManager; + public blockSpawn spawn; public int MaxRound = 999; public string nextScene = "ServerTestScene"; @@ -109,6 +110,7 @@ public class RacetrackGameMode : GameMode //We check for track sections we need to add/remove mapManager.checkTrack(); + //spawn.wakeup(); //Move the camera forward at a steady rate each round /*if (scrollSpeed > 0.0f) @@ -272,22 +274,18 @@ public class RacetrackGameMode : GameMode character.lives -= 1; character.ClientLink.Lives = character.lives; } - } private IEnumerator AnimateBlock(Material mat, float time) { - float timeElasped = 0; while (timeElasped < time) { mat.SetFloat("_Multiplier", (timeElasped / time)); yield return new WaitForEndOfFrame(); - timeElasped += Time.deltaTime; } - mat.SetFloat("_Multiplier", 1); } diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index fd23f60..26cda33 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -176,7 +176,7 @@ public class GameManager : MonoBehaviour } } //spawn collectible logic blocks - spawnBlock.Spawn(); + //spawnBlock.Spawn(); //Reset some player Data diff --git a/Assets/Scripts/Networking/Server/ClientList.cs b/Assets/Scripts/Networking/Server/ClientList.cs index fe1ed1a..aec3080 100644 --- a/Assets/Scripts/Networking/Server/ClientList.cs +++ b/Assets/Scripts/Networking/Server/ClientList.cs @@ -106,6 +106,7 @@ namespace Networking.Server ConnectedClients.ForEach(p => p.conn.Send(LoginProtocols.OtherClientDisconnected, new LoginProtocols.LoginMsg(client.Name, client.Color, client.characterAnimal))); PotentialClients.ForEach(p => p.Send(LoginProtocols.OtherClientDisconnected, new LoginProtocols.LoginMsg(client.Name, client.Color, client.characterAnimal))); Debug.Log("Disconnected: " + client.Name); + //somewhere here we need to remove the disconnected client from the client list and update such things OnClientsChange.Invoke(ConnectedClients); } diff --git a/Assets/Scripts/blockSpawn.cs b/Assets/Scripts/blockSpawn.cs index dda7e10..a5c0db7 100644 --- a/Assets/Scripts/blockSpawn.cs +++ b/Assets/Scripts/blockSpawn.cs @@ -26,6 +26,7 @@ public class blockSpawn : MonoBehaviour } public void wakeup() { + SpawnBlocks.ToList().Clear(); SpawnBlocks = FindObjectsOfType().Where(p => p.isCollectableSpawnable).ToArray(); } @@ -103,20 +104,24 @@ public class blockSpawn : MonoBehaviour public void assignLogicBlock(GameObject block, float value) { - if(value > 0) + if(value > 1) { listtoUse = WeakLogicList; } - else if (value < 0 && value > (-10)) + else if (value <= 1 && value > (-4)) { listtoUse = NormalLogicList; } - else if (value <= (-10)) + else if (value <= (-5)) { listtoUse = StrongLogicList; } + //max behind camera is -6/-7 + //max lives = 3 + // ~ anyone ahead of the average will have a minimum of 4(full lives) or 2(with 1 life left) + // ~ anyone behind the average will have a minimum of -3-4(full lives) or -5/-6 (with one life left) - int number = (int)Random.Range(0, listtoUse.Length-1); + int number = Random.Range(0, listtoUse.Length-1); block.GetComponent().Collectable.element = listtoUse[number].element; block.GetComponent().Collectable.Count = listtoUse[number].Count; }