Commit 49af132d authored by Eby Komenan's avatar Eby Komenan

modified: Assets/Scripts/Birb/Jump.cs

	modified:   Assets/Scripts/Util/HazardSlow.cs
parent 95935f37
using UnityEngine;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
......@@ -14,7 +15,6 @@ public class Jump : AbstractBehavior {
get{return jumpRequested;}
}
bool jumpRequested;
bool jumpBlocked;
int airJumpsMade = 0;
Walk walk;
......@@ -27,6 +27,8 @@ public class Jump : AbstractBehavior {
void Update() {
if (!jumpRequested && inputState.GetButtonPressed(inputButtons[0])) {
jumpRequested = true;
if(jumpHeight==0)
animator.SetTrigger("jump failed");
}
float jumpState;
Vector2 vel = body.velocity;
......@@ -36,7 +38,7 @@ public class Jump : AbstractBehavior {
jumpState = 0;
}
jumpState = Mathf.Sqrt(jumpState);
animator.SetFloat("jump state", jumpState);
animator.SetFloat ("jump state", jumpState);
// reset air jumps when on ground
if (collisionState.onGround) {
airJumpsMade = 0;
......@@ -53,11 +55,6 @@ public class Jump : AbstractBehavior {
public void Activate() {
if (collisionState.onGround) {
// ground jump
<<<<<<< HEAD
airJumpsMade = 0;
=======
>>>>>>> d984067ea55e6a0191c6cb7033212e7268955de1
Vector2 vel = body.velocity;
vel.y = GetJumpVelocity(jumpHeight);
body.velocity = vel;
......@@ -93,4 +90,5 @@ public class Jump : AbstractBehavior {
{
airJumpsMade = 0;
}
}
\ No newline at end of file
......@@ -6,10 +6,15 @@ public class HazardSlow : AbstractBehavior {
//Remember to give prefabs that have this script a "slowHazard" tag.
float slowfactor;
public float slowedSpeed;
float jumpHeightHold; //Holds the jumpHeight current value.
float wallJumpHeightHold; //Holds the wallJumpHeight current value.
bool valuesHeld;
void Awake()
{
slowfactor = 2.0f;
valuesHeld = false;
}
void OnTriggerEnter2D(Collider2D other){
......@@ -17,7 +22,15 @@ public class HazardSlow : AbstractBehavior {
if(other.tag=="Player"){
other.GetComponent<Walk>().speed /= slowfactor;
other.GetComponent<Jump> ().enabled = false;
//other.GetComponent<Jump> ().enabled = false;
if (!valuesHeld) {
jumpHeightHold = other.GetComponent<Jump> ().jumpHeight;
wallJumpHeightHold = other.GetComponent<Jump> ().wallJumpHeight;
valuesHeld = true;
}
other.GetComponent<Jump> ().jumpHeight = 0;
other.GetComponent<Jump> ().wallJumpHeight = 0;
}
}
void OnTriggerExit2D(Collider2D other){
......@@ -25,7 +38,9 @@ public class HazardSlow : AbstractBehavior {
if(other.tag=="Player"){
other.GetComponent<Walk>().speed *= slowfactor;
other.GetComponent<Jump>().enabled = true;
//other.GetComponent<Jump>().enabled = true;
other.GetComponent<Jump> ().jumpHeight = jumpHeightHold;
other.GetComponent<Jump> ().wallJumpHeight = wallJumpHeightHold;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment