Skip to content

Commit

Permalink
Add quit button and pause menu
Browse files Browse the repository at this point in the history
  • Loading branch information
BernatBC committed Jul 26, 2023
1 parent 37b1dd0 commit 45128d3
Show file tree
Hide file tree
Showing 8 changed files with 1,966 additions and 516 deletions.
383 changes: 285 additions & 98 deletions Assets/Scenes/MainMenu.unity

Large diffs are not rendered by default.

1,870 changes: 1,453 additions & 417 deletions Assets/Scenes/SampleScene.unity

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion Assets/Scripts/CellInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ public struct Utility
/// </summary>
private Dictionary<string, GameObject[]> housesPrefabs;

/// <summary>
/// Indicates if raycast is enabled
/// </summary>
private bool raycastEnabled = true;

/// <summary>
/// Method <c>InitializePropertyDictionary</c> initializes <c>propertyInformation</c>.
/// </summary>
Expand Down Expand Up @@ -1914,14 +1919,22 @@ public int GetTraddingDifference(bool playerPartner) {
return player2_value - player1_value;
}

/// <summary>
/// Method <c>SetRaycast</c> enables or disables the raycast of cells
/// </summary>
/// <param name="enable">True to enable, False to disable</param>
public void SetRaycast(bool enable) {
raycastEnabled = enable;
}

/// <summary>
/// Method <c>Update</c> Interacts with cells after clicking on them.
/// </summary>
private void Update()
{
if (!Input.GetMouseButtonDown(0)) return;

if (!justButtons && !DisableCard() && !tradingSelected)
if (!justButtons && !DisableCard() && !tradingSelected && raycastEnabled)
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,12 @@ public void SetBotDifficulty4(int difficulty)
{
botDifficulty[3] = difficulty;
}

/// <summary>
/// Method <c>QuitGame</c> quits the game.
/// </summary>
public void QuitGame()
{
Application.Quit();
}
}
42 changes: 42 additions & 0 deletions Assets/Scripts/PauseMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PauseMenu : MonoBehaviour
{

public GameObject pausePanel;

/// <summary>
/// Method <c>ShowPauseMenu</c> pauses the game, and shows the pause menu.
/// </summary>
public void ShowPauseMenu() {
Time.timeScale = 0;
GetComponent<CellInfo>().SetRaycast(false);
pausePanel.SetActive(true);
}

/// <summary>
/// Method <c>ResumeGame</c> resumes the game.
/// </summary>
public void ResumeGame() {
pausePanel.SetActive(false);
GetComponent<CellInfo>().SetRaycast(true);
Time.timeScale = 1;
}

/// <summary>
/// Method <c>BackToMenu</c> returns to menu screen
/// </summary>
public void BackToMenu() {
SceneManager.LoadScene("MainMenu");
}

/// <summary>
/// Method <c>QuitGame</c> quits the game.
/// </summary>
public void QuitGame() {
Application.Quit();
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/PauseMenu.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Sprites/menuButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
153 changes: 153 additions & 0 deletions Assets/Sprites/menuButton.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 45128d3

Please sign in to comment.