Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d65ad3d

Browse files
End Screen
added the end screen as well as stairs functionality, this will allow the player to play through each of the levels and then move on to the next level as well
1 parent 2dd8375 commit d65ad3d

File tree

21 files changed

+96463
-828
lines changed

21 files changed

+96463
-828
lines changed

‎Native_Compilation_Project/Assets/Enemy/Scripts/EnemyHealth.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ public class EnemyHealth : MonoBehaviour
2828

2929
private bool alreadyDropped = false;
3030

31+
private GameManager gameManager;
3132
public void OnEnable()
3233
{
34+
gameManager = GameObject.FindGameObjectWithTag("MANAGER").GetComponent<GameManager>();
3335
curHealth = maxHealth;
3436
enemy = GetComponent<Enemy>();
3537
scoreManager = GameObject.FindGameObjectWithTag("ScoreManager").GetComponent<ScoreManager>();
@@ -66,6 +68,9 @@ public void takeDamage(float damage)
6668
_temp2.GetComponent<Rigidbody>().AddTorque(new Vector3(Random.Range(minTorque, maxTorque), Random.Range(minTorque, maxTorque), Random.Range(minTorque, maxTorque)));
6769
}
6870
Destroy(gameObject);
71+
// add a kill to the kill count && decrease the ammount of enemys left on this floor/level
72+
gameManager.kills++;
73+
gameManager.currentEnemies[gameManager.currentFloor]--;
6974

7075
// increase score by the ammount this enemy adds (specific to each enemy)
7176
scoreManager.changeScore(score);
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
using UnityEngine.EventSystems;
6+
using UnityEngine.SceneManagement;
7+
using TMPro;
8+
using UnityEngine.InputSystem;
9+
10+
public class EndScreen : MonoBehaviour
11+
{
12+
[Header("Input")]
13+
public PlayerInput playerInput;
14+
public InputActionReference Up;
15+
public InputActionReference Down;
16+
public InputActionReference Left;
17+
public InputActionReference Right;
18+
public InputActionReference A;
19+
public InputActionReference B;
20+
21+
[Header("Menu Navigation")]
22+
public int curSelected = 0;
23+
public GameObject[] buttons;
24+
25+
[Header("Managers")]
26+
public inGameManager ingamemanager;
27+
public GameManager gameManager;
28+
29+
[Header("Text Objects")]
30+
public TMP_Text kills;
31+
public TMP_Text shots;
32+
public TMP_Text accuracy;
33+
public TMP_Text death;
34+
public TMP_Text time;
35+
public TMP_Text score;
36+
37+
public void OnEnable()
38+
{
39+
gameManager = GameObject.FindGameObjectWithTag("MANAGER").GetComponent<GameManager>();
40+
ingamemanager.canPause = false;
41+
playerInput.SwitchCurrentActionMap("Menus_Map"); // default = Player_Map
42+
Time.timeScale = 0f;
43+
44+
// initilse all of the UI componets of the end screen GUI
45+
kills.text = "Kills: " + gameManager.kills.ToString();
46+
shots.text = "shots: " + gameManager.shots.ToString();
47+
if (gameManager.shots == 0)
48+
accuracy.text = "accuracy: 100%";
49+
else
50+
accuracy.text = "accuracy: " + ((gameManager.kills / gameManager.shots) * 100).ToString() + "%";
51+
death.text = "deaths: " + gameManager.deaths.ToString();
52+
time.text = "time: " + (gameManager.finishTime - gameManager.startTime).ToString();
53+
score.text = "score: " + gameManager.score.ToString();
54+
}
55+
56+
public void Update()
57+
{
58+
if (Left.action.WasPressedThisFrame() && curSelected > 0)
59+
curSelected--;
60+
else if (Right.action.WasPressedThisFrame() && curSelected < 2)
61+
curSelected++;
62+
EventSystem.current.SetSelectedGameObject(null);
63+
EventSystem.current.SetSelectedGameObject(buttons[curSelected]);
64+
}
65+
66+
public void replayButton()
67+
{
68+
playerInput.SwitchCurrentActionMap("Player_Map");
69+
SceneManager.LoadSceneAsync(gameManager.currentSceneIndex);
70+
Time.timeScale = 1f;
71+
Destroy(gameManager.gameObject);
72+
}
73+
public void menuButton()
74+
{
75+
Time.timeScale = 1f;
76+
SceneManager.LoadScene(0);
77+
Destroy(gameManager.gameObject);
78+
}
79+
public void nextButton()
80+
{
81+
Time.timeScale = 1f;
82+
SceneManager.LoadSceneAsync(gameManager.currentFloor + gameManager.currentSceneIndex + 1);
83+
Destroy(gameManager.gameObject);
84+
}
85+
86+
}

‎Native_Compilation_Project/Assets/Menus/EndScreen.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Native_Compilation_Project/Assets/Menus/inGameManager.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class inGameManager : MonoBehaviour
1313
[Header("UI's")]
1414
public GameObject scoreUI;
1515
public GameObject pauseUI;
16+
public GameObject endUI;
1617

1718
[Header("Scripts")]
1819
public PauseMenu pauseMenu;
@@ -21,6 +22,8 @@ public class inGameManager : MonoBehaviour
2122
public InputDevice activeDevice = null;
2223
public GameObject controllerDisconnectedWarning;
2324

25+
public bool canPause;
26+
2427
public void OnEnable()
2528
{
2629
//activeDevice = null;
@@ -39,21 +42,27 @@ public void OnEnable()
3942
//Debug.Log("Device removed: " + device);
4043
if (device == activeDevice)
4144
{
42-
controllerDisconnectedWarning.SetActive(true);
43-
openPauseMenu();
45+
if (canPause)
46+
{
47+
controllerDisconnectedWarning.SetActive(true);
48+
openPauseMenu();
49+
}
4450
}
4551
break;
4652
}
4753
};
4854
}
4955

50-
56+
5157

5258
public void Update()
5359
{
5460
if (pauseButton.action.WasPressedThisFrame() && scoreUI.activeInHierarchy)
5561
{
56-
openPauseMenu();
62+
if (canPause)
63+
{
64+
openPauseMenu();
65+
}
5766
}
5867
}
5968

‎Native_Compilation_Project/Assets/Player/Scripts/Health.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections;
22
using System.Collections.Generic;
33
using UnityEngine;
4+
using UnityEngine.InputSystem;
45
using UnityEngine.SceneManagement;
56

67
public class Health : MonoBehaviour
@@ -10,8 +11,12 @@ public class Health : MonoBehaviour
1011
public float currentHealth;
1112
public int currentScene = 1;
1213

14+
private GameManager gameManager;
15+
1316
public void Start()
1417
{
18+
gameManager = GameObject.FindGameObjectWithTag("MANAGER").GetComponent<GameManager>();
19+
currentScene = gameManager.currentFloor + gameManager.currentSceneIndex;
1520
currentHealth = maxHealth;
1621
}
1722

@@ -31,6 +36,8 @@ public void changeHealth(float ammount)
3136
currentHealth += ammount;
3237
else
3338
{
39+
gameManager.deaths++;
40+
Gamepad.current.ResetHaptics();
3441
SceneManager.LoadSceneAsync(currentScene);
3542
}
3643
}

‎Native_Compilation_Project/Assets/Progression.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using Unity.PlasticSCM.Editor.WebApi;
4+
using UnityEngine;
5+
using UnityEngine.SceneManagement;
6+
7+
public class GameManager : MonoBehaviour
8+
{
9+
[Header("Floors")]
10+
public int currentSceneIndex;
11+
public int currentFloor;
12+
public int maxFloor;
13+
public bool stairsEnabled;
14+
15+
[Header("Kills")]
16+
public int[] currentEnemies;
17+
18+
[Header("End Screen")]
19+
public GameObject endScreen;
20+
public GameObject pauseMenu;
21+
public GameObject inGameUI;
22+
23+
[Header("Values")]
24+
public int kills;
25+
public int shots;
26+
public int deaths;
27+
public int score;
28+
[Header("Time")]
29+
public float startTime;
30+
public float finishTime;
31+
32+
public void OnEnable()
33+
{
34+
DontDestroyOnLoad(this);
35+
currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
36+
startTime = Time.time;
37+
stairsEnabled = false;
38+
}
39+
40+
public void Update()
41+
{
42+
if (endScreen == null)
43+
{
44+
endScreen = GameObject.FindGameObjectWithTag("ScoreManager").GetComponent<inGameManager>().endUI;
45+
pauseMenu = GameObject.FindGameObjectWithTag("ScoreManager").GetComponent<inGameManager>().pauseUI;
46+
inGameUI = GameObject.FindGameObjectWithTag("ScoreManager").GetComponent<inGameManager>().scoreUI;
47+
}
48+
// Killed all of the enemies
49+
if (currentEnemies[currentFloor] <= 0)
50+
{
51+
stairsEnabled = true;
52+
}
53+
}
54+
55+
public void stairs()
56+
{
57+
if (stairsEnabled)
58+
{
59+
// load the next scene if not the last scene if the last scene show the end screen;
60+
if (currentFloor < maxFloor)
61+
{
62+
currentFloor++;
63+
SceneManager.LoadSceneAsync(currentFloor + currentSceneIndex);
64+
}
65+
else
66+
{
67+
finishTime = Time.time;
68+
endScreen.SetActive(true);
69+
pauseMenu.SetActive(false);
70+
inGameUI.SetActive(false);
71+
}
72+
}
73+
}
74+
}

‎Native_Compilation_Project/Assets/Progression/GameManager.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /