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

Potion Fixes, Enemy Movement changes

parent 380263ae
No related branches found
No related tags found
No related merge requests found
Showing
with 73 additions and 21 deletions
No preview for this file type
......@@ -379,19 +379,19 @@ public class ArenaCombatControl : MonoBehaviour {
private void Drink() {
//Can only drink the respected potion if the respected potion exists
if (Input.GetKeyDown(KeyCode.Alpha1) && PlayerStats.strengthPotions >= 1) {
if (Input.GetKeyDown(KeyCode.Alpha1) && PlayerStats.strengthPotions >= 1 && drinkStength !=true) {
boostStrength();
PlayerStats.strengthPotions--;
drinkStength = true;
myAnimator.SetBool("drink", true);
}
else if (Input.GetKeyDown(KeyCode.Alpha2) && PlayerStats.agilityPotions >= 1) {
else if (Input.GetKeyDown(KeyCode.Alpha2) && PlayerStats.agilityPotions >= 1 && drinkAgility != true) {
boostAgility();
PlayerStats.agilityPotions--;
drinkAgility = true;
myAnimator.SetBool("drink", true);
}
else if (Input.GetKeyDown(KeyCode.Alpha3) && PlayerStats.defensePotions >= 1) {
else if (Input.GetKeyDown(KeyCode.Alpha3) && PlayerStats.defensePotions >= 1 && drinkDefence != true) {
boostDefence();
PlayerStats.defensePotions--;
drinkDefence = true;
......@@ -418,12 +418,12 @@ public class ArenaCombatControl : MonoBehaviour {
}
private void boostDefence() {
PlayerStats.strength += 15;
PlayerStats.defense += 15;
Invoke("DefenceBoostCoolDown", 150); //boost lasts 2.5 mins
}
private void boostAgility() {
PlayerStats.strength += 15;
PlayerStats.agility += 15;
Invoke("AgilityBoostCoolDown", 150); //boost lasts 2.5 mins
}
......
......@@ -50,6 +50,8 @@ public class EnemyAI : MonoBehaviour {
private int healthPotion;
public int enemyMax;
public int enemyMin;
public bool dash = true;
public float dashCoolDown = 5;
void Start() {
......@@ -104,6 +106,15 @@ public class EnemyAI : MonoBehaviour {
}
}
if (dash == true) {
dashCoolDown -= Time.deltaTime;
if (dashCoolDown <= 0) {
dashCoolDown = 5;
dash = false;
}
}
//sets a delay to the search of the tree so actions can not be spammed out by the AI
if (actionDelay == true) {
searchCoolDown -= Time.deltaTime;
......@@ -122,16 +133,16 @@ public class EnemyAI : MonoBehaviour {
public void setEnemyHp() {
if (ArenaCombatControl.winCount <= 2) {
enemyHealth = enemyHealth = Random.Range(20,40);
enemyHealth = enemyHealth = Random.Range(20, 40);
original = enemyHealth;
}
else {
enemyHealth = enemyHealth = Random.Range(15 * (int)(ArenaCombatControl.winCount / 1.1f + 1), 20 * (int)(ArenaCombatControl.winCount / 1.1f + 1));
original = enemyHealth;
enemyHealth = enemyHealth = Random.Range(15 * (int)(ArenaCombatControl.winCount / 1.1f + 1), 20 * (int)(ArenaCombatControl.winCount / 1.1f + 1));
original = enemyHealth;
}
}
/*
* getPushed()
* Takes Input from the user and checks whether or not the enemy is being pushed
......@@ -236,9 +247,9 @@ public class EnemyAI : MonoBehaviour {
* Damage dealt against the enemy from the player
*/
public void Damage(int amount) {
enemyHealth -= amount;
enemyHealth -= amount;
if (enemyHealth <= 0) {
enemyHealth = 0;
enemyHealth = 0;
ArenaCombatControl.winCount++;
isEnemyDead = true;
myAnimator.SetBool("death", true);
......@@ -266,7 +277,7 @@ public class EnemyAI : MonoBehaviour {
enemyMax = 8 + (int)(ArenaCombatControl.winCount * 1.25f); //BALANCE THIS
enemyMin = 1 + (int)(ArenaCombatControl.winCount * 1.1f);
int final = Random.Range(enemyMin, enemyMax);
Debug.Log (final);
Debug.Log(final);
// calculate here! remember player defense is factored in later
return final;
}
......@@ -380,17 +391,17 @@ public class EnemyAI : MonoBehaviour {
public bool d_isHpLow() {
myAnimator.SetBool("drink", false);
if ((original / 2) > enemyHealth) {
if (healthPotion >=1) {
if (healthPotion >= 1) {
myAnimator.SetBool("drink", true);
enemyHealth += (int)(original*0.5);
if (enemyHealth > original) {
enemyHealth = original;
}
enemyHealth += (int)(original * 0.5);
if (enemyHealth > original) {
enemyHealth = original;
}
healthPotion--;
}
return true;
}
return false;
}
......@@ -526,6 +537,18 @@ public class EnemyAI : MonoBehaviour {
myAnimator.SetBool("throw", false);
}
//change up the movement so its not so predictable
public void a_walkOrDash() {
if (dash == false) {
a_dashToPlayer();
dash = true;
}
else {
a_moveToPlayer();
}
}
//Will allow the enemy it either attack the player or preform a random action
//50% chance of either happening
......@@ -675,12 +698,35 @@ public class EnemyAI : MonoBehaviour {
}
}
public void a_dashToPlayer() {
// Debug.Log("moving");
//rotate to look at the player
//transform.LookAt(target.position);
myAnimator.SetFloat("speed", 1); // This should probbaly reflect the actual speed
if (target.transform.position.x <= transform.position.x) //players spot in world space as opposed to enemy "self" spot
{
LookRight = false;
transform.rotation = new Quaternion(0, 180, 0, 0); // flips enemy around to face the player on x axis only
Enemy.AddForce(new Vector2(-350, Player.velocity.y * 5));
}
else if (target.transform.position.x >= transform.position.x) //players spot in world space as opposed to enemy "self" spot
{
LookRight = true;
transform.rotation = new Quaternion(0, 0, 0, 0); // flips enemy around to face the player on x axis only }
Enemy.AddForce(new Vector2(350, Player.velocity.y * 5));
}
}
public void a_moveFromPlayer() {
// Debug.Log("movingAWAY");
//rotate to look at the player
//transform.LookAt(target.position);
myAnimator.SetFloat("speed", 1); // This should probbaly reflect the actual speed
transform.position = Vector2.MoveTowards(transform.position, target.position, (-speed *2) * Time.deltaTime);
transform.position = Vector2.MoveTowards(transform.position, target.position, (-speed * 2) * Time.deltaTime);
if (target.transform.position.x <= transform.position.x) //players spot in world space as opposed to enemy "self" spot
{
......@@ -701,6 +747,12 @@ public class EnemyAI : MonoBehaviour {
public void BuildDecisionTree() {
//Actions
DecisionTree Dash = new DecisionTree();
Dash.setAction(a_dashToPlayer);
DecisionTree RandomWalk = new DecisionTree();
RandomWalk.setAction(a_walkOrDash);
DecisionTree RandomAction = new DecisionTree();
RandomAction.setAction(a_randomAction);
......@@ -821,7 +873,7 @@ public class EnemyAI : MonoBehaviour {
DecisionTree IsPlayerTooFar = new DecisionTree();
IsPlayerTooFar.setDecision(d_isPlayerTooFar);
IsPlayerTooFar.setLeft(Throw);
IsPlayerTooFar.setRight(MoveToPlayer);
IsPlayerTooFar.setRight(RandomWalk);
DecisionTree IsPlayerTooClose = new DecisionTree();
IsPlayerTooClose.setDecision(d_isPlayerTooClose);
......
No preview for this file type
sceneSetups:
- path: Assets/Scenes/shopBlacksmith.unity
- path: Assets/Scenes/arena.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
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