Added equipment influence to player, Added influence display, changed rarity from items, v1.3.0

This commit is contained in:
Nicola Sovic 2022-07-04 09:33:33 +02:00
parent e002a76690
commit 977f9ca5cf
5 changed files with 54 additions and 32 deletions

View File

@ -55,10 +55,18 @@ namespace Assets.Scripts
inventory.itemDisplay.transform.Find("itemName").GetComponent<Text>().text = item.getName(); inventory.itemDisplay.transform.Find("itemName").GetComponent<Text>().text = item.getName();
string text = "Stats:\r\n"; string text = "Stats:\r\n";
Dictionary<string, int> attributes = item.getAttributes(); Dictionary<string, int> attributes = item.getAttributes();
foreach (string key in attributes.Keys) if (item.getRarity() == ItemRarity.LEGENDARY)
{ {
text = text + key + ": " + attributes[key] + "\r\n"; text = "All stats: +" + attributes["STR"];
} }
else
{
foreach (string key in attributes.Keys)
{
text = text + key + ": +" + attributes[key] + "\r\n";
}
}
inventory.itemDisplay.transform.Find("itemStats").GetComponent<Text>().text = text; inventory.itemDisplay.transform.Find("itemStats").GetComponent<Text>().text = text;
int changeY = 0; int changeY = 0;
if (inventory.itemDisplay.transform.localScale == new Vector3(0,0,0)) if (inventory.itemDisplay.transform.localScale == new Vector3(0,0,0))

View File

@ -17,6 +17,7 @@ namespace Assets.Scripts
public Item(int luck) public Item(int luck)
{ {
attributes = new Dictionary<string, int>(); attributes = new Dictionary<string, int>();
luck = luck + GameObject.Find("Inventory").GetComponent<Inventory>().getEquipmentBonus()["LCK"];
int numberOfAttributes = 1; int numberOfAttributes = 1;
calculateRarity(luck); calculateRarity(luck);
if (rarity > ItemRarity.COMMON) if (rarity > ItemRarity.COMMON)
@ -94,23 +95,23 @@ namespace Assets.Scripts
private void calculateRarity(int luck) private void calculateRarity(int luck)
{ {
int number = rand.Next(101); int number = rand.Next(100);
if (number + luck < 74) if (number + luck < 74)
{ {
rarity = ItemRarity.COMMON; rarity = ItemRarity.COMMON;
rarityColor = new Color32(0,255,20,255); rarityColor = new Color32(0,255,20,255);
} }
else if (number + luck >= 75 && number + luck < 104) else if (number + luck >= 75 && number + luck < 108)
{ {
rarity = ItemRarity.RARE; rarity = ItemRarity.RARE;
rarityColor = new Color32(0,100,255, 255); rarityColor = new Color32(0,100,255, 255);
} }
else if (number + luck >= 105 && number + luck < 113) else if (number + luck >= 108 && number + luck < 117)
{ {
rarity = ItemRarity.EPIC; rarity = ItemRarity.EPIC;
rarityColor = new Color32(255,0,230, 255); rarityColor = new Color32(255,0,230, 255);
} }
else if (number + luck >= 114) else if (number + luck >= 117)
{ {
rarity = ItemRarity.LEGENDARY; rarity = ItemRarity.LEGENDARY;
rarityColor = new Color32(255,230,0, 255); rarityColor = new Color32(255,230,0, 255);
@ -288,6 +289,11 @@ namespace Assets.Scripts
{ {
return attributes; return attributes;
} }
public ItemRarity getRarity()
{
return rarity;
}
} }
} }

View File

@ -43,6 +43,7 @@ namespace Assets.Scripts
int killcount = -1; int killcount = -1;
int difficulty = 0; int difficulty = 0;
Dictionary<string, int> equipment;
private void OnEnable() private void OnEnable()
{ {
@ -56,6 +57,10 @@ namespace Assets.Scripts
{ {
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>(); uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
audioHandler = GameObject.Find("AudioHandler").GetComponent<AudioHandler>(); audioHandler = GameObject.Find("AudioHandler").GetComponent<AudioHandler>();
if (GameObject.Find("Inventory") != null)
{
equipment = GameObject.Find("Inventory").GetComponent<Inventory>().getEquipmentBonus();
}
} }
public void finishPlayerCreation() public void finishPlayerCreation()
@ -218,23 +223,23 @@ namespace Assets.Scripts
public void regainSecondary() public void regainSecondary()
{ {
secondary = secondary + secondaryRegen; secondary = secondary + secondaryRegen + equipment["MPR"];
if (secondary >= maxSecondary) if (secondary >= maxSecondary + equipment["MP"])
{ {
secondary = maxSecondary; secondary = maxSecondary + equipment["MP"];
} }
} }
private void healPlayer() private void healPlayer()
{ {
health = health + healthRegen; health = health + healthRegen + equipment["HPR"];
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S)) if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S))
{ {
health = health + 5; health = health + 5;
} }
if (health >= maxHealth) if (health >= maxHealth + equipment["HP"])
{ {
health = maxHealth; health = maxHealth + +equipment["HP"];
} }
} }
@ -342,9 +347,9 @@ namespace Assets.Scripts
int bonus = 0; int bonus = 0;
if (isCrit()) if (isCrit())
{ {
bonus = strength * 2; bonus = (strength + equipment["STR"]) * 2;
} }
result = strength + bonus + 5; result = strength + bonus + 5 + equipment["STR"];
switch (difficulty) switch (difficulty)
{ {
case 0: case 0:
@ -362,7 +367,7 @@ namespace Assets.Scripts
public void updateKillcount(GameObject gameObject) public void updateKillcount(GameObject gameObject)
{ {
gameObject.GetComponent<Text>().text = "Slimes: " + killcount + "/" + (20 * (difficulty + 1)); gameObject.GetComponent<Text>().text = "Slimes: " + killcount + "/" + (30 * (difficulty + 1));
} }
public int castSkill(int index) public int castSkill(int index)
@ -377,11 +382,11 @@ namespace Assets.Scripts
secondary = secondary - skills[index].getSecondaryConsumption(); secondary = secondary - skills[index].getSecondaryConsumption();
if (role.classname == "Wizard") if (role.classname == "Wizard")
{ {
damage = skills[index].calculateDamage(intelligence, isCrit()); damage = skills[index].calculateDamage(intelligence + equipment["INT"], isCrit());
} }
else else
{ {
damage = skills[index].calculateDamage(strength, isCrit()); damage = skills[index].calculateDamage(strength + equipment["STR"], isCrit());
} }
switch (difficulty) switch (difficulty)
@ -414,7 +419,7 @@ namespace Assets.Scripts
public bool isCrit() public bool isCrit()
{ {
return rand.Next(1, 101) <= dexterity; return rand.Next(1, 101) <= dexterity + equipment["DEX"];
} }
public int getKillCount() public int getKillCount()
@ -434,7 +439,7 @@ namespace Assets.Scripts
} }
else else
{ {
if (rand.Next(1, 101) > dexterity + (intelligence / 2)) if (rand.Next(1, 101) > dexterity + equipment["DEX"] + ((intelligence + equipment["INT"]) / 2))
{ {
health = health - amount; health = health - amount;
audioHandler.playDamage(); audioHandler.playDamage();
@ -450,7 +455,7 @@ namespace Assets.Scripts
uihandler.showMessage("SUCCESS;You killed your enemy!"); uihandler.showMessage("SUCCESS;You killed your enemy!");
killcount++; killcount++;
SteamWorksHandler.getSlimeAchievement(killcount); SteamWorksHandler.getSlimeAchievement(killcount);
if (killcount >= 30 * (difficulty + 1) && GameObject.Find("Worldgenerator").GetComponent<WorldGenerator>().gameWon()) if (killcount >= 30 * (difficulty + 1) && GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>().gameWon())
{ {
uihandler.showMessage("SUCCESS;You won the game!"); uihandler.showMessage("SUCCESS;You won the game!");
switch (difficulty) switch (difficulty)

View File

@ -33,7 +33,7 @@ namespace Assets.Scripts.Slimes
intelligence = playerStats[6]; intelligence = playerStats[6];
experience = (int)(10 + playerStats[7] * 2.5f); experience = (int)(10 + playerStats[7] * 2.5f);
level = playerStats[7]; level = playerStats[7];
if (new System.Random().Next(100) + 1 < 1000)//50 + playerStats[11]) if (new System.Random().Next(100) + 1 < 1000)//5 + playerStats[11])
{ {
item = new Item(playerStats[11]); item = new Item(playerStats[11]);
} }

View File

@ -362,16 +362,17 @@ namespace Assets.Scripts
{ {
// { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence }; // { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence };
int[] playerStats = player.GetComponent<Player>().getStats(); int[] playerStats = player.GetComponent<Player>().getStats();
Dictionary<string, int> equipment = inventory.GetComponent<Inventory>().getEquipmentBonus();
GameObject foreground = GameObject.Find("healthForegroundPlayer"); GameObject foreground = GameObject.Find("healthForegroundPlayer");
GameObject background = GameObject.Find("healthBackgroundPlayer"); GameObject background = GameObject.Find("healthBackgroundPlayer");
GameObject text = GameObject.Find("healthTextPlayer"); GameObject text = GameObject.Find("healthTextPlayer");
updateBar(foreground, background, text, playerStats[1], playerStats[0]); updateBar(foreground, background, text, playerStats[1] + equipment["HP"], playerStats[0]);
foreground = GameObject.Find("secondaryForegroundPlayer"); foreground = GameObject.Find("secondaryForegroundPlayer");
background = GameObject.Find("secondaryBackgroundPlayer"); background = GameObject.Find("secondaryBackgroundPlayer");
text = GameObject.Find("secondaryTextPlayer"); text = GameObject.Find("secondaryTextPlayer");
updateBar(foreground, background, text, playerStats[3], playerStats[2]); updateBar(foreground, background, text, playerStats[3] + equipment["MP"], playerStats[2]);
} }
private void updateFightInterfaceEnemy(GameObject enemy) private void updateFightInterfaceEnemy(GameObject enemy)
@ -394,15 +395,16 @@ namespace Assets.Scripts
{ {
// { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence, level, experience, maxExperience, points}; // { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence, level, experience, maxExperience, points};
int[] playerStats = player.GetComponent<Player>().getStats(); int[] playerStats = player.GetComponent<Player>().getStats();
Dictionary<string, int> equipment = inventory.GetComponent<Inventory>().getEquipmentBonus();
GameObject.Find("txtStrength").GetComponent<Text>().text = "STR: " + playerStats[4]; GameObject.Find("txtStrength").GetComponent<Text>().text = "STR: " + playerStats[4] + " (+" + equipment["STR"] + ")";
GameObject.Find("txtDexterity").GetComponent<Text>().text = "DEX: " + playerStats[5]; GameObject.Find("txtDexterity").GetComponent<Text>().text = "DEX: " + playerStats[5] + " (+" + equipment["DEX"] + ")";
GameObject.Find("txtIntelligence").GetComponent<Text>().text = "INT: " + playerStats[6]; GameObject.Find("txtIntelligence").GetComponent<Text>().text = "INT: " + playerStats[6] + " (+" + equipment["INT"] + ")";
GameObject.Find("txtHealth").GetComponent<Text>().text = "Health: " + playerStats[1]; GameObject.Find("txtHealth").GetComponent<Text>().text = "Health: " + playerStats[1] + " (+" + equipment["HP"] + ")";
GameObject.Find("txtSecondary").GetComponent<Text>().text = "Mana: " + playerStats[3]; GameObject.Find("txtSecondary").GetComponent<Text>().text = "Mana: " + playerStats[3] + " (+" + equipment["MP"] + ")";
updateHealthUI(playerStats[0], playerStats[1]); updateHealthUI(playerStats[0], playerStats[1] + equipment["HP"]);
updateSecondaryUI(playerStats[2], playerStats[3]); updateSecondaryUI(playerStats[2], playerStats[3] + equipment["MP"]);
updateExperienceUI(playerStats[8], playerStats[9]); updateExperienceUI(playerStats[8], playerStats[9]);
player.updateName(GameObject.Find("txtName").GetComponent<Text>()); player.updateName(GameObject.Find("txtName").GetComponent<Text>());
@ -470,17 +472,18 @@ namespace Assets.Scripts
{ {
// { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence, level, experience, maxExperience}; // { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence, level, experience, maxExperience};
int[] playerStats = player.GetComponent<Player>().getStats(); int[] playerStats = player.GetComponent<Player>().getStats();
Dictionary<string, int> equipment = inventory.GetComponent<Inventory>().getEquipmentBonus();
GameObject information = GameObject.Find("txtInformationHUD"); GameObject information = GameObject.Find("txtInformationHUD");
player.updateNameHUD(information.GetComponent<Text>()); player.updateNameHUD(information.GetComponent<Text>());
GameObject foreground = GameObject.Find("healthForegroundHUD"); GameObject foreground = GameObject.Find("healthForegroundHUD");
GameObject background = GameObject.Find("healthBackgroundHUD"); GameObject background = GameObject.Find("healthBackgroundHUD");
updateBar(foreground, background, null, playerStats[1], playerStats[0]); updateBar(foreground, background, null, playerStats[1] + equipment["HP"], playerStats[0]);
foreground = GameObject.Find("secondaryForegroundHUD"); foreground = GameObject.Find("secondaryForegroundHUD");
background = GameObject.Find("secondaryBackgroundHUD"); background = GameObject.Find("secondaryBackgroundHUD");
updateBar(foreground, background, null, playerStats[3], playerStats[2]); updateBar(foreground, background, null, playerStats[3] + equipment["MP"], playerStats[2]);
} }
public void updateBar(GameObject bar, GameObject barBackground, GameObject textField, int maxValue, int minValue) public void updateBar(GameObject bar, GameObject barBackground, GameObject textField, int maxValue, int minValue)