added a way for the player to die and respawn, reconfigured test level
ALSO installed TMP but it has been giving me ISSUES
This commit is contained in:
		
							
								
								
									
										78
									
								
								Assets/Scripts/OLD_StateController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								Assets/Scripts/OLD_StateController.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
 | 
			
		||||
public class OLD_StateController : MonoBehaviour {
 | 
			
		||||
 | 
			
		||||
    // this is mostly a placeholder for making the programmer HUD work properly
 | 
			
		||||
    // something like this will be needed later but like with real variables
 | 
			
		||||
 | 
			
		||||
    public bool canTrumpet = true;
 | 
			
		||||
    public bool canTambourine = true;
 | 
			
		||||
    public bool canClarinet = true;
 | 
			
		||||
    public bool canCymbal = true;
 | 
			
		||||
 | 
			
		||||
    public enum PlayerStates {
 | 
			
		||||
        Idle,
 | 
			
		||||
        Running,
 | 
			
		||||
        Jumping,
 | 
			
		||||
        Falling,
 | 
			
		||||
        TrumpetJumping,
 | 
			
		||||
        TambourineThrowing,
 | 
			
		||||
        SpiderGrappling,
 | 
			
		||||
        ClarinetDiving,
 | 
			
		||||
        CymbalParrying,
 | 
			
		||||
    }
 | 
			
		||||
    public PlayerStates currentState = PlayerStates.Idle;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // Start is called before the first frame update
 | 
			
		||||
    void Start() {
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Update is called once per frame
 | 
			
		||||
    void Update() {
 | 
			
		||||
        if (Input.GetKeyDown(KeyCode.Q)) {
 | 
			
		||||
            canTrumpet = !canTrumpet;
 | 
			
		||||
            print("Q");
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown(KeyCode.W)) {
 | 
			
		||||
            canTambourine = !canTambourine;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown(KeyCode.E)) {
 | 
			
		||||
            canClarinet = !canClarinet;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown(KeyCode.R)) {
 | 
			
		||||
            canCymbal = !canCymbal;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (Input.GetKeyDown("1")) {
 | 
			
		||||
            currentState = PlayerStates.Idle;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("2")) {
 | 
			
		||||
            currentState = PlayerStates.Running;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("3")) {
 | 
			
		||||
            currentState = PlayerStates.Jumping;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("4")) {
 | 
			
		||||
            currentState = PlayerStates.Falling;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("5")) {
 | 
			
		||||
            currentState = PlayerStates.TrumpetJumping;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("6")) {
 | 
			
		||||
            currentState = PlayerStates.TambourineThrowing;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("7")) {
 | 
			
		||||
            currentState = PlayerStates.SpiderGrappling;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("8")) {
 | 
			
		||||
            currentState = PlayerStates.ClarinetDiving;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("9")) {
 | 
			
		||||
            currentState = PlayerStates.CymbalParrying;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								Assets/Scripts/OLD_StateController.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								Assets/Scripts/OLD_StateController.cs.meta
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: 73653b02e42804d288eaaf881c511225
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
  defaultReferences: []
 | 
			
		||||
  executionOrder: 0
 | 
			
		||||
  icon: {instanceID: 0}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
@@ -27,20 +27,17 @@ public class PlayerBehavior : MonoBehaviour {
 | 
			
		||||
    [SerializeField] public Tutorial_GrapplingRope grapplingRope;
 | 
			
		||||
    private GameObject grappleSurface;
 | 
			
		||||
 | 
			
		||||
    [Header("State Control:")]
 | 
			
		||||
    private StateController stateController;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    void Start() {
 | 
			
		||||
        _rb = GetComponent<Rigidbody2D>();
 | 
			
		||||
        airSpeed = .5f * moveSpeed;
 | 
			
		||||
        stateController = GameObject.Find("StateController").GetComponent<StateController>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void Update() {
 | 
			
		||||
        // move
 | 
			
		||||
        // _hInput = Input.GetAxis("Horizontal");
 | 
			
		||||
        // if (_hInput < 0) {
 | 
			
		||||
        //     forward = -1;
 | 
			
		||||
        // } else if (_hInput > 0) {
 | 
			
		||||
        //     forward = 1;
 | 
			
		||||
        // }
 | 
			
		||||
 | 
			
		||||
        // jump
 | 
			
		||||
        // if (Input.GetKeyDown(KeyCode.Space)) {
 | 
			
		||||
@@ -102,7 +99,6 @@ public class PlayerBehavior : MonoBehaviour {
 | 
			
		||||
        } else if (_hInput > 0) {
 | 
			
		||||
            forward = 1;
 | 
			
		||||
        }
 | 
			
		||||
        print(_hInput);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void FixedUpdate() {
 | 
			
		||||
@@ -125,6 +121,9 @@ public class PlayerBehavior : MonoBehaviour {
 | 
			
		||||
    void OnTriggerEnter2D(Collider2D col) {
 | 
			
		||||
        if (col.tag == "grappleSurface") {
 | 
			
		||||
            grappleSurface = col.gameObject;
 | 
			
		||||
        } else if (col.tag == "instaDeath") {
 | 
			
		||||
            stateController.ToggleDeathCanvas();
 | 
			
		||||
            Destroy(this.gameObject);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ public class ProgrammerHUDController : MonoBehaviour {
 | 
			
		||||
    [SerializeField] TMP_Text stateText;
 | 
			
		||||
 | 
			
		||||
    [SerializeField] GameObject programmerHUD;
 | 
			
		||||
    [SerializeField] StateController stateController;
 | 
			
		||||
    [SerializeField] OLD_StateController stateController;
 | 
			
		||||
 | 
			
		||||
    // Start is called before the first frame update
 | 
			
		||||
    void Start() {
 | 
			
		||||
 
 | 
			
		||||
@@ -4,75 +4,21 @@ using UnityEngine;
 | 
			
		||||
 | 
			
		||||
public class StateController : MonoBehaviour {
 | 
			
		||||
 | 
			
		||||
    // this is mostly a placeholder for making the programmer HUD work properly
 | 
			
		||||
    // something like this will be needed later but like with real variables
 | 
			
		||||
    [Header("Respawning")]
 | 
			
		||||
    [SerializeField] GameObject player;
 | 
			
		||||
    public GameObject spawnPoint;
 | 
			
		||||
    [SerializeField] private GameObject deathCanvas;
 | 
			
		||||
 | 
			
		||||
    public bool canTrumpet = true;
 | 
			
		||||
    public bool canTambourine = true;
 | 
			
		||||
    public bool canClarinet = true;
 | 
			
		||||
    public bool canCymbal = true;
 | 
			
		||||
 | 
			
		||||
    public enum PlayerStates {
 | 
			
		||||
        Idle,
 | 
			
		||||
        Running,
 | 
			
		||||
        Jumping,
 | 
			
		||||
        Falling,
 | 
			
		||||
        TrumpetJumping,
 | 
			
		||||
        TambourineThrowing,
 | 
			
		||||
        SpiderGrappling,
 | 
			
		||||
        ClarinetDiving,
 | 
			
		||||
        CymbalParrying,
 | 
			
		||||
    }
 | 
			
		||||
    public PlayerStates currentState = PlayerStates.Idle;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // Start is called before the first frame update
 | 
			
		||||
    void Start() {
 | 
			
		||||
        
 | 
			
		||||
    void Awake() {
 | 
			
		||||
        deathCanvas.SetActive(false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Update is called once per frame
 | 
			
		||||
    void Update() {
 | 
			
		||||
        if (Input.GetKeyDown(KeyCode.Q)) {
 | 
			
		||||
            canTrumpet = !canTrumpet;
 | 
			
		||||
            print("Q");
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown(KeyCode.W)) {
 | 
			
		||||
            canTambourine = !canTambourine;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown(KeyCode.E)) {
 | 
			
		||||
            canClarinet = !canClarinet;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown(KeyCode.R)) {
 | 
			
		||||
            canCymbal = !canCymbal;
 | 
			
		||||
        }
 | 
			
		||||
    public void RespawnPlayer() {
 | 
			
		||||
        ToggleDeathCanvas();
 | 
			
		||||
        Instantiate(player, spawnPoint.transform.position, spawnPoint.transform.rotation);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        if (Input.GetKeyDown("1")) {
 | 
			
		||||
            currentState = PlayerStates.Idle;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("2")) {
 | 
			
		||||
            currentState = PlayerStates.Running;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("3")) {
 | 
			
		||||
            currentState = PlayerStates.Jumping;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("4")) {
 | 
			
		||||
            currentState = PlayerStates.Falling;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("5")) {
 | 
			
		||||
            currentState = PlayerStates.TrumpetJumping;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("6")) {
 | 
			
		||||
            currentState = PlayerStates.TambourineThrowing;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("7")) {
 | 
			
		||||
            currentState = PlayerStates.SpiderGrappling;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("8")) {
 | 
			
		||||
            currentState = PlayerStates.ClarinetDiving;
 | 
			
		||||
        }
 | 
			
		||||
        if (Input.GetKeyDown("9")) {
 | 
			
		||||
            currentState = PlayerStates.CymbalParrying;
 | 
			
		||||
        }
 | 
			
		||||
    public void ToggleDeathCanvas() {
 | 
			
		||||
        deathCanvas.SetActive(!deathCanvas.activeSelf);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: 73653b02e42804d288eaaf881c511225
 | 
			
		||||
guid: 5b4a4ba989308490cb0458966a0e981c
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
 
 | 
			
		||||
@@ -51,6 +51,7 @@ public class Tutorial_GrapplingGun : MonoBehaviour {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    void Start() {
 | 
			
		||||
        m_camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
 | 
			
		||||
        grappleRope.enabled = false;
 | 
			
		||||
        m_springJoint2D.enabled = false;
 | 
			
		||||
        m_distanceJoint2D.distance = targetDistance + .5f;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user