Advertisement
johnnygoodguy2000

LogicScript

Mar 17th, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6.  
  7. public class LogicScript : MonoBehaviour
  8. {
  9.     public int playerScore;
  10.     public Text scoreText;
  11.     public GameObject gameOverScreen;
  12.  
  13. [ContextMenu("Increase Score")]
  14.     public void addScore(int scoreToAdd)
  15.     {
  16.         playerScore = playerScore + scoreToAdd;
  17.         scoreText.text = playerScore.ToString();
  18.         Debug.Log("Score increased by " + scoreToAdd + ". Current score: " + playerScore);
  19.     }
  20.  
  21.     public void restartGame()
  22.     {
  23.         SceneManager.LoadScene(SceneManager.GetActiveScene().name);
  24.     }
  25.  
  26.     public void gameOver()
  27.     {
  28.         gameOverScreen.SetActive(true);
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement