Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed mainmenu button #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 35 additions & 24 deletions GGJSGA23/Assets/MenuManager.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using System;
using RootRacer;
using UnityEngine;
using UnityEngine.Rendering.UI;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class MenuManager : MonoBehaviour
{
public static MenuManager Instance;
[SerializeField] private Canvas MenuCanvas;
[SerializeField] private Canvas creditsCanvas;
[SerializeField] private Canvas placingsCanvas;
private int activeScene = 0;
[SerializeField] private string nextScene;
//private int activeScene = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can ignore commenting code, we have version control for a reason! :)

[SerializeField] private string gameScene;
[SerializeField] private string titleScene;
public Image logo;
public Sprite[] logos;
public int players = 2;
Expand All @@ -19,28 +22,29 @@ public class MenuManager : MonoBehaviour
[SerializeField] private string threePlayerScene;
[SerializeField] private string fourPlayerScene;

[SerializeField] private string gameOverScene;
//[SerializeField] private string gameOverScene;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here


//bool changingScene = false;

// Start is called before the first frame update

void Start()
{
if (Instance == null)
{
Instance = this;
}
if (Instance != this)
{
Destroy(gameObject);
return;
}

DontDestroyOnLoad(this.gameObject);
}

// Update is called once per frame
void Update()
{ }

public void LoadNextScene()
{
//changingScene = true;
//activeScene++;
//SceneManager.LoadScene(activeScene, LoadSceneMode.Single);

SceneManager.LoadScene(nextScene, LoadSceneMode.Single);
}

public void StartGame()
{
Expand All @@ -60,11 +64,16 @@ public void StartGame()
}
placingsCanvas.gameObject.SetActive(false);
MenuCanvas.gameObject.SetActive(false);
SceneManager.LoadScene(nextScene, LoadSceneMode.Single);
SceneManager.LoadScene(gameScene, LoadSceneMode.Single);
SceneManager.LoadScene(scene, LoadSceneMode.Additive);
}
public void BackToTitle()
{
SceneManager.LoadScene(titleScene, LoadSceneMode.Single);
ShowRootMenu();
}

public void QuitGame()
public void QuitGame()
{
Application.Quit();
}
Expand All @@ -77,19 +86,25 @@ public void RestartGame()

public void ShowCredits()
{
HidePanels();
creditsCanvas.gameObject.SetActive(true);
MenuCanvas.gameObject.SetActive(false);
}

public void GoBack()
public void ShowRootMenu()
{
creditsCanvas.gameObject.SetActive(false);
HidePanels();
MenuCanvas.gameObject.SetActive(true);
}
private void HidePanels()
{
placingsCanvas.gameObject.SetActive(false);
creditsCanvas.gameObject.SetActive(false);
MenuCanvas.gameObject.SetActive(false);
}

public void ShowGameOver(PlayerController playerController)
{
//SceneManager.LoadScene(gameOverScene, LoadSceneMode.Single);
HidePanels();
SetPlace(0, playerController);
Debug.Log(GameManager.Instance.playerDeaths.Count);
int i = 1;
Expand All @@ -102,10 +117,6 @@ public void ShowGameOver(PlayerController playerController)
SetPlace(i);
i++;
}
// for (int i = 0; i <= GameManager.Instance.playerDeaths.Count; i++)
// {
// SetPlace(i+1);
//}
placingsCanvas.gameObject.SetActive(true);
}
private void SetPlace(int i, PlayerController player)
Expand All @@ -121,7 +132,7 @@ private void SetPlace(int i)
Color c = placingsImages[i].color;
c.a = 1f;
placingsImages[i].color = c;
}
}

public void SelectPlayers(int players)
{
Expand Down
Loading