Added controls for gamepad, changed input & UI
This commit is contained in:
@@ -2,6 +2,7 @@ using Assets.Scripts;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Fight : MonoBehaviour
|
||||
@@ -23,6 +24,7 @@ public class Fight : MonoBehaviour
|
||||
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
|
||||
uihandler.openFight();
|
||||
uihandler.updateFightInterface(enemy, player);
|
||||
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnActionOne"));
|
||||
}
|
||||
|
||||
private void endFight()
|
||||
@@ -91,41 +93,21 @@ public class Fight : MonoBehaviour
|
||||
int enemyDamage = -1;
|
||||
// { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence };
|
||||
int[] enemyStats = enemy.GetComponent<Enemy>().getStats();
|
||||
int index = rand.Next(0,3);
|
||||
if (enemyStats[0] <= enemyStats[1] / 4 && index != 0)
|
||||
int index = rand.Next(0,2);
|
||||
|
||||
if (index == 1 && enemyStats[2] <= 0)
|
||||
{
|
||||
enemyDamage = secondChance();
|
||||
if (enemyDamage != 0)
|
||||
{
|
||||
enemyDamage = secondChance();
|
||||
}
|
||||
}
|
||||
else if (enemyStats[0] <= enemyStats[1] / 2 && index != 0)
|
||||
{
|
||||
enemyDamage = secondChance();
|
||||
index = 0;
|
||||
}
|
||||
|
||||
if (index == 2 && enemyStats[2] <= 0)
|
||||
switch (index)
|
||||
{
|
||||
index = 1;
|
||||
}
|
||||
|
||||
if (enemyDamage == 0 || index == 0)
|
||||
{
|
||||
endFight();
|
||||
uihandler.showMessage("INFORMATION;The enemy escaped!");
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 1:
|
||||
enemyDamage = enemy.GetComponent<Enemy>().calculateDamage();
|
||||
break;
|
||||
case 2:
|
||||
enemyDamage = enemy.GetComponent<Enemy>().calculateHeavy();
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
enemyDamage = enemy.GetComponent<Enemy>().calculateDamage();
|
||||
break;
|
||||
case 1:
|
||||
enemyDamage = enemy.GetComponent<Enemy>().calculateHeavy();
|
||||
break;
|
||||
}
|
||||
|
||||
if (player.GetComponent<Player>().takeDamage(enemyDamage))
|
||||
@@ -134,10 +116,4 @@ public class Fight : MonoBehaviour
|
||||
uihandler.showDeathScreen();
|
||||
}
|
||||
}
|
||||
|
||||
private int secondChance()
|
||||
{
|
||||
int result = rand.Next(0, 3);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user