Implemented forced fight, updated attack range to be closer to player.

This commit is contained in:
finnchen123
2026-02-08 13:05:09 +01:00
parent 540cff4ca2
commit 53f775dfe7
15 changed files with 67 additions and 322 deletions

View File

@@ -14,12 +14,16 @@ public class Fight : MonoBehaviour
GameObject player;
System.Random rand = new System.Random();
UIHandler uihandler;
bool isFleeable = true;
public bool isFightActive = false;
public void startFight(GameObject tile, GameObject enemy, GameObject player)
public void startFight(GameObject tile, GameObject enemy, GameObject player, bool isFleeable)
{
isFightActive = true;
this.tile = tile;
this.enemy = enemy;
this.player = player;
this.isFleeable = isFleeable;
enemy.GetComponent<Enemy>().scaleEnemy(player.GetComponent<PlayerGameObject>());
enemy.transform.rotation = Quaternion.Euler(0, GameObject.Find("Main Camera").transform.rotation.y, 0);
@@ -31,6 +35,7 @@ public class Fight : MonoBehaviour
private void endFight()
{
isFightActive = false;
uihandler.closeFight();
}
@@ -42,7 +47,7 @@ public class Fight : MonoBehaviour
switch (index)
{
case 1:
if (rand.Next(1, 11) <= 3)
if (rand.Next(1, 11) <= 3 && isFleeable)
{
escapedSuccesfully = true;
endFight();
@@ -50,7 +55,14 @@ public class Fight : MonoBehaviour
}
else
{
uihandler.showMessage("ERROR;" + TextHandler.getText("escapeFail"));
if (isFleeable)
{
uihandler.showMessage("ERROR;" + TextHandler.getText("escapeFail"));
}
else
{
uihandler.showMessage("ERROR;" + TextHandler.getText("escapeFailForced"));
}
}
break;
case 2: