fixed unity inventory and texts

This commit is contained in:
TAASONI3
2023-07-11 18:36:46 +02:00
parent d0d9a6847a
commit 18dfaf7602
12 changed files with 367 additions and 273 deletions

View File

@@ -19,16 +19,28 @@ public class TextHandler : MonoBehaviour
}
public static string getText(string key){
key = key.Replace("(","").Replace(")","");
bool hasLeftBracket = false;
bool hasRightBracket = false;
if(key.Contains("(")){
hasLeftBracket = true;
key = key.Replace("(","");
}
if(key.Contains(")")){
hasRightBracket = true;
key = key.Replace(")","");
}
if(key[0].Equals(Char.ToUpperInvariant(key[0]))){
key = Char.ToLowerInvariant(key[0]) + key.Substring(1);
}
if(key.Contains("\r\n")){
return key;
}
string text = LocalizationSettings.StringDatabase.GetLocalizedString("MyTexts",key);
if(hasLeftBracket){
text = "(" + text;
}
if(hasRightBracket){
text = text + ")";
}
return text;
}

View File

@@ -30,7 +30,6 @@ namespace Assets.Scripts
TooltipHandler tooltip;
public GameObject currentSlot;
// Start is called before the first frame update
void Start()
@@ -50,18 +49,19 @@ namespace Assets.Scripts
private void createStatBoost()
{
if (statBoost == null)
{
statBoost = new Dictionary<string, int>();
statBoost.Add("HP", 0);
statBoost.Add("MP", 0);
statBoost.Add("HPR", 0);
statBoost.Add("MPR", 0);
statBoost.Add("STR", 0);
statBoost.Add("DEX", 0);
statBoost.Add("INT", 0);
statBoost.Add("LCK", 0);
}
statBoost = new Dictionary<string, int>();
statBoost.Add("HP", 0);
statBoost.Add("MP", 0);
statBoost.Add("HPR", 0);
statBoost.Add("MPR", 0);
statBoost.Add("STR", 0);
statBoost.Add("DEX", 0);
statBoost.Add("INT", 0);
statBoost.Add("LCK", 0);
}
void OnDisable(){
statBoost = new Dictionary<string, int>();
}
public void addItem(Item item)
@@ -195,6 +195,41 @@ namespace Assets.Scripts
public Dictionary<string, int> getEquipmentBonus()
{
createStatBoost();
GameObject equip = head;
for (int i = 0; i < 8; i++)
{
switch (i)
{
case 0:
equip = head;
break;
case 1:
equip = rightHand;
break;
case 2:
equip = leftHand;
break;
case 3:
equip = amulet;
break;
case 4:
equip = feet;
break;
case 5:
equip = shoulders;
break;
case 6:
equip = chest;
break;
case 7:
equip = ring;
break;
}
if (equip.GetComponent<InventorySlot>().getEquip() != null)
{
calculateStatBoost(equip.GetComponent<InventorySlot>().getEquip().getAttributes(), true);
}
}
return statBoost;
}

View File

@@ -118,7 +118,7 @@ namespace Assets.Scripts
}
else
{
itemName = place.ToString() + " of " + itemName + " attribute \r\n (" + rarity.ToString() + ")";
itemName = place.ToString() + " of " + itemName + " attribute (" + rarity.ToString() + ")";
}
}
@@ -126,11 +126,11 @@ namespace Assets.Scripts
{
if (replacement.Length > 0)
{
itemName = replacement + " \r\n" + rarity.ToString();
itemName = replacement + " " + rarity.ToString();
}
else
{
itemName = place.ToString() + " \r\n" + rarity.ToString();
itemName = place.ToString() + " " + rarity.ToString();
}
}
itemName = itemName.ToLower();

8
Assets/Scripts/UI.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7b28188d6b76b96d38e71a4b554ef98f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: