Skip to content
Snippets Groups Projects
Commit f0d0ac36 authored by Graham Solie's avatar Graham Solie
Browse files

Block Timer

can no longer hold block for ever
parent 3a494d7c
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 13 deletions
No preview for this file type
No preview for this file type
......@@ -12,8 +12,11 @@ public class ArenaCombatControl : MonoBehaviour {
private float speed;
private bool LookRight = true;
private bool canMove = true;
private bool canJump = false;
private bool canJump = false;
private bool canBlock = true;
private bool canRefill = false;
private float attackSpeedCooldown;
private float blockCoolDown;
// fields to modify player stats based on weapons -- now in CharacterLook script!! *****
/*
public WeaponStats[] weapons;
......@@ -27,6 +30,7 @@ public class ArenaCombatControl : MonoBehaviour {
Player = GetComponent<Rigidbody2D>();
myAnimator = GetComponent<Animator>(); //required for animation *******
//SetWeaponStats();
blockCoolDown = 3;
}
// Update is called once per frame
......@@ -42,8 +46,8 @@ public class ArenaCombatControl : MonoBehaviour {
Jump();
}
//controlling the characters movement
//controlling the characters movement
private void Movement(float horizontal) {
if (canMove) {
......@@ -66,23 +70,50 @@ public class ArenaCombatControl : MonoBehaviour {
}
private void Block() {
if (Input.GetKeyDown(KeyCode.E)) {
// blockCoolDown -= Time.deltaTime;
Debug.Log(blockCoolDown);
if (canBlock == true && Input.GetKey(KeyCode.E)) {
Debug.Log("blocking");
myAnimator.SetBool("block", true);
Player.velocity = Vector2.zero;
canMove = false;
canRefill = false;
blockCoolDown -= Time.deltaTime;
}
if (blockCoolDown < 0) {
canRefill = false;
canBlock = false;
}
if (canBlock == false) {
Debug.Log("filling");
myAnimator.SetBool("block", false);
blockCoolDown += Time.deltaTime;
}
if (blockCoolDown > 3) {
Debug.Log("true");
canBlock = true;
}
if (Input.GetKeyUp(KeyCode.E)) {
Debug.Log("KeyOff");
myAnimator.SetBool("block", false);
canMove = true;
canRefill = true;
}
if (canRefill == true) {
if (blockCoolDown < 3) {
blockCoolDown += Time.deltaTime;
}
}
}
private void Jump() {
if (Input.GetKeyDown(KeyCode.W)&&canJump) {
canJump = false;
if (Input.GetKeyDown(KeyCode.W) && canJump) {
canJump = false;
Player.AddForce(new Vector2(0, 300));
}
}
......@@ -126,13 +157,13 @@ public class ArenaCombatControl : MonoBehaviour {
}
}
void OnCollisionEnter2D(Collision2D coll){
if (coll.gameObject.tag == "ground") {
canJump = true;
}
}
void OnCollisionEnter2D(Collision2D coll) {
if (coll.gameObject.tag == "ground") {
canJump = true;
}
}
/* can change stats simply in the inspector for dynamic purposes :)
//a few proposed weapon stats
private void SetWeaponStats()
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment