Merge branch 'master' of https://gitlab.nicholasnovak.io/fums/ofb
This commit is contained in:
		
							
								
								
									
										25
									
								
								Assets/Scripts/Bouncepad.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								Assets/Scripts/Bouncepad.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
 | 
			
		||||
public class Bouncepad : MonoBehaviour
 | 
			
		||||
{
 | 
			
		||||
    public enum Facing
 | 
			
		||||
    {
 | 
			
		||||
        Left,
 | 
			
		||||
        Right,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [SerializeField]
 | 
			
		||||
    Facing bounceDirection = Facing.Left;
 | 
			
		||||
 | 
			
		||||
    [SerializeField]
 | 
			
		||||
    public float bounceForce = 20f;
 | 
			
		||||
    [SerializeField]
 | 
			
		||||
    public float verticalModifier = 1.0f;
 | 
			
		||||
 | 
			
		||||
    public Facing Direction()
 | 
			
		||||
    {
 | 
			
		||||
        return this.bounceDirection;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								Assets/Scripts/Bouncepad.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								Assets/Scripts/Bouncepad.cs.meta
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: 1f75445772cf608f6a46acd7fd8dd323
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
  defaultReferences: []
 | 
			
		||||
  executionOrder: 0
 | 
			
		||||
  icon: {instanceID: 0}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
@@ -6,10 +6,18 @@ using TMPro;
 | 
			
		||||
 | 
			
		||||
public class DebugSceneSwitcher : MonoBehaviour
 | 
			
		||||
{
 | 
			
		||||
    public static DebugSceneSwitcher Instance = null;
 | 
			
		||||
 | 
			
		||||
    public bool showDropdown;
 | 
			
		||||
 | 
			
		||||
    void Awake()
 | 
			
		||||
    {
 | 
			
		||||
        if (Instance == null) {
 | 
			
		||||
            Instance = this;
 | 
			
		||||
        } else {
 | 
			
		||||
            Destroy(this.gameObject);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        // Keep the object around when we switch scenes
 | 
			
		||||
        DontDestroyOnLoad(this.gameObject);
 | 
			
		||||
        CreateDropdownOptions();
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,9 @@ public class DialogBoxes : MonoBehaviour
 | 
			
		||||
    [SerializeField] Image backgroundImageObject;
 | 
			
		||||
    [SerializeField] Sprite[] images;
 | 
			
		||||
 | 
			
		||||
    [Header("Buttons:")]
 | 
			
		||||
    [SerializeField] GameObject backToMenuButton;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // Start is called before the first frame update
 | 
			
		||||
    void Start()
 | 
			
		||||
@@ -37,7 +40,11 @@ public class DialogBoxes : MonoBehaviour
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        { // no more dialog messages, advance the scene
 | 
			
		||||
            SceneController.Instance.NextScene();
 | 
			
		||||
            if (backToMenuButton != null) {
 | 
			
		||||
                backToMenuButton.SetActive(true);
 | 
			
		||||
            } else {
 | 
			
		||||
                SceneController.Instance.NextScene();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,7 @@ public class EnemyPatrol : MonoBehaviour {
 | 
			
		||||
    [Header("General")]
 | 
			
		||||
    public float moveSpeed;
 | 
			
		||||
    Animator animator;
 | 
			
		||||
    public bool isPlayingDefeatAnimation = false;
 | 
			
		||||
 | 
			
		||||
    void Awake() {
 | 
			
		||||
        animator = GetComponent<Animator>();
 | 
			
		||||
@@ -73,11 +74,13 @@ public class EnemyPatrol : MonoBehaviour {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    IEnumerator Defeat() {
 | 
			
		||||
        isPlayingDefeatAnimation = true;
 | 
			
		||||
        this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
 | 
			
		||||
        animator.Play("Explosion");
 | 
			
		||||
        this.gameObject.GetComponent<AudioSource>().Play();
 | 
			
		||||
        yield return new WaitForSeconds(animator.GetCurrentAnimatorStateInfo(0).length);
 | 
			
		||||
        this.gameObject.GetComponent<BoxCollider2D>().enabled = true;
 | 
			
		||||
        isPlayingDefeatAnimation = false;
 | 
			
		||||
        this.gameObject.SetActive(false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,21 +10,26 @@ public class GameUIController : MonoBehaviour
 | 
			
		||||
    public GameObject trumpetBackground;
 | 
			
		||||
    public GameObject tambourineBackground;
 | 
			
		||||
    public GameObject clarinetBackground;
 | 
			
		||||
    public GameObject cymbalBackground;
 | 
			
		||||
    [HideInInspector] public GameObject trumpetUI;
 | 
			
		||||
    [HideInInspector] public GameObject tambourineUI;
 | 
			
		||||
    [HideInInspector] public GameObject clarinetUI;
 | 
			
		||||
    [HideInInspector] public GameObject cymbalUI;
 | 
			
		||||
 | 
			
		||||
    void Awake()
 | 
			
		||||
    {
 | 
			
		||||
        this.trumpetUI = trumpetBackground.transform.GetChild(0).gameObject;
 | 
			
		||||
        this.tambourineUI = tambourineBackground.transform.GetChild(0).gameObject;
 | 
			
		||||
        this.clarinetUI = clarinetBackground.transform.GetChild(0).gameObject;
 | 
			
		||||
        this.cymbalUI = this.cymbalBackground.transform.GetChild(0).gameObject;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void Start() {
 | 
			
		||||
    void Start()
 | 
			
		||||
    {
 | 
			
		||||
        this.trumpetBackground.SetActive(StateController.Instance.HasTrumpet());
 | 
			
		||||
        this.tambourineBackground.SetActive(StateController.Instance.HasTambourine());
 | 
			
		||||
        this.clarinetBackground.SetActive(StateController.Instance.HasClarinet());
 | 
			
		||||
        this.cymbalBackground.SetActive(StateController.Instance.HasCymbal());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void ToggleTrumpet(bool toggleState)
 | 
			
		||||
@@ -54,10 +59,20 @@ public class GameUIController : MonoBehaviour
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void ToggleCymbal(bool toggleState)
 | 
			
		||||
    {
 | 
			
		||||
        bool curEnabled = cymbalUI.GetComponent<Image>().enabled;
 | 
			
		||||
        if (curEnabled != toggleState)
 | 
			
		||||
        {
 | 
			
		||||
            cymbalUI.GetComponent<Image>().enabled = toggleState;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void UpdateInstrumentUI()
 | 
			
		||||
    {
 | 
			
		||||
        this.ToggleTrumpet(StateController.Instance.HasTrumpet());
 | 
			
		||||
        this.ToggleTambourine(StateController.Instance.HasTambourine());
 | 
			
		||||
        this.ToggleClarinet(StateController.Instance.HasClarinet());
 | 
			
		||||
        this.ToggleCymbal(StateController.Instance.HasCymbal());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -31,6 +31,10 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
    Vector2 dashVec;
 | 
			
		||||
    private bool lowSpeed = false;
 | 
			
		||||
 | 
			
		||||
    [Header("Cymbals:")]
 | 
			
		||||
    private float cymbalActiveTime = 0f;
 | 
			
		||||
    [SerializeField] AudioSource cymbalAudio;
 | 
			
		||||
 | 
			
		||||
    [Header("Grappling:")]
 | 
			
		||||
    [SerializeField] public Tutorial_GrapplingGun grapplingGun;
 | 
			
		||||
    [SerializeField] public Tutorial_GrapplingRope grapplingRope;
 | 
			
		||||
@@ -72,6 +76,12 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
 | 
			
		||||
    void Update()
 | 
			
		||||
    {
 | 
			
		||||
        if (this.cymbalActiveTime < 0)
 | 
			
		||||
        {
 | 
			
		||||
            this.gameUI.ToggleCymbal(true);
 | 
			
		||||
        }
 | 
			
		||||
        this.cymbalActiveTime -= Time.deltaTime;
 | 
			
		||||
 | 
			
		||||
        unlockedTambourine = StateController.Instance.HasTambourine();
 | 
			
		||||
        if (playerIsAlive)
 | 
			
		||||
        {
 | 
			
		||||
@@ -123,6 +133,7 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
            else if (!isInWater)
 | 
			
		||||
            {
 | 
			
		||||
                isDash = false;
 | 
			
		||||
 | 
			
		||||
                currentDash = 0.0f;
 | 
			
		||||
                _rb.AddForce(-(dashVec), ForceMode2D.Impulse);
 | 
			
		||||
                dashVec = Vector2.zero;
 | 
			
		||||
@@ -134,6 +145,22 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
                dashVec = Vector2.zero;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (StateController.Instance.HasCymbal())
 | 
			
		||||
        {
 | 
			
		||||
            if (this.playerInput.actions["CymbalCrash"].WasPressedThisFrame())
 | 
			
		||||
            {
 | 
			
		||||
                // Play the sound
 | 
			
		||||
                this.gameUI.ToggleCymbal(false);
 | 
			
		||||
                // this.audioSource.clip = cymbalSound;
 | 
			
		||||
                // this.audioSource.loop = false;
 | 
			
		||||
                // this.audioSource.Play();
 | 
			
		||||
                cymbalAudio.Play();
 | 
			
		||||
 | 
			
		||||
                // Set the cymbal active for the equivalent of one second
 | 
			
		||||
                this.cymbalActiveTime = 1;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void Animate()
 | 
			
		||||
@@ -239,13 +266,13 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
    void Bounce()
 | 
			
		||||
    {
 | 
			
		||||
        Vector2 reflect;
 | 
			
		||||
        if(lowSpeed)
 | 
			
		||||
        if (lowSpeed)
 | 
			
		||||
        {
 | 
			
		||||
            reflect = new Vector2(saveVelocity.x,-(saveVelocity.y) * 0.75f);
 | 
			
		||||
            reflect = new Vector2(saveVelocity.x, -(saveVelocity.y) * 0.75f);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            reflect = new Vector2(saveVelocity.x,-(saveVelocity.y) * bonk);
 | 
			
		||||
            reflect = new Vector2(saveVelocity.x, -(saveVelocity.y) * bonk);
 | 
			
		||||
        }
 | 
			
		||||
        _rb.AddForce(reflect, ForceMode2D.Impulse);
 | 
			
		||||
        reflect = Vector2.zero;
 | 
			
		||||
@@ -291,6 +318,28 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
            isInWater = true;
 | 
			
		||||
            Water();
 | 
			
		||||
        }
 | 
			
		||||
        else if (col.tag == "bouncePad")
 | 
			
		||||
        {
 | 
			
		||||
            // Assign the player's velocity to zero so that the player can 
 | 
			
		||||
            // bounce on the same jump pad
 | 
			
		||||
            this.playerController.RB.velocity = Vector2.zero;
 | 
			
		||||
            Bouncepad pad = col.GetComponent<Bouncepad>();
 | 
			
		||||
            switch (pad.Direction())
 | 
			
		||||
            {
 | 
			
		||||
                case Bouncepad.Facing.Left:
 | 
			
		||||
                    this.playerController.RB.AddForce(
 | 
			
		||||
                        new Vector2(-pad.bounceForce, pad.verticalModifier * pad.bounceForce),
 | 
			
		||||
                        ForceMode2D.Impulse
 | 
			
		||||
                        );
 | 
			
		||||
                    break;
 | 
			
		||||
                case Bouncepad.Facing.Right:
 | 
			
		||||
                    this.playerController.RB.AddForce(
 | 
			
		||||
                        new Vector2(pad.bounceForce, pad.verticalModifier * pad.bounceForce),
 | 
			
		||||
                        ForceMode2D.Impulse
 | 
			
		||||
                        );
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void OnTriggerExit2D(Collider2D col)
 | 
			
		||||
@@ -331,7 +380,19 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
        else if (collision.gameObject.tag == "Projectile")
 | 
			
		||||
        {
 | 
			
		||||
            Destroy(collision.gameObject);
 | 
			
		||||
            StartCoroutine(DestroyPlayer());
 | 
			
		||||
            if (this.cymbalActiveTime > 0)
 | 
			
		||||
            {
 | 
			
		||||
                Vector2 projVel = collision.gameObject.GetComponent<Rigidbody2D>().velocity;
 | 
			
		||||
                collision.gameObject.GetComponent<Rigidbody2D>().velocity =
 | 
			
		||||
                  new Vector2(
 | 
			
		||||
                      -projVel.x,
 | 
			
		||||
                      -projVel.y
 | 
			
		||||
                    );
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                StartCoroutine(DestroyPlayer());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //stupid stuff for claude's house
 | 
			
		||||
        else if (collision.gameObject.tag == "SirJacques")
 | 
			
		||||
@@ -366,7 +427,8 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
 | 
			
		||||
            // this.stateController.SetDeathCanvasActive(true);
 | 
			
		||||
 | 
			
		||||
            if (grapplingRope.isGrappling) {
 | 
			
		||||
            if (grapplingRope.isGrappling)
 | 
			
		||||
            {
 | 
			
		||||
                LetGoOfGrapple();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,11 @@ public class SceneController : MonoBehaviour
 | 
			
		||||
        {
 | 
			
		||||
            Instance = this;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            Destroy(this.gameObject);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        // Make this object stay around when switching scenes
 | 
			
		||||
        DontDestroyOnLoad(this.gameObject);
 | 
			
		||||
        SceneManager.sceneLoaded += OnSceneLoaded;
 | 
			
		||||
@@ -26,13 +31,22 @@ public class SceneController : MonoBehaviour
 | 
			
		||||
        GameObject pauseMenu = GameObject.Find("PauseMenuCanvas");
 | 
			
		||||
        if (pauseMenu != null)
 | 
			
		||||
        {
 | 
			
		||||
            Button quitButton = GameObject.Find("QuitButton").GetComponent<Button>();
 | 
			
		||||
            quitButton.onClick.AddListener(BackToMainMenu);
 | 
			
		||||
            // Button quitButton = GameObject.Find("QuitButton").GetComponent<Button>();
 | 
			
		||||
            // quitButton.onClick.AddListener(BackToMainMenu);
 | 
			
		||||
        }
 | 
			
		||||
        if (scene.buildIndex == 0)
 | 
			
		||||
        { // if this is the menu
 | 
			
		||||
            GameObject.Find("NewGameButton").GetComponent<Button>().onClick.AddListener(NextScene);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // if this is the last scene
 | 
			
		||||
        if (scene.buildIndex == (SceneManager.sceneCountInBuildSettings - 1)) {
 | 
			
		||||
            GameObject backToMenuButton = GameObject.Find("BackToMenuButton");
 | 
			
		||||
            if (backToMenuButton != null) {
 | 
			
		||||
                backToMenuButton.GetComponent<Button>().onClick.AddListener(delegate{LoadChosenScene(0);});
 | 
			
		||||
                backToMenuButton.SetActive(false);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void NextScene()
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,9 @@ public class StateController : MonoBehaviour
 | 
			
		||||
        if (Instance == null)
 | 
			
		||||
        {
 | 
			
		||||
            Instance = this;
 | 
			
		||||
        } else {
 | 
			
		||||
            Destroy(this.gameObject);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        DontDestroyOnLoad(this.gameObject);
 | 
			
		||||
        SceneManager.sceneLoaded += OnSceneLoaded;
 | 
			
		||||
@@ -102,6 +105,8 @@ public class StateController : MonoBehaviour
 | 
			
		||||
        {
 | 
			
		||||
            Button resumeButton = GameObject.Find("ResumeButton").GetComponent<Button>();
 | 
			
		||||
            resumeButton.onClick.AddListener(Unpause);
 | 
			
		||||
            Button quitButton = GameObject.Find("QuitButton").GetComponent<Button>();
 | 
			
		||||
            quitButton.onClick.AddListener(SceneController.Instance.BackToMainMenu);
 | 
			
		||||
            TogglePauseMenu(false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -180,7 +185,9 @@ public class StateController : MonoBehaviour
 | 
			
		||||
 | 
			
		||||
    void TogglePauseMenu(bool showPauseMenu)
 | 
			
		||||
    {
 | 
			
		||||
        pauseMenuCanvas.SetActive(showPauseMenu);
 | 
			
		||||
        if (pauseMenuCanvas != null) {
 | 
			
		||||
            pauseMenuCanvas.SetActive(showPauseMenu);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void RespawnPlayer()
 | 
			
		||||
@@ -196,6 +203,9 @@ public class StateController : MonoBehaviour
 | 
			
		||||
    {
 | 
			
		||||
        foreach (GameObject enemy in enemiesInScene)
 | 
			
		||||
        {
 | 
			
		||||
            if (enemy.GetComponent<EnemyPatrol>().isPlayingDefeatAnimation) {
 | 
			
		||||
                enemy.SetActive(false);
 | 
			
		||||
            }
 | 
			
		||||
            enemy.SetActive(true);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user