Browse Source

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
master
Claire Peta 5 years ago
parent
commit
365b6605cd
4 changed files with 13 additions and 9 deletions
  1. +2
    -4
      Assets/Scripts/GameMode/ColorGameMode/RacetrackGameMode.cs
  2. +1
    -1
      Assets/Scripts/Managers/GameManager.cs
  3. +1
    -0
      Assets/Scripts/Networking/Server/ClientList.cs
  4. +9
    -4
      Assets/Scripts/blockSpawn.cs

+ 2
- 4
Assets/Scripts/GameMode/ColorGameMode/RacetrackGameMode.cs View File

@ -10,6 +10,7 @@ using System.Linq;
public class RacetrackGameMode : GameMode public class RacetrackGameMode : GameMode
{ {
public MapManager mapManager; public MapManager mapManager;
public blockSpawn spawn;
public int MaxRound = 999; public int MaxRound = 999;
public string nextScene = "ServerTestScene"; public string nextScene = "ServerTestScene";
@ -109,6 +110,7 @@ public class RacetrackGameMode : GameMode
//We check for track sections we need to add/remove //We check for track sections we need to add/remove
mapManager.checkTrack(); mapManager.checkTrack();
//spawn.wakeup();
//Move the camera forward at a steady rate each round //Move the camera forward at a steady rate each round
/*if (scrollSpeed > 0.0f) /*if (scrollSpeed > 0.0f)
@ -272,22 +274,18 @@ public class RacetrackGameMode : GameMode
character.lives -= 1; character.lives -= 1;
character.ClientLink.Lives = character.lives; character.ClientLink.Lives = character.lives;
} }
} }
private IEnumerator AnimateBlock(Material mat, float time) private IEnumerator AnimateBlock(Material mat, float time)
{ {
float timeElasped = 0; float timeElasped = 0;
while (timeElasped < time) while (timeElasped < time)
{ {
mat.SetFloat("_Multiplier", (timeElasped / time)); mat.SetFloat("_Multiplier", (timeElasped / time));
yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame();
timeElasped += Time.deltaTime; timeElasped += Time.deltaTime;
} }
mat.SetFloat("_Multiplier", 1); mat.SetFloat("_Multiplier", 1);
} }

+ 1
- 1
Assets/Scripts/Managers/GameManager.cs View File

@ -176,7 +176,7 @@ public class GameManager : MonoBehaviour
} }
} }
//spawn collectible logic blocks //spawn collectible logic blocks
spawnBlock.Spawn();
//spawnBlock.Spawn();
//Reset some player Data //Reset some player Data

+ 1
- 0
Assets/Scripts/Networking/Server/ClientList.cs View File

@ -106,6 +106,7 @@ namespace Networking.Server
ConnectedClients.ForEach(p => p.conn.Send(LoginProtocols.OtherClientDisconnected, new LoginProtocols.LoginMsg(client.Name, client.Color, client.characterAnimal))); 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))); PotentialClients.ForEach(p => p.Send(LoginProtocols.OtherClientDisconnected, new LoginProtocols.LoginMsg(client.Name, client.Color, client.characterAnimal)));
Debug.Log("Disconnected: " + client.Name); 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); OnClientsChange.Invoke(ConnectedClients);
} }

+ 9
- 4
Assets/Scripts/blockSpawn.cs View File

@ -26,6 +26,7 @@ public class blockSpawn : MonoBehaviour
} }
public void wakeup() public void wakeup()
{ {
SpawnBlocks.ToList().Clear();
SpawnBlocks = FindObjectsOfType<Block>().Where(p => p.isCollectableSpawnable).ToArray(); SpawnBlocks = FindObjectsOfType<Block>().Where(p => p.isCollectableSpawnable).ToArray();
} }
@ -103,20 +104,24 @@ public class blockSpawn : MonoBehaviour
public void assignLogicBlock(GameObject block, float value) public void assignLogicBlock(GameObject block, float value)
{ {
if(value > 0)
if(value > 1)
{ {
listtoUse = WeakLogicList; listtoUse = WeakLogicList;
} }
else if (value < 0 && value > (-10))
else if (value <= 1 && value > (-4))
{ {
listtoUse = NormalLogicList; listtoUse = NormalLogicList;
} }
else if (value <= (-10))
else if (value <= (-5))
{ {
listtoUse = StrongLogicList; 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<LogicCollectable_Multiplayer>().Collectable.element = listtoUse[number].element; block.GetComponent<LogicCollectable_Multiplayer>().Collectable.element = listtoUse[number].element;
block.GetComponent<LogicCollectable_Multiplayer>().Collectable.Count = listtoUse[number].Count; block.GetComponent<LogicCollectable_Multiplayer>().Collectable.Count = listtoUse[number].Count;
} }

Loading…
Cancel
Save