Commit 8b9e42b6 authored by Andrew Van Buren's avatar Andrew Van Buren

Updated Dash.cs with isDashing boolean and dash meter.

parent a67a3cce
fileFormatVersion: 2
guid: a58ae0e00797d794297ccb4228d903bf
folderAsset: yes
timeCreated: 1487292663
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: fa60ffd6264804b43bc03430e8dd86b1
timeCreated: 1487292666
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Sets dash velocity and smoothly decelerates to a minimum velocity
public class Dash : AbstractBehavior {
private float lastDash;
public float coolDown = 1f;
public float dashforce = 5;
public float holdTime = 0.4f;
public float minVelocity = 0.5f;
// Should be called every frame
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Sets dash velocity and smoothly decelerates to a minimum velocity
public class Dash : AbstractBehavior {
private float lastDash;
public float coolDown = 1f;
public float dashforce = 5;
public float holdTime = 0.4f;
public float minVelocity = 0.5f;
private bool _isDashing = false;
private Transform dashMeter;
// Call to check if currently dashing
public bool isDashing
{
get { return _isDashing; }
private set
{
_isDashing = value;
}
}
void Start() {
dashMeter = GameObject.FindGameObjectWithTag("DashMeter").transform;
}
// Should be called every frame
public void DashCheck() {
// Button pressed, not in cooldown, and not on wall
if (inputState.GetButtonValue(inputButtons[0]) && Time.time > lastDash && !collisionState.onWall) {
StartCoroutine(DoDash());
}
}
// Dash
UpdateUI();
}
void UpdateUI() {
float progress = 1 - ((lastDash - Time.time)/coolDown);
dashMeter.localScale = new Vector2(Mathf.Clamp01(progress), dashMeter.localScale.y);
}
// Dash
IEnumerator DoDash() {
// Cooldown
lastDash = Time.time + coolDown;
// Is dashing
isDashing = true;
// Set initial velocity
body.velocity = transform.right * dashforce;
// Disable gravity
......@@ -39,7 +63,6 @@ public class Dash : AbstractBehavior {
if(body.velocity.magnitude < minVelocity || collisionState.onWall) {
// Velocity is low enough or collision with wall
Debug.Log("Stopped");
break;
}
......@@ -51,5 +74,11 @@ public class Dash : AbstractBehavior {
// Restore gravity
body.gravityScale = initialGrav;
}
}
// Is not dashing
isDashing = false;
}
public void DashIgnoringCooldown() {
StartCoroutine(DoDash());
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hazard : MonoBehaviour {
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Player"))
{
other.GetComponent<Birb>().Die ();
}
}
}
fileFormatVersion: 2
guid: 763513e1173772545a16c3cb1a4d40d5
timeCreated: 1487294208
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WinTrigger : MonoBehaviour {
//checks for incoming collision
public void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.name == "Player") //ensuring it's the player
{
//tell manager it has won
GameEditor.Win();
//Debug.Log("Victory Achieved");
}
}
}
fileFormatVersion: 2
guid: 79af5acd6c178454090143472b307c76
timeCreated: 1487294208
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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