Skip to content

Commit

Permalink
added pause panel
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulEvans07 committed Nov 26, 2019
1 parent 9658acb commit 49e45e6
Show file tree
Hide file tree
Showing 12 changed files with 1,085 additions and 110 deletions.
14 changes: 7 additions & 7 deletions Assets/Resources/level_01.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{ "type": 0, "x": -3, "y": 4, "hitPoints": 3, "color": "#2d3258", "powerUp": { "name": "SpawnExtraBall", "duration": 0 } },
{ "type": 0, "x": -2, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": -1, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": 0, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": 0, "y": 4, "hitPoints": 0, "color": "#2d3258" },
{ "type": 0, "x": 1, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": 2, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": 3, "y": 4, "hitPoints": 3, "color": "#2d3258", "powerUp": { "name": "SpawnExtraBall", "duration": 0 } },
Expand All @@ -19,11 +19,11 @@
{ "type": 0, "x": -5, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": -4, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": -3, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": -2, "y": 5, "hitPoints": 0, "color": "#304b78" },
{ "type": 0, "x": -2, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": -1, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 0, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 0, "y": 5, "hitPoints": 0, "color": "#304b78" },
{ "type": 0, "x": 1, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 2, "y": 5, "hitPoints": 0, "color": "#304b78" },
{ "type": 0, "x": 2, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 3, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 4, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 5, "y": 5, "hitPoints": 1, "color": "#304b78" },
Expand All @@ -34,9 +34,9 @@
{ "type": 0, "x": -4, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": -3, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": -2, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": -1, "y": 6, "hitPoints": 0, "color": "#2494a2" },
{ "type": 0, "x": 0, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": 1, "y": 6, "hitPoints": 0, "color": "#2494a2" },
{ "type": 0, "x": -1, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": 0, "y": 6, "hitPoints": 0, "color": "#2494a2" },
{ "type": 0, "x": 1, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": 2, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": 3, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": 4, "y": 6, "hitPoints": 1, "color": "#2494a2" },
Expand Down
2 changes: 1 addition & 1 deletion Assets/Resources/level_01.json.meta

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

74 changes: 74 additions & 0 deletions Assets/Resources/level_02.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "level_01",
"map": [
{ "type": 0, "x": -6, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": -5, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": -4, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": -3, "y": 4, "hitPoints": 3, "color": "#2d3258", "powerUp": { "name": "SpawnExtraBall", "duration": 0 } },
{ "type": 0, "x": -2, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": -1, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": 0, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": 1, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": 2, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": 3, "y": 4, "hitPoints": 3, "color": "#2d3258", "powerUp": { "name": "SpawnExtraBall", "duration": 0 } },
{ "type": 0, "x": 4, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": 5, "y": 4, "hitPoints": 1, "color": "#2d3258" },
{ "type": 0, "x": 6, "y": 4, "hitPoints": 1, "color": "#2d3258" },

{ "type": 0, "x": -6, "y": 5, "hitPoints": 1, "color": "#304b78", "powerUp": { "name": "ShrinkPaddle", "duration": 10 } },
{ "type": 0, "x": -5, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": -4, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": -3, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": -2, "y": 5, "hitPoints": 0, "color": "#304b78" },
{ "type": 0, "x": -1, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 0, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 1, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 2, "y": 5, "hitPoints": 0, "color": "#304b78" },
{ "type": 0, "x": 3, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 4, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 5, "y": 5, "hitPoints": 1, "color": "#304b78" },
{ "type": 0, "x": 6, "y": 5, "hitPoints": 1, "color": "#304b78", "powerUp": { "name": "GrowPaddle", "duration": 10 } },

{ "type": 0, "x": -6, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": -5, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": -4, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": -3, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": -2, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": -1, "y": 6, "hitPoints": 0, "color": "#2494a2" },
{ "type": 0, "x": 0, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": 1, "y": 6, "hitPoints": 0, "color": "#2494a2" },
{ "type": 0, "x": 2, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": 3, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": 4, "y": 6, "hitPoints": 1, "color": "#2494a2" },
{ "type": 0, "x": 5, "y": 6, "hitPoints": 1, "color": "#2494a2", "powerUp": { "name": "ExtraBall", "duration": 0 } },
{ "type": 0, "x": 6, "y": 6, "hitPoints": 1, "color": "#2494a2" },

{ "type": 0, "x": -6, "y": 7, "hitPoints": 0, "color": "#56bca4" },
{ "type": 0, "x": -5, "y": 7, "hitPoints": 2, "color": "#56bca4" },
{ "type": 0, "x": -4, "y": 7, "hitPoints": 1, "color": "#56bca4" },
{ "type": 0, "x": -3, "y": 7, "hitPoints": 1, "color": "#56bca4" },
{ "type": 0, "x": -2, "y": 7, "hitPoints": 2, "color": "#56bca4" },
{ "type": 0, "x": -1, "y": 7, "hitPoints": 2, "color": "#56bca4", "powerUp": { "name": "BallSpeedDown", "duration": 15 } },
{ "type": 0, "x": 0, "y": 7, "hitPoints": 0, "color": "#56bca4" },
{ "type": 0, "x": 1, "y": 7, "hitPoints": 2, "color": "#56bca4", "powerUp": { "name": "BallSpeedUp", "duration": 15 } },
{ "type": 0, "x": 2, "y": 7, "hitPoints": 2, "color": "#56bca4" },
{ "type": 0, "x": 3, "y": 7, "hitPoints": 1, "color": "#56bca4" },
{ "type": 0, "x": 4, "y": 7, "hitPoints": 1, "color": "#56bca4" },
{ "type": 0, "x": 5, "y": 7, "hitPoints": 2, "color": "#56bca4" },
{ "type": 0, "x": 6, "y": 7, "hitPoints": 0, "color": "#56bca4" },

{ "type": 0, "x": -6, "y": 8, "hitPoints": 0, "color": "#ddb03b" },
{ "type": 0, "x": -5, "y": 8, "hitPoints": 0, "color": "#ddb03b" },
{ "type": 0, "x": -4, "y": 8, "hitPoints": 1, "color": "#ddb03b" },
{ "type": 0, "x": -3, "y": 8, "hitPoints": 1, "color": "#ddb03b" },
{ "type": 0, "x": -2, "y": 8, "hitPoints": 1, "color": "#ddb03b" },
{ "type": 0, "x": -1, "y": 8, "hitPoints": 2, "color": "#ddb03b" },
{ "type": 0, "x": 0, "y": 8, "hitPoints": 2, "color": "#ddb03b", "powerUp": { "name": "PiercingBall", "duration": 10 } },
{ "type": 0, "x": 1, "y": 8, "hitPoints": 2, "color": "#ddb03b" },
{ "type": 0, "x": 2, "y": 8, "hitPoints": 1, "color": "#ddb03b" },
{ "type": 0, "x": 3, "y": 8, "hitPoints": 1, "color": "#ddb03b" },
{ "type": 0, "x": 4, "y": 8, "hitPoints": 1, "color": "#ddb03b" },
{ "type": 0, "x": 5, "y": 8, "hitPoints": 0, "color": "#ddb03b" },
{ "type": 0, "x": 6, "y": 8, "hitPoints": 0, "color": "#ddb03b" }
]
}

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

7 changes: 0 additions & 7 deletions Assets/Resources/test_01.json

This file was deleted.

12 changes: 8 additions & 4 deletions Assets/Scripts/GameInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ private void Awake() {

string[] userLevelPathList = Directory.GetFiles(absoluteGameFolderPath);
foreach(string path in userLevelPathList) {
TextAsset asset = new TextAsset(ReadJsonFromFile(path));

string[] parts = path.Split(Path.DirectorySeparatorChar);
asset.name = parts[parts.Length - 1];

GameState.userLevels.Add(asset);
string fileName = parts[parts.Length - 1];
fileName = fileName.Substring(0, fileName.Length - 5);

if (fileName != userLevelTemplate.name) {
TextAsset asset = new TextAsset(ReadJsonFromFile(path));
asset.name = fileName;
GameState.userLevels.Add(asset);
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions Assets/Scripts/GamePlayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ public class GamePlayController : MonoBehaviour {
public PaddleController playerController;
public GameObject winScreen;
public GameObject loseScreen;
public GameObject pausePanel;

private void Awake() {
winScreen.SetActive(false);
loseScreen.SetActive(false);
pausePanel.SetActive(false);
}

public void ShowWinScreen() {
Expand All @@ -23,6 +25,16 @@ public void ShowGameOverScreen() {
loseScreen.SetActive(true);
}

public void PauseGame() {
Time.timeScale = 0f;
pausePanel.SetActive(true);
}

public void ResumeGame() {
pausePanel.SetActive(false);
Time.timeScale = 1f;
}

public void Replay() {
SceneManager.LoadScene("GameScene");
}
Expand Down
5 changes: 5 additions & 0 deletions Assets/Scripts/LevelSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ private void Awake() {
PlaceButton(NextPos(i), () => this.SelectLevel(lvl), lvl.name);
i++;
}
foreach(TextAsset lvl in GameState.userLevels) {
PlaceButton(NextPos(i), () => this.SelectLevel(lvl), lvl.name);
i++;
}


PlaceButton(NextPos(i) + Vector3.down * btnHeight, backToMainMenu.Invoke, "Back");

Expand Down
9 changes: 7 additions & 2 deletions Assets/Scripts/MapLoader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.IO;
using System.Collections.Generic;
using System;
using UnityEngine.SceneManagement;
using UnityEngine;

public class MapLoader : MonoBehaviour {
Expand All @@ -10,6 +9,7 @@ public class MapLoader : MonoBehaviour {
private Dictionary<string, PowerUpObject> powerupMap;

public void Awake() {
Time.timeScale = 1f;
BrickController.brickList = new List<BrickController>();
powerupMap = MapPowerUps(powerupList);
Level level = JsonUtility.FromJson<Level>(GameState.selectedLevel);
Expand All @@ -25,6 +25,11 @@ public static Dictionary<string, PowerUpObject> MapPowerUps(List<PowerUpObject>
}

private void Load(Level level) {
if (level == null || level.map == null) {
SceneManager.LoadScene("MainMenu");
return;
}

foreach (Brick brick in level.map) {
SpawnBrick(brick);
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/PaddleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private void Awake() {

private void Update() {
if (gameOver) return;
if (Input.GetButtonUp("Cancel")) SceneManager.LoadScene("MainMenu");
if (Input.GetButtonUp("Cancel")) _gameController.PauseGame();

this.x = Input.GetAxis("Horizontal");
Move();
Expand Down
Loading

0 comments on commit 49e45e6

Please sign in to comment.