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

Potions and Boosts Implemented

Health pot heals 35
Stats boosted for 2.5 mins
parent b3d1392c
No related branches found
No related tags found
No related merge requests found
Showing
with 162 additions and 20 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -17,7 +17,7 @@ public class ArenaCombatControl : MonoBehaviour {
private bool canJump = false;
private bool canBlock = true;
private bool canRefill = false;
private float attackSpeedCooldown;
public static float attackSpeedCooldown;
private float blockCoolDown;
public bool kicked = false;
public static bool kick = false;
......@@ -45,6 +45,7 @@ public class ArenaCombatControl : MonoBehaviour {
Player = GetComponent<Rigidbody2D>();
myAnimator = GetComponent<Animator>(); //required for animation *******
//SetWeaponStats();
attackSpeedCooldown = 3 - stats.getWeapon().attackSpeed; // set cooldown based on equipped weapon (higher attack speed is quicker)
blockCoolDown = 3;
dashCoolDownD = 0.2f;
dashCoolDownA = 0.2f;
......@@ -184,9 +185,6 @@ public class ArenaCombatControl : MonoBehaviour {
}
//controlling the characters movement
private void Movement(float horizontal) {
if (canMove) {
......@@ -199,8 +197,8 @@ public class ArenaCombatControl : MonoBehaviour {
private void Attack() {
attackSpeedCooldown -= Time.deltaTime;
if (Input.GetKeyDown(KeyCode.Space) && attackSpeedCooldown <= 0) {
attackSpeedCooldown = 3; // Base time, subtract attack speed from this to get the cool down. So a weapon with 0 attack speed will have 3 seconds between swings.
attackSpeedCooldown -= stats.getWeapon().attackSpeed; // set cooldown based on equipped weapon (higher attack speed is quicker)
// attackSpeedCooldown = 3; // Base time, subtract attack speed from this to get the cool down. So a weapon with 0 attack speed will have 3 seconds between swings.
attackSpeedCooldown = stats.getWeapon().attackSpeed; // set cooldown based on equipped weapon (higher attack speed is quicker)
attack = true;
myAnimator.SetBool("attack", true);
}
......@@ -260,7 +258,7 @@ public class ArenaCombatControl : MonoBehaviour {
PlayerStats.stamina -= 2*Time.deltaTime; // drains stamina while blocking ( 2x to counteract constant filling)
}
if (blockCoolDown < 0) {
if (blockCoolDown < 0 || PlayerStats.stamina <= 0) {
block = false;
canRefill = true;
canBlock = false;
......@@ -348,16 +346,25 @@ public class ArenaCombatControl : MonoBehaviour {
}
private void Drink() {
if (Input.GetKeyDown(KeyCode.Alpha1)) {
//Can only drink the respected potion if the respected potion exists
if (Input.GetKeyDown(KeyCode.Alpha1) && PlayerStats.strengthPotions >= 1) {
boostStrength();
PlayerStats.strengthPotions--;
myAnimator.SetBool("drink", true);
}
else if (Input.GetKeyDown(KeyCode.Alpha2)) {
else if (Input.GetKeyDown(KeyCode.Alpha2) && PlayerStats.agilityPotions >= 1) {
boostAgility();
PlayerStats.agilityPotions--;
myAnimator.SetBool("drink", true);
}
else if (Input.GetKeyDown(KeyCode.Alpha3)) {
else if (Input.GetKeyDown(KeyCode.Alpha3) && PlayerStats.defensePotions >= 1) {
boostDefence();
PlayerStats.defensePotions--;
myAnimator.SetBool("drink", true);
}
else if (Input.GetKeyDown(KeyCode.Alpha4)) {
else if (Input.GetKeyDown(KeyCode.Alpha4) && PlayerStats.healthPotions >= 1) {
PlayerStats.curHealth += 35; //heal as soon as you drink the pot
PlayerStats.healthPotions--;
myAnimator.SetBool("drink", true);
}
......@@ -366,6 +373,35 @@ public class ArenaCombatControl : MonoBehaviour {
}
}
//Apply the boost to the respected skill
private void boostStrength() {
PlayerStats.strength += 15;
Invoke("StrengthBoostCoolDown", 150); //boost lasts 2.5 mins
}
private void boostDefence() {
PlayerStats.strength += 15;
Invoke("DefenceBoostCoolDown", 150); //boost lasts 2.5 mins
}
private void boostAgility() {
PlayerStats.strength += 15;
Invoke("AgilityBoostCoolDown", 150); //boost lasts 2.5 mins
}
//take boost off the respected skills
private void StrengthBoostCoolDown() {
PlayerStats.strength -= 15;
}
private void DefenceBoostCoolDown() {
PlayerStats.defense -= 15;
}
private void AgilityBoostCoolDown() {
PlayerStats.agility -= 15;
}
void OnCollisionEnter2D(Collision2D coll) {
if (coll.gameObject.tag == "ground") {
......
......@@ -79,16 +79,25 @@ public class PlayerMovement : MonoBehaviour
}
private void Drink() {
if (Input.GetKeyDown(KeyCode.Alpha1)) {
//Can only drink the respected potion if the respected potion exists
if (Input.GetKeyDown(KeyCode.Alpha1) && PlayerStats.strengthPotions >= 1) {
boostStrength();
PlayerStats.strengthPotions--;
myAnimator.SetBool("drink", true);
}
else if (Input.GetKeyDown(KeyCode.Alpha2)) {
else if (Input.GetKeyDown(KeyCode.Alpha2) && PlayerStats.agilityPotions >= 1) {
boostAgility();
PlayerStats.agilityPotions--;
myAnimator.SetBool("drink", true);
}
else if (Input.GetKeyDown(KeyCode.Alpha3)) {
else if (Input.GetKeyDown(KeyCode.Alpha3) && PlayerStats.defensePotions >= 1) {
boostDefence();
PlayerStats.defensePotions--;
myAnimator.SetBool("drink", true);
}
else if (Input.GetKeyDown(KeyCode.Alpha4)) {
else if (Input.GetKeyDown(KeyCode.Alpha4) && PlayerStats.healthPotions >= 1) {
PlayerStats.curHealth += 35; //heal as soon as you drink the pot
PlayerStats.healthPotions--;
myAnimator.SetBool("drink", true);
}
......@@ -97,6 +106,34 @@ public class PlayerMovement : MonoBehaviour
}
}
//Apply the boost to the respected skill
private void boostStrength() {
PlayerStats.strength += 15;
Invoke("StrengthBoostCoolDown", 150); //boost lasts 2.5 mins
}
private void boostDefence() {
PlayerStats.strength += 15;
Invoke("DefenceBoostCoolDown", 150); //boost lasts 2.5 mins
}
private void boostAgility() {
PlayerStats.strength += 15;
Invoke("AgilityBoostCoolDown", 150); //boost lasts 2.5 mins
}
//take boost off the respected skills
private void StrengthBoostCoolDown() {
PlayerStats.strength -= 15;
}
private void DefenceBoostCoolDown() {
PlayerStats.defense -= 15;
}
private void AgilityBoostCoolDown() {
PlayerStats.agility -= 15;
}
......
......@@ -22,10 +22,10 @@ public class PlayerStats : MonoBehaviour {
public static float staminaMax;
//below will act as the invetory
public static int healthPotions;
public static int strengthPotions;
public static int defensePotions;
public static int agilityPotions;
public static int healthPotions = 0;
public static int strengthPotions = 0;
public static int defensePotions = 0;
public static int agilityPotions = 0;
public static bool offenseBlessing;
public static bool defenseBlessing;
public static bool luckBlessing;
......
using UnityEngine;
using System.Collections;
public class Pots : MonoBehaviour {
private static int HealthPot = 0;
private static int StrengthPot = 0;
private static int DefencePot = 0;
private static int AgilityPot = 0;
//Use this for initialization
void Start () {
}
// Method for increasing coin amount
public void increaseHealthPot(int amount) {
HealthPot += amount;
}
// Method for increasing coin amount
public void increaseStrengthPot(int amount) {
StrengthPot += amount;
}
// Method for increasing coin amount
public void increaseDefencePot(int amount) {
DefencePot += amount;
}
// Method for increasing coin amount
public void increaseAgilityPot(int amount) {
AgilityPot += amount;
}
// Method for increasing coin amount
public void decreaseHealthPot(int amount) {
HealthPot += amount;
}
// Method for increasing coin amount
public void decreaseStrengthPot(int amount) {
StrengthPot += amount;
}
// Method for increasing coin amount
public void decreaseDefencePot(int amount) {
DefencePot += amount;
}
// Method for increasing coin amount
public void decreaseAgilityPot(int amount) {
AgilityPot += amount;
}
}
fileFormatVersion: 2
guid: 2e436e5f859b4de47ba4ea9846e2d62a
timeCreated: 1480566736
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
No preview for this file type
No preview for this file type
sceneSetups:
- path: Assets/Scenes/Town02.unity
- path: Assets/Scenes/Start.unity
isLoaded: 1
isActive: 1
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