added transition scene with basic tutorial AND PERSISTENT DATA
PLEASE launch game from the main menu scene, otherwise persistent data will not load correctly
This commit is contained in:
		
							
								
								
									
										30
									
								
								Assets/Scripts/DialogBoxes.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								Assets/Scripts/DialogBoxes.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.InputSystem;
 | 
			
		||||
using TMPro;
 | 
			
		||||
 | 
			
		||||
public class DialogBoxes : MonoBehaviour
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    [Header("Dialog Messages:")]
 | 
			
		||||
    [SerializeField] string[] dialogMessages;
 | 
			
		||||
    private TMP_Text textField;
 | 
			
		||||
    private int messageCount = 0;
 | 
			
		||||
 | 
			
		||||
    // Start is called before the first frame update
 | 
			
		||||
    void Start()
 | 
			
		||||
    {
 | 
			
		||||
        textField = this.gameObject.GetComponent<TMP_Text>();
 | 
			
		||||
        textField.text = dialogMessages[0];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    void OnAdvanceDialog() {
 | 
			
		||||
        messageCount += 1;
 | 
			
		||||
        if (messageCount < dialogMessages.Length) {
 | 
			
		||||
            textField.text = dialogMessages[messageCount];
 | 
			
		||||
        } else { // no more dialog messages, advance the scene
 | 
			
		||||
            GameObject.Find("SceneManager").GetComponent<SceneController>().NextScene();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: cfde94a1d6dbc4cb49a9a7530cb6f6e0
 | 
			
		||||
guid: 72c45d3f9da5e4ffc8662964e2518a79
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
@@ -1,30 +0,0 @@
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.InputSystem;
 | 
			
		||||
 | 
			
		||||
public class PauseController : MonoBehaviour
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    public bool isPaused = false;
 | 
			
		||||
    public GameObject pauseMenuCanvas;
 | 
			
		||||
 | 
			
		||||
    void Awake() {
 | 
			
		||||
        TogglePauseMenu(false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void OnPause() {
 | 
			
		||||
        if (!isPaused) {
 | 
			
		||||
            Time.timeScale = 0;
 | 
			
		||||
            TogglePauseMenu(true);
 | 
			
		||||
        } else {
 | 
			
		||||
            Time.timeScale = 1;
 | 
			
		||||
            TogglePauseMenu(false);
 | 
			
		||||
        }
 | 
			
		||||
        isPaused = !isPaused;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void TogglePauseMenu(bool showPauseMenu) {
 | 
			
		||||
        pauseMenuCanvas.SetActive(showPauseMenu);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -132,7 +132,7 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void LetGoOfGrapple() {
 | 
			
		||||
        bool currentlyPaused = GameObject.Find("PauseMenu").GetComponent<PauseController>().isPaused;
 | 
			
		||||
        bool currentlyPaused = stateController.isPaused;
 | 
			
		||||
        if (grapplingRope.isGrappling && !currentlyPaused) {
 | 
			
		||||
            print("currently paused is " + currentlyPaused + ", releasing grapple");
 | 
			
		||||
            if (tambourine != null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,9 @@ public class SpawnPointBehavior : MonoBehaviour
 | 
			
		||||
    [SerializeField] private Sprite deactivatedSprite;
 | 
			
		||||
    [SerializeField] private Sprite activatedSprite;
 | 
			
		||||
 | 
			
		||||
    [Header("Initialization")]
 | 
			
		||||
    [SerializeField] public bool firstSpawnPoint;
 | 
			
		||||
 | 
			
		||||
    // not set in inspector
 | 
			
		||||
    private SpriteRenderer _sr;
 | 
			
		||||
    private StateController stateController;
 | 
			
		||||
@@ -19,6 +22,9 @@ public class SpawnPointBehavior : MonoBehaviour
 | 
			
		||||
    {
 | 
			
		||||
      _sr = this.gameObject.GetComponent<SpriteRenderer>();  
 | 
			
		||||
      stateController = GameObject.Find("StateController").GetComponent<StateController>();
 | 
			
		||||
      if (firstSpawnPoint) {
 | 
			
		||||
        ActivateSpawnPoint();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void ActivateSpawnPoint() {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.SceneManagement;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
 | 
			
		||||
public class StateController : MonoBehaviour {
 | 
			
		||||
 | 
			
		||||
@@ -9,14 +11,49 @@ public class StateController : MonoBehaviour {
 | 
			
		||||
    public GameObject spawnPoint;
 | 
			
		||||
    [SerializeField] private GameObject deathCanvas;
 | 
			
		||||
 | 
			
		||||
    [Header("Pause Menu")]
 | 
			
		||||
    public bool isPaused = false;
 | 
			
		||||
    public GameObject pauseMenuCanvas;
 | 
			
		||||
 | 
			
		||||
    void Awake() {
 | 
			
		||||
        deathCanvas.SetActive(false);
 | 
			
		||||
        DontDestroyOnLoad(this.gameObject);
 | 
			
		||||
        SceneManager.sceneLoaded += OnSceneLoaded;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void OnSceneLoaded(Scene scene, LoadSceneMode mode) { 
 | 
			
		||||
        deathCanvas = GameObject.Find("DeathUICanvas");
 | 
			
		||||
        if (deathCanvas != null) {
 | 
			
		||||
            Button respawnButton = GameObject.Find("RespawnButton").GetComponent<Button>();
 | 
			
		||||
            respawnButton.onClick.AddListener(RespawnPlayer);
 | 
			
		||||
            deathCanvas.SetActive(false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        pauseMenuCanvas = GameObject.Find("PauseMenuCanvas");
 | 
			
		||||
        if (pauseMenuCanvas != null) {
 | 
			
		||||
            TogglePauseMenu(false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void OnPause() {
 | 
			
		||||
        if (!isPaused) {
 | 
			
		||||
            Time.timeScale = 0;
 | 
			
		||||
            TogglePauseMenu(true);
 | 
			
		||||
        } else {
 | 
			
		||||
            Time.timeScale = 1;
 | 
			
		||||
            TogglePauseMenu(false);
 | 
			
		||||
        }
 | 
			
		||||
        isPaused = !isPaused;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void TogglePauseMenu(bool showPauseMenu) {
 | 
			
		||||
        pauseMenuCanvas.SetActive(showPauseMenu);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void RespawnPlayer() {
 | 
			
		||||
        SetDeathCanvasActive(false);
 | 
			
		||||
        GameObject.Find("Main Camera").GetComponent<CameraMovement>().FindPlayer();
 | 
			
		||||
        Instantiate(player, spawnPoint.transform.position, spawnPoint.transform.rotation);
 | 
			
		||||
        Instantiate(player, spawnPoint.transform.position, player.transform.rotation);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void SetDeathCanvasActive(bool activeState) {
 | 
			
		||||
 
 | 
			
		||||
@@ -52,16 +52,19 @@ public class TambourineBehavior : MonoBehaviour {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void OnTriggerEnter2D(Collider2D col) {
 | 
			
		||||
        collidedObject = col.gameObject;
 | 
			
		||||
        if (collidedObject.tag == "Enemy") {
 | 
			
		||||
        print(col.tag);
 | 
			
		||||
        if (col.tag == "Enemy") {
 | 
			
		||||
            collidedObject = col.gameObject;
 | 
			
		||||
            print("Pinning to enemy");
 | 
			
		||||
            this.gameObject.GetComponent<CircleCollider2D>().enabled = false;
 | 
			
		||||
            collidedObject.GetComponent<EnemyPatrol>().pinned = true;
 | 
			
		||||
            collidedObject.GetComponent<EnemyPatrol>().TogglePin(true);
 | 
			
		||||
        } else if (collidedObject.tag == "Projectile") {
 | 
			
		||||
            // print("pinned");
 | 
			
		||||
        } else if (col.tag == "Projectile") {
 | 
			
		||||
            collidedObject = col.gameObject;
 | 
			
		||||
            print("pinned to projectile");
 | 
			
		||||
            this.gameObject.GetComponent<CircleCollider2D>().enabled = false;
 | 
			
		||||
            collidedObject.GetComponent<ProjectileBehavior>().Pin();
 | 
			
		||||
        } 
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void OnCollisionEnter2D(Collision2D col) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user