Skip to content

Commit

Permalink
Level loading for clients in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
plaidpants committed Jan 31, 2022
1 parent 1851785 commit 8893574
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
Binary file modified Assets/Game1.unity
Binary file not shown.
Binary file modified Assets/Game2.unity
Binary file not shown.
Binary file modified Assets/Game3.unity
Binary file not shown.
Binary file modified Assets/Game4.unity
Binary file not shown.
24 changes: 12 additions & 12 deletions Assets/Levels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using UnityEngine;
using UnityEngine.SceneManagement;

public class Levels : NetworkBehaviour
public class Levels : NetworkManager
{
public static int level = 0;
public int lastCount = -1;

public int lastCount = 0;
/*
// Use this for initialization
void Start ()
{
Expand Down Expand Up @@ -45,19 +45,19 @@ void CmdNextLevel()
{
RpcNextLevel();
}

*/
// Update is called once per frame
void Update ()
{
if (RockSphere.count != lastCount)
{
lastCount = RockSphere.count;
Debug.Log("Rocks " + lastCount + " " + Random.Range(0.0f, 1.0f).ToString());
if (RockSphere.count == 0)
if (RockSphere.count != lastCount)
{
Debug.Log("Rocks " + lastCount);
RpcNextLevel();
lastCount = RockSphere.count;
if (RockSphere.count == 0)
{
//ServerChangeScene("Game2");
// NextLevel();
//RpcNextLevel();
}
}
}
}
}
22 changes: 22 additions & 0 deletions Assets/NetworkManagerRocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,26 @@ public override void OnStopHost()
if (RockField2 != null)
NetworkServer.Destroy(RockField2);
}

public static int level = 1;
public int lastCount = 0;

void Update()
{
if (RockSphere.count != lastCount)
{
lastCount = RockSphere.count;
if (RockSphere.count == 0)
{
level++;
if (level > 3)
{
level = 1;
}

ServerChangeScene("Game" + level);
}
}
}

}
2 changes: 0 additions & 2 deletions Assets/RockSphere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ void Start()
}

count++;
Debug.Log("Add Rocks " + count + " " + Random.Range(0.0f, 1.0f).ToString());
}

[ServerCallback]
Expand All @@ -100,7 +99,6 @@ void OnTriggerEnter(Collider other)
destroyed = true;
NetworkServer.Destroy(transform.gameObject);
count--;
Debug.Log("Destroy Rocks " + count + " " + Random.Range(0.0f, 1.0f).ToString());

if (rockSpherePrefab)
{
Expand Down

0 comments on commit 8893574

Please sign in to comment.