Updated rarity, fixed hp/mp display on point usage, fixed item moving issue, v1.3.0

This commit is contained in:
Nicola Sovic 2022-07-04 11:54:31 +02:00
parent 977f9ca5cf
commit dd0251cb3e
5 changed files with 42 additions and 38 deletions

View File

@ -125,16 +125,16 @@ namespace Assets.Scripts
inventory.dragImage.GetComponent<RawImage>().color = new Color(0,0,0,0); inventory.dragImage.GetComponent<RawImage>().color = new Color(0,0,0,0);
inventory.dragImage.GetComponent<RawImage>().texture = null; inventory.dragImage.GetComponent<RawImage>().texture = null;
inventory.dragImage.transform.position = new Vector3(0,0,0); inventory.dragImage.transform.position = new Vector3(0,0,0);
GameObject startDrag = inventory.getDrag(); InventorySlot startDrag = inventory.getDrag().GetComponent<InventorySlot>();
Item item; Item item;
bool isSwap = false; bool isSwap = false;
if (startDrag.GetComponent<InventorySlot>().place == ItemPlace.BAG) if (startDrag.place == ItemPlace.BAG)
{ {
item = startDrag.GetComponent<InventorySlot>().getItem(currentBag); item = startDrag.getItem(startDrag.currentBag);
} }
else else
{ {
item = startDrag.GetComponent<InventorySlot>().getEquip(); item = startDrag.getEquip();
} }
if (item != null) if (item != null)
{ {
@ -146,13 +146,17 @@ namespace Assets.Scripts
{ {
if (items[currentBag] != null) if (items[currentBag] != null)
{ {
if (startDrag.GetComponent<InventorySlot>().place == ItemPlace.BAG) if (items[currentBag].getPlace() != startDrag.place)
{ {
startDrag.GetComponent<InventorySlot>().setItem(items[currentBag], currentBag); return;
}
if (startDrag.place == ItemPlace.BAG)
{
startDrag.setItem(items[currentBag], currentBag);
} }
else else
{ {
startDrag.GetComponent<InventorySlot>().setEquip(items[currentBag]); startDrag.setEquip(items[currentBag]);
inventory.calculateStatBoost(item.getAttributes(), false); inventory.calculateStatBoost(item.getAttributes(), false);
inventory.calculateStatBoost(items[currentBag].getAttributes(), true); inventory.calculateStatBoost(items[currentBag].getAttributes(), true);
} }
@ -164,9 +168,9 @@ namespace Assets.Scripts
{ {
if (equip != null) if (equip != null)
{ {
if (startDrag.GetComponent<InventorySlot>().place == ItemPlace.BAG) if (startDrag.place == ItemPlace.BAG)
{ {
startDrag.GetComponent<InventorySlot>().setItem(equip, currentBag); startDrag.setItem(equip, startDrag.currentBag);
isSwap = true; isSwap = true;
inventory.calculateStatBoost(equip.getAttributes(), false); inventory.calculateStatBoost(equip.getAttributes(), false);
} }
@ -180,14 +184,14 @@ namespace Assets.Scripts
} }
if (!isSwap) if (!isSwap)
{ {
if (startDrag.GetComponent<InventorySlot>().place != ItemPlace.BAG) if (startDrag.place != ItemPlace.BAG)
{ {
inventory.calculateStatBoost(startDrag.GetComponent<InventorySlot>().getEquip().getAttributes(), false); inventory.calculateStatBoost(startDrag.getEquip().getAttributes(), false);
startDrag.GetComponent<InventorySlot>().removeEquip(); startDrag.removeEquip();
} }
else else
{ {
startDrag.GetComponent<InventorySlot>().removeItem(); startDrag.removeItem();
} }
} }
} }

View File

@ -96,22 +96,22 @@ namespace Assets.Scripts
private void calculateRarity(int luck) private void calculateRarity(int luck)
{ {
int number = rand.Next(100); int number = rand.Next(100);
if (number + luck < 74) if (number + luck < 80)
{ {
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 < 108) else if (number + luck >= 80 && number + luck < 100)
{ {
rarity = ItemRarity.RARE; rarity = ItemRarity.RARE;
rarityColor = new Color32(0,100,255, 255); rarityColor = new Color32(0,100,255, 255);
} }
else if (number + luck >= 108 && number + luck < 117) else if (number + luck >= 100 && number + luck < 120)
{ {
rarity = ItemRarity.EPIC; rarity = ItemRarity.EPIC;
rarityColor = new Color32(255,0,230, 255); rarityColor = new Color32(255,0,230, 255);
} }
else if (number + luck >= 117) else if (number + luck >= 120)
{ {
rarity = ItemRarity.LEGENDARY; rarity = ItemRarity.LEGENDARY;
rarityColor = new Color32(255,230,0, 255); rarityColor = new Color32(255,230,0, 255);
@ -134,71 +134,71 @@ namespace Assets.Scripts
{ {
itemName = "luck"; itemName = "luck";
} }
attributes.Add("LCK", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2))); attributes.Add("LCK", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1)));
break; break;
case 1: case 1:
if (i == 0) if (i == 0)
{ {
itemName = "intelligence"; itemName = "intelligence";
} }
attributes.Add("INT", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2))); attributes.Add("INT", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1)));
break; break;
case 2: case 2:
if (i == 0) if (i == 0)
{ {
itemName = "dexterity"; itemName = "dexterity";
} }
attributes.Add("DEX", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2))); attributes.Add("DEX", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1)));
break; break;
case 3: case 3:
if (i == 0) if (i == 0)
{ {
itemName = "strength"; itemName = "strength";
} }
attributes.Add("STR", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2))); attributes.Add("STR", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1)));
break; break;
case 4: case 4:
if (i == 0) if (i == 0)
{ {
itemName = "health"; itemName = "health";
} }
attributes.Add("HP", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2))); attributes.Add("HP", Mathf.RoundToInt((float)(10 - (2 * i) + luck * 0.1)));
break; break;
case 5: case 5:
if (i == 0) if (i == 0)
{ {
itemName = "mana"; itemName = "mana";
} }
attributes.Add("MP", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2))); attributes.Add("MP", Mathf.RoundToInt((float)(10 - (2 * i) + luck * 0.1)));
break; break;
case 6: case 6:
if (i == 0) if (i == 0)
{ {
itemName = "health regeneration"; itemName = "health regeneration";
} }
attributes.Add("HPR", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2))); attributes.Add("HPR", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1)));
break; break;
case 7: case 7:
if (i == 0) if (i == 0)
{ {
itemName = "mana regeneration"; itemName = "mana regeneration";
} }
attributes.Add("MPR", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2))); attributes.Add("MPR", Mathf.RoundToInt((float)(3 - (2 * i) + luck * 0.1)));
break; break;
} }
indexes[0] = index; indexes[i] = index;
} }
} }
else else
{ {
attributes.Add("MPR", Mathf.RoundToInt((float)(5 + luck * 0.2))); attributes.Add("MPR", Mathf.RoundToInt((float)(3 + luck * 0.1)));
attributes.Add("HPR", Mathf.RoundToInt((float)(5 + luck * 0.2))); attributes.Add("HPR", Mathf.RoundToInt((float)(3 + luck * 0.1)));
attributes.Add("MP", Mathf.RoundToInt((float)(5 + luck * 0.2))); attributes.Add("MP", Mathf.RoundToInt((float)(3 + luck * 0.1)));
attributes.Add("HP", Mathf.RoundToInt((float)(5 + luck * 0.2))); attributes.Add("HP", Mathf.RoundToInt((float)(3 + luck * 0.1)));
attributes.Add("STR", Mathf.RoundToInt((float)(5 + luck * 0.2))); attributes.Add("STR", Mathf.RoundToInt((float)(3 + luck * 0.1)));
attributes.Add("DEX", Mathf.RoundToInt((float)(5 + luck * 0.2))); attributes.Add("DEX", Mathf.RoundToInt((float)(3 + luck * 0.1)));
attributes.Add("INT", Mathf.RoundToInt((float)(5 + luck * 0.2))); attributes.Add("INT", Mathf.RoundToInt((float)(3 + luck * 0.1)));
attributes.Add("LCK", Mathf.RoundToInt((float)(5 + luck * 0.2))); attributes.Add("LCK", Mathf.RoundToInt((float)(3 + luck * 0.1)));
} }
} }

View File

@ -542,7 +542,7 @@ namespace Assets.Scripts
if (points > 0) if (points > 0)
{ {
maxHealth = maxHealth + 5; maxHealth = maxHealth + 5;
health = maxHealth; health = maxHealth + equipment["HP"];
points--; points--;
} }
else else
@ -556,7 +556,7 @@ namespace Assets.Scripts
if (points > 0) if (points > 0)
{ {
maxSecondary = maxSecondary + 5; maxSecondary = maxSecondary + 5;
secondary = maxSecondary; secondary = maxSecondary + equipment["MP"];
points--; points--;
} }
else else

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)//5 + playerStats[11]) if (new System.Random().Next(100) + 1 < 1000)//10 + playerStats[11])
{ {
item = new Item(playerStats[11]); item = new Item(playerStats[11]);
} }

View File

@ -1,2 +1,2 @@
Music:0 Music:0
Effects:0.5051396 Effects:0