Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class GameManager : MonoBehaviour
- {
- public static GameManager instance; // Define a static instance variable
- public Transform platformGenerator;
- private Vector3 platformStartPoint;
- public PlayerController thePlayer;
- private Vector3 playerStartPoint;
- private PlatformDestroyer[] platformList;
- public ScoreManager theScoreManager;
- public DeathMenu theDeathScreen;
- public bool powerupReset;
- // Start is called before the first frame update
- void Start()
- {
- instance = this; // Assign the current instance to the static variable
- platformStartPoint = platformGenerator.position;
- playerStartPoint = thePlayer.transform.position;
- theScoreManager = FindObjectOfType<ScoreManager>();
- }
- // Update is called once per frame
- void Update()
- {
- // Update logic here (if needed), but don't place methods here
- }
- // Method to restart the game
- public void RestartGame()
- {
- theScoreManager.scoreIncreasing = false;
- thePlayer.gameObject.SetActive(false);
- theDeathScreen.gameObject.SetActive(true);
- // StartCoroutine(RestartGameCo());
- }
- public void Reset()
- {
- theDeathScreen.gameObject.SetActive(false);
- platformList = FindObjectsOfType<PlatformDestroyer>();
- for (int i = 0; i < platformList.Length; i++)
- {
- platformList[i].gameObject.SetActive(false);
- }
- thePlayer.transform.position = playerStartPoint;
- platformGenerator.position = platformStartPoint;
- thePlayer.gameObject.SetActive(true);
- theScoreManager.scoreCount = 0;
- theScoreManager.scoreIncreasing = true;
- powerupReset = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement