Added User Manual and fixes
Added help button on the title screen with animation. Added User Manual to appear after clicking the button, and vice versa. Added tons of catches to handle unwanted errors.
This commit is contained in:
@@ -21,8 +21,15 @@ namespace Game
|
||||
|
||||
public PlayerJoinCard CreateCard() // Creates a player join card
|
||||
{
|
||||
GameObject card = Instantiate(playerJoinCardPrefab, transform);
|
||||
return card.GetComponent<PlayerJoinCard>();
|
||||
try
|
||||
{
|
||||
GameObject card = Instantiate(playerJoinCardPrefab, transform);
|
||||
return card.GetComponent<PlayerJoinCard>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,10 @@ public class GameManager : MonoBehaviour
|
||||
/// </summary>
|
||||
private void Start()
|
||||
{
|
||||
MusicManager.Instance.StartPlaylist();
|
||||
if (MusicManager.Instance != null)
|
||||
{
|
||||
MusicManager.Instance.StartPlaylist();
|
||||
}
|
||||
StartGame();
|
||||
}
|
||||
|
||||
@@ -124,8 +127,11 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
if (gameMode == GameMode.keepAway)
|
||||
{
|
||||
gameTimer.startTime = time;
|
||||
gameTimer.StartTimer();
|
||||
if (gameTimer != null)
|
||||
{
|
||||
gameTimer.startTime = time;
|
||||
gameTimer.StartTimer();
|
||||
}
|
||||
foreach (GameObject player in players)
|
||||
{
|
||||
player.transform.position = spawnPosition + (offset * players.IndexOf(player) * Vector2.right);
|
||||
@@ -203,11 +209,17 @@ public class GameManager : MonoBehaviour
|
||||
/// </summary>
|
||||
public void GameOver()
|
||||
{
|
||||
if (LeaderboardCanvas == null){}
|
||||
gameOver = true;
|
||||
EndGameEvent?.Invoke();
|
||||
LeaderboardCanvas.gameObject.SetActive(false);
|
||||
TimerCanvas.gameObject.SetActive(false);
|
||||
|
||||
if (LeaderboardCanvas != null)
|
||||
{
|
||||
LeaderboardCanvas.gameObject.SetActive(false);
|
||||
}
|
||||
if (TimerCanvas != null)
|
||||
{
|
||||
TimerCanvas.gameObject.SetActive(false);
|
||||
}
|
||||
if (gameMode == GameMode.freeForAll)
|
||||
{
|
||||
GameObject winner = AlivePlayers()[0];
|
||||
@@ -231,13 +243,24 @@ public class GameManager : MonoBehaviour
|
||||
if (winner != null)
|
||||
{
|
||||
print(winner.name + " is the winner with " + maxHoldTime + " seconds!");
|
||||
FindFirstObjectByType<PlayerCameraMovement>().WinScene(winner);
|
||||
var cameraMovement = FindFirstObjectByType<PlayerCameraMovement>();
|
||||
if (cameraMovement != null)
|
||||
{
|
||||
cameraMovement.WinScene(winner);
|
||||
}
|
||||
WinScreen.Instance.ShowWinScreen(players.IndexOf(winner) + 1);
|
||||
FindFirstObjectByType<LifeDisplayManager>().HideLifeDisplay();
|
||||
var lifeDisplayManager = FindFirstObjectByType<LifeDisplayManager>();
|
||||
if (lifeDisplayManager != null)
|
||||
{
|
||||
lifeDisplayManager.HideLifeDisplay();
|
||||
}
|
||||
StartCoroutine(MoveHatToWinner(winner));
|
||||
hatObject.SetActive(true);
|
||||
hatObject.GetComponent<Collider2D>().enabled = true;
|
||||
hatObject.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
|
||||
if (hatObject != null)
|
||||
{
|
||||
hatObject.SetActive(true);
|
||||
hatObject.GetComponent<Collider2D>().enabled = true;
|
||||
hatObject.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gameMode == GameMode.obstacleCourse)
|
||||
|
||||
18
Assets/Scripts/Game/UserManualPopup.cs
Normal file
18
Assets/Scripts/Game/UserManualPopup.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class UserManualPopup : MonoBehaviour
|
||||
{
|
||||
public GameObject popupPanel;
|
||||
|
||||
public void ShowPopup()
|
||||
{
|
||||
popupPanel.SetActive(true);
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void HidePopup()
|
||||
{
|
||||
popupPanel.SetActive(false);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Game/UserManualPopup.cs.meta
Normal file
2
Assets/Scripts/Game/UserManualPopup.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f3390a791c72be41ab00266e23fe518
|
||||
@@ -32,11 +32,23 @@ public class PlayerManager : MonoBehaviour
|
||||
Destroy(playerInput.gameObject);
|
||||
return;
|
||||
}
|
||||
Debug.Log("Player joined");
|
||||
print("Player joined");
|
||||
DontDestroyOnLoad(playerInput.gameObject);
|
||||
if (PlayerCardCreator.Instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PlayerJoinCard card = PlayerCardCreator.Instance.CreateCard();
|
||||
if (card == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
card.playerNumber = GameManager.players.Count + 1;
|
||||
cards.Add(card);
|
||||
if (GameManager.players == null)
|
||||
{
|
||||
GameManager.players = new List<GameObject>();
|
||||
}
|
||||
GameManager.players.Add(playerInput.gameObject);
|
||||
Colorize(GameManager.players.Count - 1);
|
||||
}
|
||||
@@ -46,7 +58,7 @@ public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
Destroy(playerInput.gameObject);
|
||||
GameManager.players.Remove(playerInput.gameObject);
|
||||
Debug.Log("Player left");
|
||||
print("Player left");
|
||||
}
|
||||
|
||||
private void Init()
|
||||
|
||||
Reference in New Issue
Block a user