change: Added second level to MushroomVillage and implemented jump pads

This commit is contained in:
Nicholas Novak
2023-05-04 20:25:44 -07:00
parent 6ac28f4560
commit 97419d36de
6 changed files with 4003 additions and 1800 deletions

View File

@@ -0,0 +1,23 @@
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;
public Facing Direction()
{
return this.bounceDirection;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1f75445772cf608f6a46acd7fd8dd323
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -239,13 +239,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);
}
//reflect = new Vector2(saveVelocity.x,-(saveVelocity.y) * bonk);
_rb.AddForce(reflect, ForceMode2D.Impulse);
@@ -292,6 +292,27 @@ 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 = new Vector2(
this.playerController.RB.velocity.x,
0
);
Bouncepad pad = col.GetComponent<Bouncepad>();
switch (pad.Direction())
{
case Bouncepad.Facing.Left:
this.playerController.RB.AddForce(
new Vector2(-pad.bounceForce, pad.bounceForce),
ForceMode2D.Impulse
);
break;
case Bouncepad.Facing.Right:
break;
}
}
}
void OnTriggerExit2D(Collider2D col)
@@ -367,7 +388,8 @@ public class PlayerBehavior : MonoBehaviour
// this.stateController.SetDeathCanvasActive(true);
if (grapplingRope.isGrappling) {
if (grapplingRope.isGrappling)
{
LetGoOfGrapple();
}