From ae85d02ea2b1d70468054a165712d0fabb6842eb Mon Sep 17 00:00:00 2001 From: Nicola Sovic Date: Thu, 7 Jul 2022 12:03:13 +0200 Subject: [PATCH] Fixed game win bug for discovering city, v1.3.1 --- Assets/Scripts/Item.cs | 59 ++++++++++++++++---------------- Assets/Scripts/Player.cs | 6 ++++ Assets/Scripts/WorldGenerator.cs | 3 +- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/Assets/Scripts/Item.cs b/Assets/Scripts/Item.cs index 58588fe..0073ff2 100644 --- a/Assets/Scripts/Item.cs +++ b/Assets/Scripts/Item.cs @@ -199,61 +199,61 @@ namespace Assets.Scripts index = calculateIndex(indexes); switch (index) { - case 0: + case 1: if (i == 0) { itemName = "luck"; } - attributes.Add("LCK", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1))); - break; - case 1: - if (i == 0) - { - itemName = "intelligence"; - } - attributes.Add("INT", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1))); + attributes.Add("LCK", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1))); break; case 2: if (i == 0) { - itemName = "dexterity"; + itemName = "intelligence"; } - attributes.Add("DEX", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1))); + attributes.Add("INT", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1))); break; case 3: if (i == 0) { - itemName = "strength"; + itemName = "dexterity"; } - attributes.Add("STR", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1))); + attributes.Add("DEX", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1))); break; case 4: if (i == 0) { - itemName = "health"; + itemName = "strength"; } - attributes.Add("HP", Mathf.RoundToInt((float)(10 - (2 * i) + luck * 0.1))); + attributes.Add("STR", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1))); break; case 5: if (i == 0) { - itemName = "mana"; + itemName = "health"; } - attributes.Add("MP", Mathf.RoundToInt((float)(10 - (2 * i) + luck * 0.1))); + attributes.Add("HP", Mathf.RoundToInt((float)(10 - (2 * i) + rand.Next(luck) * 0.1))); break; case 6: if (i == 0) { - itemName = "health regeneration"; + itemName = "mana"; } - attributes.Add("HPR", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1))); + attributes.Add("MP", Mathf.RoundToInt((float)(10 - (2 * i) + rand.Next(luck) * 0.1))); break; case 7: + if (i == 0) + { + itemName = "health regeneration"; + } + attributes.Add("HPR", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1))); + break; + case 8: if (i == 0) { itemName = "mana regeneration"; } - attributes.Add("MPR", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1))); + attributes.Add("MPR", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1))); break; } indexes[i] = index; @@ -261,14 +261,15 @@ namespace Assets.Scripts } else { - attributes.Add("MPR", Mathf.RoundToInt((float)(3 + luck * 0.1))); - attributes.Add("HPR", Mathf.RoundToInt((float)(3 + luck * 0.1))); - attributes.Add("MP", Mathf.RoundToInt((float)(3 + luck * 0.1))); - attributes.Add("HP", Mathf.RoundToInt((float)(3 + luck * 0.1))); - attributes.Add("STR", Mathf.RoundToInt((float)(3 + luck * 0.1))); - attributes.Add("DEX", Mathf.RoundToInt((float)(3 + luck * 0.1))); - attributes.Add("INT", Mathf.RoundToInt((float)(3 + luck * 0.1))); - attributes.Add("LCK", Mathf.RoundToInt((float)(3 + luck * 0.1))); + int bonus = rand.Next(luck); + attributes.Add("MPR", Mathf.RoundToInt((float)(3 + bonus * 0.1))); + attributes.Add("HPR", Mathf.RoundToInt((float)(3 + bonus * 0.1))); + attributes.Add("MP", Mathf.RoundToInt((float)(3 + bonus * 0.1))); + attributes.Add("HP", Mathf.RoundToInt((float)(3 + bonus * 0.1))); + attributes.Add("STR", Mathf.RoundToInt((float)(3 + bonus * 0.1))); + attributes.Add("DEX", Mathf.RoundToInt((float)(3 + bonus * 0.1))); + attributes.Add("INT", Mathf.RoundToInt((float)(3 + bonus * 0.1))); + attributes.Add("LCK", Mathf.RoundToInt((float)(3 + bonus * 0.1))); } } @@ -278,7 +279,7 @@ namespace Assets.Scripts int index = 0; while (true) { - index = rand.Next(8); + index = rand.Next(8) + 1; counter = 0; for (int j = 0; j < indexes.Length; j++) { diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 26816c2..156f604 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -194,6 +194,7 @@ namespace Assets.Scripts getRotation(); regeneratePlayer(); uihandler.adjustInformation(this); + gameFinished(); } } @@ -464,6 +465,11 @@ namespace Assets.Scripts uihandler.showMessage("SUCCESS;You killed your enemy!"); killcount++; SteamWorksHandler.getSlimeAchievement(killcount); + gameFinished(); + } + + public void gameFinished() + { if (killcount >= 30 * (difficulty + 1) && GameObject.Find("WorldGenerator").GetComponent().gameWon()) { uihandler.showMessage("SUCCESS;You won the game!"); diff --git a/Assets/Scripts/WorldGenerator.cs b/Assets/Scripts/WorldGenerator.cs index 0ff9025..92fd83a 100644 --- a/Assets/Scripts/WorldGenerator.cs +++ b/Assets/Scripts/WorldGenerator.cs @@ -101,6 +101,7 @@ public class WorldGenerator : MonoBehaviour name = city.name; cityAmount--; SteamWorksHandler.getStandardAchievement("CityAchievement"); + } else { @@ -108,7 +109,6 @@ public class WorldGenerator : MonoBehaviour name = tile.name; noise.applyNoise(newTile); } - } else { @@ -116,7 +116,6 @@ public class WorldGenerator : MonoBehaviour name = tile.name; noise.applyNoise(newTile); } - if (name.Contains("_")) { name = name.Split('_')[0];