Skip to content

Commit

Permalink
Merge pull request #62 from siwei-yuan/main
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
siwei-yuan authored Jun 1, 2023
2 parents 17a301d + 23fb7a3 commit 63688eb
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
29 changes: 29 additions & 0 deletions Assets/Mirror/Core/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,35 @@ public void StartClient()
OnStartClient();
}

public void StartClient(string serverAddress)
{
if (NetworkClient.active)
{
Debug.LogWarning("Client already started.");
return;
}

mode = NetworkManagerMode.ClientOnly;

SetupClient();

// In case this is a headless client...
ConfigureHeadlessFrameRate();

RegisterClientMessages();

if (string.IsNullOrWhiteSpace(serverAddress))
{
Debug.LogError("Must set the serverAddress field in the manager");
return;
}
// Debug.Log($"NetworkManager StartClient address:{networkAddress}");

NetworkClient.Connect(serverAddress);

OnStartClient();
}

/// <summary>Starts the client, connects it to the server via Uri</summary>
public void StartClient(Uri uri)
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Prefabs/Prometheus.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ MonoBehaviour:
syncInterval: 0.1
Speed: 0
CheckpointsReached: 0
TotalCheckpoints: 0
TotalCheckpoints: 5
--- !u!114 &2803430939122561944
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -6633,7 +6633,7 @@ MonoBehaviour:
syncDirection: 0
syncMode: 0
syncInterval: 0.1
NumberOfPlayers: 1
NumberOfPlayers: 2
GameStarted: 0
--- !u!4 &442470983
Transform:
Expand Down Expand Up @@ -8403,7 +8403,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Press any key to continue......
m_text: Press RETURN to continue......
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
Expand Down
1 change: 0 additions & 1 deletion Assets/Scripts/BGMController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public class BGMController : MonoBehaviour

AudioSource Prep = null;
AudioSource Game = null;
bool GameHasStarted = false;

// Start is called before the first frame update
void Start()
Expand Down
9 changes: 5 additions & 4 deletions Assets/Scripts/GameStarter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using System;

public class GameStarter : MonoBehaviour
{
Expand All @@ -12,9 +13,9 @@ public class GameStarter : MonoBehaviour

public enum Connection // your custom enumeration
{
Host,
Client,
Server,
Client
Host
};
public Connection ConnectionType;

Expand All @@ -30,7 +31,7 @@ void Start()
// Update is called once per frame
void Update()
{
if (!Started && Input.GetKeyDown(KeyCode.Space))
if (!Started && Input.GetKeyDown(KeyCode.Return))
{
// UISystem.SetActive(true);

Expand All @@ -40,7 +41,7 @@ void Update()
Manager.StartHost();
} else if (ConnectionType == Connection.Client)
{
Manager.StartClient();
Manager.StartClient("34.94.115.129");
} else
{
Manager.StartServer();
Expand Down
8 changes: 6 additions & 2 deletions Assets/Scripts/UpdateStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class UpdateStats : NetworkBehaviour

public int Speed = 0;
public int CheckpointsReached = 0;
public int TotalCheckpoints = 0;
public int TotalCheckpoints = 5;
private bool IsWinner = false;
private bool UIDestroyed = false;
private float LapTime = 0.0f;
Expand Down Expand Up @@ -133,7 +133,11 @@ void FixedUpdate()
{
Destroy(transform.Find("UI").Find("Speedometer").gameObject);
Destroy(transform.Find("UI").Find("ModeIndicator").gameObject);
Destroy(transform.Find("UI"));
Destroy(transform.Find("UI").Find("Timer").gameObject);
Destroy(transform.Find("UI").Find("DefenseModeTimeLeft").Find("TimeLeftBackground").gameObject);
Destroy(transform.Find("UI").Find("DefenseModeTimeLeft").Find("TimeLeft").gameObject);
Destroy(transform.Find("UI").Find("DefenseModeTimeLeft").gameObject);
Destroy(transform.Find("UI").gameObject);
UIDestroyed = true;
}
}
Expand Down

0 comments on commit 63688eb

Please sign in to comment.