blocking in some more tile stuff!
This commit is contained in:
parent
075b140ac1
commit
09758c732c
File diff suppressed because it is too large
Load Diff
@ -914,7 +914,7 @@ PrefabInstance:
|
|||||||
m_Modifications:
|
m_Modifications:
|
||||||
- target: {fileID: 2527389465697474493, guid: ff99a7d0beeca415e911378b9b377de4, type: 3}
|
- target: {fileID: 2527389465697474493, guid: ff99a7d0beeca415e911378b9b377de4, type: 3}
|
||||||
propertyPath: showDropdown
|
propertyPath: showDropdown
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3422388587178177106, guid: ff99a7d0beeca415e911378b9b377de4, type: 3}
|
- target: {fileID: 3422388587178177106, guid: ff99a7d0beeca415e911378b9b377de4, type: 3}
|
||||||
propertyPath: m_Pivot.x
|
propertyPath: m_Pivot.x
|
||||||
|
@ -57,8 +57,8 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
AudioSource audioSource;
|
AudioSource audioSource;
|
||||||
|
|
||||||
|
|
||||||
void Awake()
|
void Awake() {
|
||||||
{ // initialize
|
// initialize
|
||||||
_rb = GetComponent<Rigidbody2D>();
|
_rb = GetComponent<Rigidbody2D>();
|
||||||
|
|
||||||
gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent<GameUIController>();
|
gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent<GameUIController>();
|
||||||
@ -72,54 +72,44 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
playerIsAlive = true;
|
playerIsAlive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start() {
|
||||||
{
|
|
||||||
gameUI.UpdateInstrumentUI();
|
gameUI.UpdateInstrumentUI();
|
||||||
currentDash = dashTime;
|
currentDash = dashTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update() {
|
||||||
{
|
if (playerIsAlive) {
|
||||||
if (playerIsAlive)
|
if (this.cymbalActiveTime < 0) {
|
||||||
{
|
|
||||||
if (this.cymbalActiveTime < 0)
|
|
||||||
{
|
|
||||||
this.gameUI.ToggleCymbal(true);
|
this.gameUI.ToggleCymbal(true);
|
||||||
}
|
}
|
||||||
this.cymbalActiveTime -= Time.deltaTime;
|
this.cymbalActiveTime -= Time.deltaTime;
|
||||||
|
|
||||||
// throw tambourine
|
// throw tambourine
|
||||||
unlockedTambourine = StateController.Instance.HasTambourine();
|
unlockedTambourine = StateController.Instance.HasTambourine();
|
||||||
if (playerInput.actions["ThrowTambourine"].WasPressedThisFrame())
|
if (playerInput.actions["ThrowTambourine"].WasPressedThisFrame()) {
|
||||||
{
|
|
||||||
ThrowTambourine();
|
ThrowTambourine();
|
||||||
}
|
}
|
||||||
|
|
||||||
// grapple
|
// grapple
|
||||||
tambourine = GameObject.FindGameObjectWithTag("tambourine");
|
tambourine = GameObject.FindGameObjectWithTag("tambourine");
|
||||||
if (playerInput.actions["Grapple"].WasPressedThisFrame())
|
if (playerInput.actions["Grapple"].WasPressedThisFrame()) {
|
||||||
{
|
|
||||||
AttemptGrapple();
|
AttemptGrapple();
|
||||||
}
|
}
|
||||||
if (playerInput.actions["Grapple"].WasReleasedThisFrame() && grapplingRope.isGrappling)
|
if (playerInput.actions["Grapple"].WasReleasedThisFrame() && grapplingRope.isGrappling) {
|
||||||
{
|
|
||||||
LetGoOfGrapple();
|
LetGoOfGrapple();
|
||||||
}
|
}
|
||||||
|
|
||||||
// clarinet
|
// clarinet
|
||||||
unlockedClarinet = StateController.Instance.HasClarinet();
|
unlockedClarinet = StateController.Instance.HasClarinet();
|
||||||
if (unlockedClarinet)
|
if (unlockedClarinet) {
|
||||||
{
|
if (playerInput.actions["ClarinetDive"].WasPressedThisFrame() && !isInWater && !playerController.IsGrounded() && !isDash) {
|
||||||
if (playerInput.actions["ClarinetDive"].WasPressedThisFrame() && !isInWater && !playerController.IsGrounded() && !isDash)
|
|
||||||
{
|
|
||||||
isDash = true;
|
isDash = true;
|
||||||
this.gameUI.ToggleClarinet(false);
|
this.gameUI.ToggleClarinet(false);
|
||||||
playerInput.DeactivateInput();
|
playerInput.DeactivateInput();
|
||||||
currentDash = 0.0f;
|
currentDash = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!playerController.IsGrounded() && isDash && (currentDash < dashTime))
|
if (!playerController.IsGrounded() && isDash && (currentDash < dashTime)) {
|
||||||
{
|
|
||||||
if (!forceAdded) {
|
if (!forceAdded) {
|
||||||
dashVec = new Vector2(1f * forward, -1f) * dashForce;
|
dashVec = new Vector2(1f * forward, -1f) * dashForce;
|
||||||
_rb.AddForce(dashVec, ForceMode2D.Impulse);
|
_rb.AddForce(dashVec, ForceMode2D.Impulse);
|
||||||
@ -128,8 +118,8 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
|
|
||||||
currentDash += Time.deltaTime;
|
currentDash += Time.deltaTime;
|
||||||
}
|
}
|
||||||
else if ((currentDash >= dashTime)) // dash ends
|
else if ((currentDash >= dashTime)) {
|
||||||
{
|
// dash ends
|
||||||
if (!isInWater) {
|
if (!isInWater) {
|
||||||
isDash = false;
|
isDash = false;
|
||||||
this.gameUI.ToggleClarinet(true);
|
this.gameUI.ToggleClarinet(true);
|
||||||
@ -150,10 +140,8 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StateController.Instance.HasCymbal())
|
if (StateController.Instance.HasCymbal()) {
|
||||||
{
|
if (this.playerInput.actions["CymbalCrash"].WasPressedThisFrame()) {
|
||||||
if (this.playerInput.actions["CymbalCrash"].WasPressedThisFrame())
|
|
||||||
{
|
|
||||||
// Play the sound
|
// Play the sound
|
||||||
this.gameUI.ToggleCymbal(false);
|
this.gameUI.ToggleCymbal(false);
|
||||||
// this.audioSource.clip = cymbalSound;
|
// this.audioSource.clip = cymbalSound;
|
||||||
@ -170,35 +158,28 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animate()
|
void Animate() {
|
||||||
{
|
|
||||||
// start walking
|
// start walking
|
||||||
if (playerInput.actions["Move"].WasPressedThisFrame())
|
if (playerInput.actions["Move"].WasPressedThisFrame()) {
|
||||||
{
|
|
||||||
animator.SetBool("Walking", true);
|
animator.SetBool("Walking", true);
|
||||||
}
|
}
|
||||||
// return to idle animation
|
// return to idle animation
|
||||||
if (playerInput.actions["Move"].WasReleasedThisFrame())
|
if (playerInput.actions["Move"].WasReleasedThisFrame()) {
|
||||||
{
|
|
||||||
animator.SetBool("Walking", false);
|
animator.SetBool("Walking", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnMove(InputValue value)
|
void OnMove(InputValue value) {
|
||||||
{
|
if (playerIsAlive) {
|
||||||
if (playerIsAlive)
|
|
||||||
{
|
|
||||||
_hInput = value.Get<Vector2>().x;
|
_hInput = value.Get<Vector2>().x;
|
||||||
if (_hInput < 0)
|
if (_hInput < 0) {
|
||||||
{
|
if (forward != -1) {
|
||||||
if (forward != -1)
|
// if character hasnt already flipped
|
||||||
{ // if character hasnt already flipped
|
|
||||||
FlipRenderer();
|
FlipRenderer();
|
||||||
}
|
}
|
||||||
forward = -1;
|
forward = -1;
|
||||||
}
|
}
|
||||||
else if (_hInput > 0)
|
else if (_hInput > 0) {
|
||||||
{
|
|
||||||
if (forward != 1)
|
if (forward != 1)
|
||||||
{ // if character hasnt already flipped
|
{ // if character hasnt already flipped
|
||||||
FlipRenderer();
|
FlipRenderer();
|
||||||
@ -209,69 +190,54 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlipRenderer()
|
void FlipRenderer() {
|
||||||
{
|
|
||||||
GetComponent<SpriteRenderer>().flipX = !GetComponent<SpriteRenderer>().flipX;
|
GetComponent<SpriteRenderer>().flipX = !GetComponent<SpriteRenderer>().flipX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThrowTambourine()
|
void ThrowTambourine() {
|
||||||
{
|
if (unlockedTambourine && hasTambourine && !grapplingRope.isGrappling) {
|
||||||
if (unlockedTambourine && hasTambourine && !grapplingRope.isGrappling)
|
|
||||||
{
|
|
||||||
launcher.ThrowTambourine(forward);
|
launcher.ThrowTambourine(forward);
|
||||||
SetHasTambourine(false);
|
SetHasTambourine(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHasTambourine(bool state)
|
public void SetHasTambourine(bool state) {
|
||||||
{
|
|
||||||
hasTambourine = state;
|
hasTambourine = state;
|
||||||
gameUI.ToggleTambourine(state);
|
gameUI.ToggleTambourine(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttemptGrapple()
|
void AttemptGrapple() {
|
||||||
{
|
if (tambourine != null) { // grapple to tambourine
|
||||||
if (tambourine != null)
|
if (!grapplingRope.isGrappling && tambourine.GetComponent<TambourineBehavior>().pinned) {
|
||||||
{ // grapple to tambourine
|
|
||||||
if (!grapplingRope.isGrappling && tambourine.GetComponent<TambourineBehavior>().pinned)
|
|
||||||
{
|
|
||||||
grapplingGun.GrappleToTambourine(tambourine);
|
grapplingGun.GrappleToTambourine(tambourine);
|
||||||
grapplingRope.isGrappling = true;
|
grapplingRope.isGrappling = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (grappleSurface != null) {
|
||||||
if (grappleSurface != null)
|
|
||||||
{
|
|
||||||
grapplingGun.GrappleToSurface(grappleSurface.transform.position);
|
grapplingGun.GrappleToSurface(grappleSurface.transform.position);
|
||||||
grapplingRope.isGrappling = true;
|
grapplingRope.isGrappling = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LetGoOfGrapple()
|
void LetGoOfGrapple() {
|
||||||
{
|
|
||||||
bool currentlyPaused = StateController.Instance.isPaused;
|
bool currentlyPaused = StateController.Instance.isPaused;
|
||||||
if (grapplingRope.isGrappling && !currentlyPaused)
|
if (grapplingRope.isGrappling && !currentlyPaused) {
|
||||||
{
|
|
||||||
print("currently paused is " + currentlyPaused + ", releasing grapple");
|
print("currently paused is " + currentlyPaused + ", releasing grapple");
|
||||||
if (tambourine != null)
|
if (tambourine != null) {
|
||||||
{
|
|
||||||
tambourine.GetComponent<TambourineBehavior>().DestroySelf();
|
tambourine.GetComponent<TambourineBehavior>().DestroySelf();
|
||||||
}
|
}
|
||||||
grapplingGun.ReleaseGrapple();
|
grapplingGun.ReleaseGrapple();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bounce()
|
void Bounce() {
|
||||||
{
|
|
||||||
Vector2 reflect;
|
Vector2 reflect;
|
||||||
if (Mathf.Abs(saveVelocity.y) < 1f && hasBounced)
|
if (Mathf.Abs(saveVelocity.y) < 1f && hasBounced) {
|
||||||
{
|
|
||||||
reflect = Vector2.zero;
|
reflect = Vector2.zero;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
reflect = new Vector2(saveVelocity.x * reflectForce, -(saveVelocity.y) * reflectForce);
|
reflect = new Vector2(saveVelocity.x * reflectForce, -(saveVelocity.y) * reflectForce);
|
||||||
//reflect = new Vector2(saveVelocity.x * 1.1f, -(saveVelocity.y) * reflectForce);
|
//reflect = new Vector2(saveVelocity.x * 1.1f, -(saveVelocity.y) * reflectForce);
|
||||||
hasBounced = true;
|
hasBounced = true;
|
||||||
@ -281,57 +247,46 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
isDash = false;
|
isDash = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Water()
|
void Water() {
|
||||||
{
|
|
||||||
print("water dash " + isDash);
|
print("water dash " + isDash);
|
||||||
if(isDash)
|
if(isDash) {
|
||||||
{
|
|
||||||
saveVelocity = _rb.velocity / velocityCut;
|
saveVelocity = _rb.velocity / velocityCut;
|
||||||
if (isDash) {
|
if (isDash) {
|
||||||
dashVec = new Vector2(1f * forward, -1f) * (dashForce / velocityCut);
|
dashVec = new Vector2(1f * forward, -1f) * (dashForce / velocityCut);
|
||||||
_rb.AddForce(dashVec, ForceMode2D.Force);
|
_rb.AddForce(dashVec, ForceMode2D.Force);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
playerController.FloatGravity(waterGravity);
|
playerController.FloatGravity(waterGravity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTriggerEnter2D(Collider2D col)
|
void OnTriggerEnter2D(Collider2D col) {
|
||||||
{
|
if (col.tag == "grappleSurface") {
|
||||||
if (col.tag == "grappleSurface")
|
|
||||||
{
|
|
||||||
grappleSurface = col.gameObject;
|
grappleSurface = col.gameObject;
|
||||||
}
|
}
|
||||||
else if (col.tag == "instaDeath")
|
else if (col.tag == "instaDeath") {
|
||||||
{
|
|
||||||
print("player fell in spikes");
|
print("player fell in spikes");
|
||||||
StartCoroutine(DestroyPlayer());
|
StartCoroutine(DestroyPlayer());
|
||||||
}
|
}
|
||||||
else if (col.tag == "spawnPoint")
|
else if (col.tag == "spawnPoint") {
|
||||||
{
|
|
||||||
StateController.Instance.spawnPoint.GetComponent<SpawnPointBehavior>().DeactivateSpawnPoint();
|
StateController.Instance.spawnPoint.GetComponent<SpawnPointBehavior>().DeactivateSpawnPoint();
|
||||||
col.GetComponent<SpawnPointBehavior>().ActivateSpawnPoint();
|
col.GetComponent<SpawnPointBehavior>().ActivateSpawnPoint();
|
||||||
}
|
}
|
||||||
else if (col.tag == "Trumpet")
|
else if (col.tag == "Trumpet") {
|
||||||
{
|
|
||||||
this.playerController.in_range = true;
|
this.playerController.in_range = true;
|
||||||
this.playerController.enemy = col.transform.parent.gameObject;
|
this.playerController.enemy = col.transform.parent.gameObject;
|
||||||
}
|
}
|
||||||
else if (col.tag == "water")
|
else if (col.tag == "water") {
|
||||||
{
|
|
||||||
isInWater = true;
|
isInWater = true;
|
||||||
Water();
|
Water();
|
||||||
}
|
}
|
||||||
else if (col.tag == "bouncePad")
|
else if (col.tag == "bouncePad") {
|
||||||
{
|
|
||||||
// Assign the player's velocity to zero so that the player can
|
// Assign the player's velocity to zero so that the player can
|
||||||
// bounce on the same jump pad
|
// bounce on the same jump pad
|
||||||
this.playerController.RB.velocity = Vector2.zero;
|
this.playerController.RB.velocity = Vector2.zero;
|
||||||
Bouncepad pad = col.GetComponent<Bouncepad>();
|
Bouncepad pad = col.GetComponent<Bouncepad>();
|
||||||
switch (pad.Direction())
|
switch (pad.Direction()) {
|
||||||
{
|
|
||||||
case Bouncepad.Facing.Left:
|
case Bouncepad.Facing.Left:
|
||||||
this.playerController.RB.AddForce(
|
this.playerController.RB.AddForce(
|
||||||
new Vector2(-pad.bounceForce, pad.verticalModifier * pad.bounceForce),
|
new Vector2(-pad.bounceForce, pad.verticalModifier * pad.bounceForce),
|
||||||
@ -348,19 +303,15 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTriggerExit2D(Collider2D col)
|
void OnTriggerExit2D(Collider2D col) {
|
||||||
{
|
if (col.tag == "grappleSurface") {
|
||||||
if (col.tag == "grappleSurface")
|
|
||||||
{
|
|
||||||
grappleSurface = null;
|
grappleSurface = null;
|
||||||
}
|
}
|
||||||
else if (col.tag == "Trumpet")
|
else if (col.tag == "Trumpet") {
|
||||||
{
|
|
||||||
this.playerController.in_range = false;
|
this.playerController.in_range = false;
|
||||||
this.playerController.enemy = null;
|
this.playerController.enemy = null;
|
||||||
}
|
}
|
||||||
else if (col.tag == "water")
|
else if (col.tag == "water") {
|
||||||
{
|
|
||||||
isInWater = false;
|
isInWater = false;
|
||||||
isDash = false;
|
isDash = false;
|
||||||
hasBounced = false;
|
hasBounced = false;
|
||||||
@ -370,26 +321,20 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCollisionEnter2D(Collision2D collision)
|
void OnCollisionEnter2D(Collision2D collision) {
|
||||||
{
|
if (collision.gameObject.tag == "Enemy" || collision.gameObject.tag == "ProjectileEnemy") {
|
||||||
if (collision.gameObject.tag == "Enemy" || collision.gameObject.tag == "ProjectileEnemy")
|
if (collision.transform.position.y < transform.position.y) {
|
||||||
{
|
|
||||||
if (collision.transform.position.y < transform.position.y)
|
|
||||||
{
|
|
||||||
_rb.AddForce(Vector2.up * 8, ForceMode2D.Impulse);
|
_rb.AddForce(Vector2.up * 8, ForceMode2D.Impulse);
|
||||||
collision.gameObject.GetComponent<EnemyPatrol>().DefeatEnemy();
|
collision.gameObject.GetComponent<EnemyPatrol>().DefeatEnemy();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
StartCoroutine(DestroyPlayer());
|
StartCoroutine(DestroyPlayer());
|
||||||
print("enemy defeated player");
|
print("enemy defeated player");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (collision.gameObject.tag == "Projectile")
|
else if (collision.gameObject.tag == "Projectile") {
|
||||||
{
|
|
||||||
Destroy(collision.gameObject);
|
Destroy(collision.gameObject);
|
||||||
if (this.cymbalActiveTime > 0)
|
if (this.cymbalActiveTime > 0) {
|
||||||
{
|
|
||||||
Vector2 projVel = collision.gameObject.GetComponent<Rigidbody2D>().velocity;
|
Vector2 projVel = collision.gameObject.GetComponent<Rigidbody2D>().velocity;
|
||||||
collision.gameObject.GetComponent<Rigidbody2D>().velocity =
|
collision.gameObject.GetComponent<Rigidbody2D>().velocity =
|
||||||
new Vector2(
|
new Vector2(
|
||||||
@ -397,30 +342,24 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
-projVel.y
|
-projVel.y
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
StartCoroutine(DestroyPlayer());
|
StartCoroutine(DestroyPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//stupid stuff for claude's house
|
//stupid stuff for claude's house
|
||||||
else if (collision.gameObject.tag == "SirJacques")
|
else if (collision.gameObject.tag == "SirJacques") {
|
||||||
{
|
|
||||||
Destroy(collision.gameObject);
|
Destroy(collision.gameObject);
|
||||||
}
|
}
|
||||||
else if (collision.gameObject.tag == "Door")
|
else if (collision.gameObject.tag == "Door") {
|
||||||
{
|
|
||||||
StateController.Instance.RespawnPlayer();
|
StateController.Instance.RespawnPlayer();
|
||||||
}
|
}
|
||||||
else if (collision.gameObject.tag == "bouncy")
|
else if (collision.gameObject.tag == "bouncy") {
|
||||||
{
|
|
||||||
Bounce();
|
Bounce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator DestroyPlayer()
|
IEnumerator DestroyPlayer() {
|
||||||
{
|
if (playerIsAlive) {
|
||||||
if (playerIsAlive)
|
|
||||||
{
|
|
||||||
print("destroyPlayer called");
|
print("destroyPlayer called");
|
||||||
playerIsAlive = false;
|
playerIsAlive = false;
|
||||||
audioSource.clip = deathSound;
|
audioSource.clip = deathSound;
|
||||||
@ -435,15 +374,13 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
|
|
||||||
// this.stateController.SetDeathCanvasActive(true);
|
// this.stateController.SetDeathCanvasActive(true);
|
||||||
|
|
||||||
if (grapplingRope.isGrappling)
|
if (grapplingRope.isGrappling) {
|
||||||
{
|
|
||||||
LetGoOfGrapple();
|
LetGoOfGrapple();
|
||||||
}
|
}
|
||||||
|
|
||||||
// destroy all tambourines
|
// destroy all tambourines
|
||||||
GameObject[] currentTambourines = GameObject.FindGameObjectsWithTag("tambourine");
|
GameObject[] currentTambourines = GameObject.FindGameObjectsWithTag("tambourine");
|
||||||
foreach (GameObject tambourine in currentTambourines)
|
foreach (GameObject tambourine in currentTambourines) {
|
||||||
{
|
|
||||||
tambourine.GetComponent<TambourineBehavior>().DestroySelf();
|
tambourine.GetComponent<TambourineBehavior>().DestroySelf();
|
||||||
// Destroy(tambourine);
|
// Destroy(tambourine);
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,7 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
[HideInInspector] private GameUIController gameUI;
|
[HideInInspector] private GameUIController gameUI;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void Awake()
|
private void Awake() {
|
||||||
{
|
|
||||||
RB = GetComponent<Rigidbody2D>();
|
RB = GetComponent<Rigidbody2D>();
|
||||||
playerBehavior = this.gameObject.GetComponent<PlayerBehavior>();
|
playerBehavior = this.gameObject.GetComponent<PlayerBehavior>();
|
||||||
grapplingRope = playerBehavior.grapplingRope;
|
grapplingRope = playerBehavior.grapplingRope;
|
||||||
@ -80,35 +79,28 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
trumpetAnimationObject.SetActive(false);
|
trumpetAnimationObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start() {
|
||||||
{
|
|
||||||
SetGravityScale(Data.gravityScale);
|
SetGravityScale(Data.gravityScale);
|
||||||
IsFacingRight = true;
|
IsFacingRight = true;
|
||||||
tempFallSpeed = Data.maxFallSpeed;
|
tempFallSpeed = Data.maxFallSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnMove(InputValue value)
|
void OnMove(InputValue value) {
|
||||||
{
|
if (playerBehavior.playerIsAlive) {
|
||||||
if (playerBehavior.playerIsAlive)
|
|
||||||
{
|
|
||||||
this._moveInput = value.Get<Vector2>();
|
this._moveInput = value.Get<Vector2>();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
this._moveInput = Vector2.zero;
|
this._moveInput = Vector2.zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnJump()
|
void OnJump() {
|
||||||
{
|
if (playerBehavior.playerIsAlive) {
|
||||||
if (playerBehavior.playerIsAlive)
|
|
||||||
{
|
|
||||||
OnJumpInput();
|
OnJumpInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update() {
|
||||||
{
|
|
||||||
unlockedTrumpet = StateController.Instance.HasTrumpet();
|
unlockedTrumpet = StateController.Instance.HasTrumpet();
|
||||||
#region TIMERS
|
#region TIMERS
|
||||||
LastOnGroundTime -= Time.deltaTime;
|
LastOnGroundTime -= Time.deltaTime;
|
||||||
@ -117,36 +109,29 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region COLLISION CHECKS
|
#region COLLISION CHECKS
|
||||||
if (!IsJumping)
|
if (!IsJumping) {
|
||||||
{
|
|
||||||
//Ground Check
|
//Ground Check
|
||||||
if (IsGrounded()) //checks if set box overlaps with ground
|
if (IsGrounded()) {
|
||||||
{
|
//checks if set box overlaps with ground
|
||||||
LastOnGroundTime = Data.coyoteTime; //if so sets the lastGrounded to coyoteTime
|
LastOnGroundTime = Data.coyoteTime; //if so sets the lastGrounded to coyoteTime
|
||||||
if (unlockedTrumpet)
|
if (unlockedTrumpet) {
|
||||||
{
|
|
||||||
trumpet = 1;
|
trumpet = 1;
|
||||||
gameUI.ToggleTrumpet(true);
|
gameUI.ToggleTrumpet(true);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
trumpet = -1;
|
trumpet = -1;
|
||||||
}
|
}
|
||||||
wasGrappling = false;
|
wasGrappling = false;
|
||||||
isRegFalling = false;
|
isRegFalling = false;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// print("not jumping");
|
// print("not jumping");
|
||||||
if (!_isJumpFalling && !isRegFalling)
|
if (!_isJumpFalling && !isRegFalling) {
|
||||||
{
|
if (unlockedTrumpet) {
|
||||||
if (unlockedTrumpet)
|
|
||||||
{
|
|
||||||
trumpet = 1;
|
trumpet = 1;
|
||||||
gameUI.ToggleTrumpet(true);
|
gameUI.ToggleTrumpet(true);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
trumpet = -1;
|
trumpet = -1;
|
||||||
}
|
}
|
||||||
isRegFalling = true;
|
isRegFalling = true;
|
||||||
@ -156,15 +141,13 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region JUMP CHECKS
|
#region JUMP CHECKS
|
||||||
if (IsJumping && RB.velocity.y <= 0)
|
if (IsJumping && RB.velocity.y <= 0) {
|
||||||
{
|
|
||||||
IsJumping = false;
|
IsJumping = false;
|
||||||
// print("isJumping " + IsJumping);
|
// print("isJumping " + IsJumping);
|
||||||
_isJumpFalling = true;
|
_isJumpFalling = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LastOnGroundTime > 0 && !IsJumping)
|
if (LastOnGroundTime > 0 && !IsJumping) {
|
||||||
{
|
|
||||||
_isJumpCut = false;
|
_isJumpCut = false;
|
||||||
|
|
||||||
if (!IsJumping)
|
if (!IsJumping)
|
||||||
@ -173,8 +156,7 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
|
|
||||||
|
|
||||||
//Jump
|
//Jump
|
||||||
if (CanJump() && LastPressedJumpTime > 0)
|
if (CanJump() && LastPressedJumpTime > 0) {
|
||||||
{
|
|
||||||
IsJumping = true;
|
IsJumping = true;
|
||||||
_isJumpCut = false;
|
_isJumpCut = false;
|
||||||
_isJumpFalling = false;
|
_isJumpFalling = false;
|
||||||
@ -185,29 +167,25 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
Jump();
|
Jump();
|
||||||
|
|
||||||
// determine if trumpet jump
|
// determine if trumpet jump
|
||||||
if (!IsGrounded() && in_range && trumpet > 0 && !inCoyoteTime)
|
if (!IsGrounded() && in_range && trumpet > 0 && !inCoyoteTime) {
|
||||||
{
|
|
||||||
StartCoroutine(ActivateTrumpetSprite());
|
StartCoroutine(ActivateTrumpetSprite());
|
||||||
gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
|
gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
|
||||||
enemy.GetComponent<EnemyPatrol>().DefeatEnemy();
|
enemy.GetComponent<EnemyPatrol>().DefeatEnemy();
|
||||||
enemy = null;
|
enemy = null;
|
||||||
in_range = false;
|
in_range = false;
|
||||||
}
|
}
|
||||||
else if (!IsGrounded() && !in_range && trumpet > 0 && !inCoyoteTime)
|
else if (!IsGrounded() && !in_range && trumpet > 0 && !inCoyoteTime) {
|
||||||
{
|
|
||||||
trumpet -= 1;
|
trumpet -= 1;
|
||||||
}
|
}
|
||||||
// check if double jump, play sound
|
// check if double jump, play sound
|
||||||
if (trumpet == 0)
|
if (trumpet == 0) {
|
||||||
{
|
|
||||||
StartCoroutine(ActivateTrumpetSprite());
|
StartCoroutine(ActivateTrumpetSprite());
|
||||||
gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
|
gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop sound if needed
|
// stop sound if needed
|
||||||
if (soundPlaying && (isRegFalling || IsJumping || _isJumpFalling))
|
if (soundPlaying && (isRegFalling || IsJumping || _isJumpFalling)) {
|
||||||
{
|
|
||||||
print("footsteps stop");
|
print("footsteps stop");
|
||||||
audioSource.Stop();
|
audioSource.Stop();
|
||||||
soundPlaying = false;
|
soundPlaying = false;
|
||||||
@ -216,8 +194,7 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
|
|
||||||
#region GRAPPLE CHECKS
|
#region GRAPPLE CHECKS
|
||||||
// set wasGrappling to true if the player starts grappling
|
// set wasGrappling to true if the player starts grappling
|
||||||
if (grapplingRope.isGrappling)
|
if (grapplingRope.isGrappling) {
|
||||||
{
|
|
||||||
wasGrappling = true;
|
wasGrappling = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -228,49 +205,41 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
// {
|
// {
|
||||||
// SetGravityScale(0);
|
// SetGravityScale(0);
|
||||||
// }
|
// }
|
||||||
if (RB.velocity.y < 0 && _moveInput.y < 0)
|
if (RB.velocity.y < 0 && _moveInput.y < 0) {
|
||||||
{
|
|
||||||
//Much higher gravity if holding down
|
//Much higher gravity if holding down
|
||||||
SetGravityScale(Data.gravityScale * Data.fastFallGravityMult);
|
SetGravityScale(Data.gravityScale * Data.fastFallGravityMult);
|
||||||
//Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
|
//Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
|
||||||
RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFastFallSpeed));
|
RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFastFallSpeed));
|
||||||
}
|
}
|
||||||
else if (_isJumpCut)
|
else if (_isJumpCut) {
|
||||||
{
|
|
||||||
//Higher gravity if jump button released
|
//Higher gravity if jump button released
|
||||||
SetGravityScale(Data.gravityScale * Data.jumpCutGravityMult);
|
SetGravityScale(Data.gravityScale * Data.jumpCutGravityMult);
|
||||||
RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
|
RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
|
||||||
}
|
}
|
||||||
else if ((IsJumping || _isJumpFalling) && Mathf.Abs(RB.velocity.y) < Data.jumpHangTimeThreshold)
|
else if ((IsJumping || _isJumpFalling) && Mathf.Abs(RB.velocity.y) < Data.jumpHangTimeThreshold) {
|
||||||
{
|
|
||||||
SetGravityScale(Data.gravityScale * Data.jumpHangGravityMult);
|
SetGravityScale(Data.gravityScale * Data.jumpHangGravityMult);
|
||||||
}
|
}
|
||||||
else if (RB.velocity.y < 0)
|
else if (RB.velocity.y < 0) {
|
||||||
{
|
|
||||||
//Higher gravity if falling
|
//Higher gravity if falling
|
||||||
SetGravityScale(Data.gravityScale * Data.fallGravityMult);
|
SetGravityScale(Data.gravityScale * Data.fallGravityMult);
|
||||||
//Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
|
//Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
|
||||||
RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
|
RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
//Default gravity if standing on a platform or moving upwards
|
//Default gravity if standing on a platform or moving upwards
|
||||||
SetGravityScale(Data.gravityScale);
|
SetGravityScale(Data.gravityScale);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SOUND CHECKS
|
#region SOUND CHECKS
|
||||||
if (!IsJumping && !_isJumpFalling && !isRegFalling && _moveInput.x != 0)
|
if (!IsJumping && !_isJumpFalling && !isRegFalling && _moveInput.x != 0) {
|
||||||
{
|
if (!soundPlaying) {
|
||||||
if (!soundPlaying)
|
|
||||||
{
|
|
||||||
// print("footsteps PLAY");
|
// print("footsteps PLAY");
|
||||||
audioSource.Play();
|
audioSource.Play();
|
||||||
soundPlaying = true;
|
soundPlaying = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (soundPlaying && audioSource.clip.name == "footsteps")
|
else if (soundPlaying && audioSource.clip.name == "footsteps") {
|
||||||
{
|
|
||||||
// print("footsteps stop");
|
// print("footsteps stop");
|
||||||
audioSource.Stop();
|
audioSource.Stop();
|
||||||
soundPlaying = false;
|
soundPlaying = false;
|
||||||
@ -278,43 +247,38 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region UPDATE UI
|
#region UPDATE UI
|
||||||
if (trumpet == 0)
|
if (trumpet == 0) {
|
||||||
{
|
|
||||||
gameUI.ToggleTrumpet(false);
|
gameUI.ToggleTrumpet(false);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate() {
|
||||||
{
|
|
||||||
Run(1);
|
Run(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region INPUT CALLBACKS
|
#region INPUT CALLBACKS
|
||||||
//Methods which whandle input detected in Update()
|
//Methods which whandle input detected in Update()
|
||||||
public void OnJumpInput()
|
public void OnJumpInput() {
|
||||||
{
|
|
||||||
LastPressedJumpTime = Data.jumpInputBufferTime;
|
LastPressedJumpTime = Data.jumpInputBufferTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnJumpUpInput()
|
public void OnJumpUpInput() {
|
||||||
{
|
if (CanJumpCut()) {
|
||||||
if (CanJumpCut())
|
|
||||||
_isJumpCut = true;
|
_isJumpCut = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GENERAL METHODS
|
#region GENERAL METHODS
|
||||||
public void SetGravityScale(float scale)
|
public void SetGravityScale(float scale) {
|
||||||
{
|
|
||||||
RB.gravityScale = scale;
|
RB.gravityScale = scale;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//MOVEMENT METHODS
|
//MOVEMENT METHODS
|
||||||
#region RUN METHODS
|
#region RUN METHODS
|
||||||
private void Run(float lerpAmount)
|
private void Run(float lerpAmount) {
|
||||||
{
|
|
||||||
//Calculate the direction we want to move in and our desired velocity
|
//Calculate the direction we want to move in and our desired velocity
|
||||||
float targetSpeed = _moveInput.x * Data.runMaxSpeed;
|
float targetSpeed = _moveInput.x * Data.runMaxSpeed;
|
||||||
//We can reduce are control using Lerp() this smooths changes to are direction and speed
|
//We can reduce are control using Lerp() this smooths changes to are direction and speed
|
||||||
@ -325,24 +289,20 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
|
|
||||||
//Gets an acceleration value based on if we are accelerating (includes turning)
|
//Gets an acceleration value based on if we are accelerating (includes turning)
|
||||||
//or trying to decelerate (stop). As well as applying a multiplier if we're air borne.
|
//or trying to decelerate (stop). As well as applying a multiplier if we're air borne.
|
||||||
if (LastOnGroundTime > 0)
|
if (LastOnGroundTime > 0) {
|
||||||
{
|
|
||||||
accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? Data.runAccelAmount : Data.runDeccelAmount;
|
accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? Data.runAccelAmount : Data.runDeccelAmount;
|
||||||
}
|
}
|
||||||
else if (wasGrappling)
|
else if (wasGrappling) {
|
||||||
{
|
|
||||||
accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? Data.runAccelAmount * Data.accelInAir : Data.runDeccelAmount * (Data.deccelInAir / 5);
|
accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? Data.runAccelAmount * Data.accelInAir : Data.runDeccelAmount * (Data.deccelInAir / 5);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? Data.runAccelAmount * Data.accelInAir : Data.runDeccelAmount * Data.deccelInAir;
|
accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? Data.runAccelAmount * Data.accelInAir : Data.runDeccelAmount * Data.deccelInAir;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Add Bonus Jump Apex Acceleration
|
#region Add Bonus Jump Apex Acceleration
|
||||||
//Increase are acceleration and maxSpeed when at the apex of their jump, makes the jump feel a bit more bouncy, responsive and natural
|
//Increase are acceleration and maxSpeed when at the apex of their jump, makes the jump feel a bit more bouncy, responsive and natural
|
||||||
if ((IsJumping || _isJumpFalling) && Mathf.Abs(RB.velocity.y) < Data.jumpHangTimeThreshold)
|
if ((IsJumping || _isJumpFalling) && Mathf.Abs(RB.velocity.y) < Data.jumpHangTimeThreshold) {
|
||||||
{
|
|
||||||
accelRate *= Data.jumpHangAccelerationMult;
|
accelRate *= Data.jumpHangAccelerationMult;
|
||||||
targetSpeed *= Data.jumpHangMaxSpeedMult;
|
targetSpeed *= Data.jumpHangMaxSpeedMult;
|
||||||
}
|
}
|
||||||
@ -350,8 +310,7 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
|
|
||||||
#region Conserve Momentum
|
#region Conserve Momentum
|
||||||
//We won't slow the player down if they are moving in their desired direction but at a greater speed than their maxSpeed
|
//We won't slow the player down if they are moving in their desired direction but at a greater speed than their maxSpeed
|
||||||
if ((Data.doConserveMomentum && Mathf.Abs(RB.velocity.x) > Mathf.Abs(targetSpeed) && Mathf.Sign(RB.velocity.x) == Mathf.Sign(targetSpeed) && Mathf.Abs(targetSpeed) > 0.01f && LastOnGroundTime < 0) || grapplingRope.isGrappling)
|
if ((Data.doConserveMomentum && Mathf.Abs(RB.velocity.x) > Mathf.Abs(targetSpeed) && Mathf.Sign(RB.velocity.x) == Mathf.Sign(targetSpeed) && Mathf.Abs(targetSpeed) > 0.01f && LastOnGroundTime < 0) || grapplingRope.isGrappling) {
|
||||||
{
|
|
||||||
//Prevent any deceleration from happening, or in other words conserve are current momentum
|
//Prevent any deceleration from happening, or in other words conserve are current momentum
|
||||||
//You could experiment with allowing for the player to slightly increae their speed whilst in this "state"
|
//You could experiment with allowing for the player to slightly increae their speed whilst in this "state"
|
||||||
accelRate = 0;
|
accelRate = 0;
|
||||||
@ -374,8 +333,7 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Turn()
|
private void Turn() {
|
||||||
{
|
|
||||||
//stores scale and flips the player along the x axis,
|
//stores scale and flips the player along the x axis,
|
||||||
Vector3 scale = transform.localScale;
|
Vector3 scale = transform.localScale;
|
||||||
scale.x *= -1;
|
scale.x *= -1;
|
||||||
@ -386,8 +344,7 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region JUMP METHODS
|
#region JUMP METHODS
|
||||||
private void Jump()
|
private void Jump() {
|
||||||
{
|
|
||||||
//Ensures we can't call Jump multiple times from one press
|
//Ensures we can't call Jump multiple times from one press
|
||||||
LastPressedJumpTime = 0;
|
LastPressedJumpTime = 0;
|
||||||
LastOnGroundTime = 0;
|
LastOnGroundTime = 0;
|
||||||
@ -397,9 +354,9 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
//This means we'll always feel like we jump the same amount
|
//This means we'll always feel like we jump the same amount
|
||||||
//(setting the player's Y velocity to 0 beforehand will likely work the same, but I find this more elegant :D)
|
//(setting the player's Y velocity to 0 beforehand will likely work the same, but I find this more elegant :D)
|
||||||
float force = Data.jumpForce;
|
float force = Data.jumpForce;
|
||||||
if (RB.velocity.y < 0)
|
if (RB.velocity.y < 0) {
|
||||||
force -= RB.velocity.y;
|
force -= RB.velocity.y;
|
||||||
|
}
|
||||||
RB.AddForce(Vector2.up * force, ForceMode2D.Impulse);
|
RB.AddForce(Vector2.up * force, ForceMode2D.Impulse);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -407,41 +364,34 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
|
|
||||||
|
|
||||||
#region CHECK METHODS
|
#region CHECK METHODS
|
||||||
private bool CanJump()
|
private bool CanJump() {
|
||||||
{
|
if (!IsGrounded() && trumpet > 0) {
|
||||||
if (!IsGrounded() && trumpet > 0)
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return LastOnGroundTime > 0 && !IsJumping;
|
return LastOnGroundTime > 0 && !IsJumping;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanJumpCut()
|
private bool CanJumpCut() {
|
||||||
{
|
|
||||||
return IsJumping && RB.velocity.y > 0;
|
return IsJumping && RB.velocity.y > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsGrounded()
|
public bool IsGrounded() {
|
||||||
{
|
|
||||||
// print(Physics2D.OverlapBox(this.transform.position, _groundCheckSize, 0, _groundLayer) && !IsJumping);
|
// print(Physics2D.OverlapBox(this.transform.position, _groundCheckSize, 0, _groundLayer) && !IsJumping);
|
||||||
return (Physics2D.OverlapBox(new Vector2(this.transform.position.x, this.transform.position.y - _groundCheckOffset), _groundCheckSize, 0, _groundLayer) && !IsJumping);
|
return (Physics2D.OverlapBox(new Vector2(this.transform.position.x, this.transform.position.y - _groundCheckOffset), _groundCheckSize, 0, _groundLayer) && !IsJumping);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FloatGravity(float grav)
|
public void FloatGravity(float grav) {
|
||||||
{
|
|
||||||
Data.maxFallSpeed = grav;
|
Data.maxFallSpeed = grav;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndFloatGravity()
|
public void EndFloatGravity() {
|
||||||
{
|
|
||||||
Data.maxFallSpeed = tempFallSpeed;
|
Data.maxFallSpeed = tempFallSpeed;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region EDITOR METHODS
|
#region EDITOR METHODS
|
||||||
private void OnDrawGizmosSelected()
|
private void OnDrawGizmosSelected() {
|
||||||
{
|
|
||||||
Gizmos.color = Color.green;
|
Gizmos.color = Color.green;
|
||||||
Gizmos.DrawWireCube(new Vector2(this.transform.position.x, this.transform.position.y - _groundCheckOffset), _groundCheckSize);
|
Gizmos.DrawWireCube(new Vector2(this.transform.position.x, this.transform.position.y - _groundCheckOffset), _groundCheckSize);
|
||||||
Gizmos.color = Color.blue;
|
Gizmos.color = Color.blue;
|
||||||
@ -451,10 +401,8 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ADDITIONAL TRUMPET METHODS
|
#region ADDITIONAL TRUMPET METHODS
|
||||||
IEnumerator ActivateTrumpetSprite()
|
IEnumerator ActivateTrumpetSprite() {
|
||||||
{
|
if (!trumpetActive) {
|
||||||
if (!trumpetActive)
|
|
||||||
{
|
|
||||||
trumpetActive = true;
|
trumpetActive = true;
|
||||||
trumpetSprite.enabled = true;
|
trumpetSprite.enabled = true;
|
||||||
trumpetAnimationObject.SetActive(true);
|
trumpetAnimationObject.SetActive(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user