Added items, inventory, basic inv mechanics and art, added item comparison, v1.3.0
This commit is contained in:
@@ -114,6 +114,12 @@ namespace Assets.Scripts
|
||||
uihandler.switchPauseMenu();
|
||||
}
|
||||
|
||||
public void switchInventory()
|
||||
{
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.switchInventory();
|
||||
}
|
||||
|
||||
public void saveGame()
|
||||
{
|
||||
audioHandler.playButtonClick();
|
||||
|
||||
@@ -64,6 +64,10 @@ public class Controls : MonoBehaviour
|
||||
{
|
||||
uihandler.switchQuestLog();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.I))
|
||||
{
|
||||
uihandler.switchInventory();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
|
||||
@@ -121,6 +121,11 @@ namespace Assets.Scripts
|
||||
return slime.getExperience();
|
||||
}
|
||||
|
||||
public Item getItem()
|
||||
{
|
||||
return slime.getItem();
|
||||
}
|
||||
|
||||
public string saveEnemy()
|
||||
{
|
||||
string result = "";
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Fight : MonoBehaviour
|
||||
playerDamage = player.GetComponent<Player>().castSkill(skillnumber);
|
||||
}
|
||||
player.GetComponent<Player>().reduceCooldown(skillnumber);
|
||||
player.GetComponent<Player>().regainSecondary(2);
|
||||
player.GetComponent<Player>().regainSecondary();
|
||||
bool isDead = enemy.GetComponent<Enemy>().takeDamage(playerDamage);
|
||||
if (isDead)
|
||||
{
|
||||
@@ -73,6 +73,7 @@ public class Fight : MonoBehaviour
|
||||
tile.GetComponent<Tile>().enemyKilled(enemy);
|
||||
player.GetComponent<Player>().enemyKilled();
|
||||
player.GetComponent<Player>().gainExperience(enemy.GetComponent<Enemy>().getExperience());
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(enemy.GetComponent<Enemy>().getItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
181
Assets/Scripts/Inventory.cs
Normal file
181
Assets/Scripts/Inventory.cs
Normal file
@@ -0,0 +1,181 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class Inventory : MonoBehaviour
|
||||
{
|
||||
public GameObject head;
|
||||
public GameObject chest;
|
||||
public GameObject shoulders;
|
||||
public GameObject feet;
|
||||
public GameObject ring;
|
||||
public GameObject amulet;
|
||||
public GameObject hands;
|
||||
public GameObject leftHand;
|
||||
public GameObject rightHand;
|
||||
|
||||
public GameObject[] bags;
|
||||
public GameObject[] slots;
|
||||
|
||||
public int currentBag = -1;
|
||||
|
||||
GameObject startDrag;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
changeCurrentBag(0);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
checkInventoryColors();
|
||||
checkEquipColors();
|
||||
}
|
||||
|
||||
public void addItem(Item item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("SUCCESS;You got an item!");
|
||||
bool itemAdded = false;
|
||||
for (int i = 0; i < bags.Length; i++)
|
||||
{
|
||||
for (int j = 0; j < slots.Length; j++)
|
||||
{
|
||||
if (slots[j].GetComponent<InventorySlot>().getItem() == null)
|
||||
{
|
||||
slots[j].GetComponent<InventorySlot>().setItem(item);
|
||||
itemAdded = true;
|
||||
slots[j].GetComponent<RawImage>().color = Color.red;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (itemAdded)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void changeCurrentBag(int index)
|
||||
{
|
||||
if (currentBag != -1)
|
||||
{
|
||||
bags[currentBag].GetComponent<RawImage>().color = Color.white;
|
||||
}
|
||||
currentBag = index;
|
||||
bags[currentBag].GetComponent<RawImage>().color = Color.cyan;
|
||||
checkInventoryColors();
|
||||
foreach(GameObject slot in slots)
|
||||
{
|
||||
slot.GetComponent<InventorySlot>().updateCurrentBag(currentBag);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkInventoryColors()
|
||||
{
|
||||
for (int i = 0; i < slots.Length; i++)
|
||||
{
|
||||
if (slots[i].GetComponent<InventorySlot>().getItem() != null)
|
||||
{
|
||||
slots[i].GetComponent<RawImage>().color = Color.red;
|
||||
}
|
||||
else
|
||||
{
|
||||
slots[i].GetComponent<RawImage>().color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkEquipColors()
|
||||
{
|
||||
GameObject slot = head;
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
slot = head;
|
||||
break;
|
||||
case 1:
|
||||
slot = rightHand;
|
||||
break;
|
||||
case 2:
|
||||
slot = leftHand;
|
||||
break;
|
||||
case 3:
|
||||
slot = hands;
|
||||
break;
|
||||
case 4:
|
||||
slot = amulet;
|
||||
break;
|
||||
case 5:
|
||||
slot = feet;
|
||||
break;
|
||||
case 6:
|
||||
slot = shoulders;
|
||||
break;
|
||||
case 7:
|
||||
slot = chest;
|
||||
break;
|
||||
case 8:
|
||||
slot = ring;
|
||||
break;
|
||||
}
|
||||
if (slot.GetComponent<InventorySlot>().getEquip() != null)
|
||||
{
|
||||
slot.GetComponent<RawImage>().color = Color.red;
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.GetComponent<RawImage>().color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDrag(GameObject slot)
|
||||
{
|
||||
startDrag = slot;
|
||||
}
|
||||
|
||||
public GameObject getDrag()
|
||||
{
|
||||
return startDrag;
|
||||
}
|
||||
|
||||
public Item getEquip(ItemPlace place)
|
||||
{
|
||||
switch (place)
|
||||
{
|
||||
case ItemPlace.SHIELD:
|
||||
return leftHand.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.WEAPON:
|
||||
return rightHand.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.HELMET:
|
||||
return head.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.BOOTS:
|
||||
return feet.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.SHOULDER:
|
||||
return shoulders.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.AMULET:
|
||||
return amulet.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.RING:
|
||||
return ring.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.ARMOR:
|
||||
return chest.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.GLOVES:
|
||||
return hands.GetComponent<InventorySlot>().getEquip();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Inventory.cs.meta
Normal file
11
Assets/Scripts/Inventory.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78a3db482922b1c4385629b9511c9647
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
158
Assets/Scripts/InventorySlot.cs
Normal file
158
Assets/Scripts/InventorySlot.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class InventorySlot : MonoBehaviour
|
||||
{
|
||||
TooltipHandler tooltip;
|
||||
Item[] items = new Item[3];
|
||||
public bool[] itemRemoved = {false, false, false};
|
||||
int currentBag = 0;
|
||||
public ItemPlace place;
|
||||
Item equip;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
tooltip = GameObject.Find("TooltipHandler").GetComponent<TooltipHandler>();
|
||||
}
|
||||
|
||||
public void updateCurrentBag(int currentBag)
|
||||
{
|
||||
this.currentBag = currentBag;
|
||||
}
|
||||
|
||||
public void setItem(Item item)
|
||||
{
|
||||
items[currentBag] = item;
|
||||
itemRemoved[currentBag] = false;
|
||||
}
|
||||
|
||||
public Item getItem()
|
||||
{
|
||||
return items[currentBag];
|
||||
}
|
||||
|
||||
public void removeItem()
|
||||
{
|
||||
items[currentBag] = null;
|
||||
itemRemoved[currentBag] = true;
|
||||
}
|
||||
|
||||
public void showTooltip()
|
||||
{
|
||||
if (place == ItemPlace.BAG)
|
||||
{
|
||||
if (items[currentBag] != null)
|
||||
{
|
||||
string text = items[currentBag].getDisplayText();
|
||||
Item equip = GameObject.Find("Inventory").GetComponent<Inventory>().getEquip(items[currentBag].getPlace());
|
||||
if (equip != null)
|
||||
{
|
||||
text = "(Current)\r\n" + equip.getDisplayText() + "----------\r\n" + text;
|
||||
}
|
||||
tooltip.showTooltip(text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (equip != null)
|
||||
{
|
||||
tooltip.showTooltip(equip.getDisplayText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void hideTooltip()
|
||||
{
|
||||
tooltip.hideToolTip();
|
||||
}
|
||||
|
||||
public void onClick()
|
||||
{
|
||||
removeItem();
|
||||
tooltip.hideToolTip();
|
||||
}
|
||||
|
||||
public void OnMouseDrag()
|
||||
{
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().setDrag(gameObject);
|
||||
}
|
||||
|
||||
public void OnMouseUp()
|
||||
{
|
||||
GameObject startDrag = GameObject.Find("Inventory").GetComponent<Inventory>().getDrag();
|
||||
Item item;
|
||||
bool isSwap = false;
|
||||
if (startDrag.GetComponent<InventorySlot>().place == ItemPlace.BAG)
|
||||
{
|
||||
item = startDrag.GetComponent<InventorySlot>().getItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
item = startDrag.GetComponent<InventorySlot>().getEquip();
|
||||
}
|
||||
if (item != null)
|
||||
{
|
||||
if (place != item.getPlace() && place != ItemPlace.BAG)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (place == ItemPlace.BAG)
|
||||
{
|
||||
if (items[currentBag] != null)
|
||||
{
|
||||
startDrag.GetComponent<InventorySlot>().setItem(items[currentBag]);
|
||||
isSwap = true;
|
||||
}
|
||||
setItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (equip != null)
|
||||
{
|
||||
if (startDrag.GetComponent<InventorySlot>().place == ItemPlace.BAG)
|
||||
{
|
||||
startDrag.GetComponent<InventorySlot>().setItem(equip);
|
||||
isSwap = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
setEquip(item);
|
||||
}
|
||||
if (!isSwap)
|
||||
{
|
||||
if (startDrag.GetComponent<InventorySlot>().place != ItemPlace.BAG)
|
||||
{
|
||||
startDrag.GetComponent<InventorySlot>().removeEquip();
|
||||
}
|
||||
else
|
||||
{
|
||||
startDrag.GetComponent<InventorySlot>().removeItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Item getEquip()
|
||||
{
|
||||
return equip;
|
||||
}
|
||||
|
||||
public void setEquip(Item item)
|
||||
{
|
||||
equip = item;
|
||||
}
|
||||
|
||||
public void removeEquip()
|
||||
{
|
||||
equip = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/InventorySlot.cs.meta
Normal file
11
Assets/Scripts/InventorySlot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b661b52d4ccd19649bb6a1a5f1d9b893
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
204
Assets/Scripts/Item.cs
Normal file
204
Assets/Scripts/Item.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class Item
|
||||
{
|
||||
private System.Random rand = new System.Random();
|
||||
ItemRarity rarity;
|
||||
ItemPlace place;
|
||||
string itemName;
|
||||
Dictionary<string, int> attributes;
|
||||
|
||||
public Item(int luck)
|
||||
{
|
||||
attributes = new Dictionary<string, int>();
|
||||
int numberOfAttributes = 1;
|
||||
calculateRarity(luck);
|
||||
if (rarity > ItemRarity.COMMON)
|
||||
{
|
||||
numberOfAttributes = 2;
|
||||
}
|
||||
if (rarity > ItemRarity.RARE)
|
||||
{
|
||||
numberOfAttributes = 3;
|
||||
}
|
||||
if (rarity == ItemRarity.LEGENDARY)
|
||||
{
|
||||
numberOfAttributes = 0;
|
||||
}
|
||||
calculateAttributes(luck, numberOfAttributes);
|
||||
place = (ItemPlace)rand.Next(9);
|
||||
if (itemName != null)
|
||||
{
|
||||
itemName = rarity.ToString() + " " + place.ToString() + " of " + itemName;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemName = rarity.ToString() + " " + place.ToString();
|
||||
}
|
||||
itemName = itemName.ToLower();
|
||||
itemName = char.ToUpper(itemName[0]) + itemName.Substring(1);
|
||||
}
|
||||
|
||||
private void calculateRarity(int luck)
|
||||
{
|
||||
int number = rand.Next(101);
|
||||
if (number + luck < 74)
|
||||
{
|
||||
rarity = ItemRarity.COMMON;
|
||||
}
|
||||
else if (number + luck >= 75 && number + luck < 104)
|
||||
{
|
||||
rarity = ItemRarity.RARE;
|
||||
}
|
||||
else if (number + luck >= 105 && number + luck < 113)
|
||||
{
|
||||
rarity = ItemRarity.EPIC;
|
||||
}
|
||||
else if (number + luck >= 114)
|
||||
{
|
||||
rarity = ItemRarity.LEGENDARY;
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateAttributes(int luck, int numberOfAttributes)
|
||||
{
|
||||
if (numberOfAttributes != 0)
|
||||
{
|
||||
int[] indexes = new int[numberOfAttributes];
|
||||
int index;
|
||||
for (int i = 0; i < numberOfAttributes; i++)
|
||||
{
|
||||
index = calculateIndex(indexes);
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
if (i == 0)
|
||||
{
|
||||
itemName = "luck";
|
||||
}
|
||||
attributes.Add("LCK", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2)));
|
||||
break;
|
||||
case 1:
|
||||
if (i == 0)
|
||||
{
|
||||
itemName = "intelligence";
|
||||
}
|
||||
attributes.Add("INT", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2)));
|
||||
break;
|
||||
case 2:
|
||||
if (i == 0)
|
||||
{
|
||||
itemName = "dexterity";
|
||||
}
|
||||
attributes.Add("DEX", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2)));
|
||||
break;
|
||||
case 3:
|
||||
if (i == 0)
|
||||
{
|
||||
itemName = "strength";
|
||||
}
|
||||
attributes.Add("STR", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2)));
|
||||
break;
|
||||
case 4:
|
||||
if (i == 0)
|
||||
{
|
||||
itemName = "health";
|
||||
}
|
||||
attributes.Add("HP", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2)));
|
||||
break;
|
||||
case 5:
|
||||
if (i == 0)
|
||||
{
|
||||
itemName = "mana";
|
||||
}
|
||||
attributes.Add("MP", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2)));
|
||||
break;
|
||||
case 6:
|
||||
if (i == 0)
|
||||
{
|
||||
itemName = "health regeneration";
|
||||
}
|
||||
attributes.Add("HPR", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2)));
|
||||
break;
|
||||
case 7:
|
||||
if (i == 0)
|
||||
{
|
||||
itemName = "mana regeneration";
|
||||
}
|
||||
attributes.Add("MPR", Mathf.RoundToInt((float)(5 - (2 * i) + luck * 0.2)));
|
||||
break;
|
||||
}
|
||||
indexes[0] = index;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
attributes.Add("MPR", Mathf.RoundToInt((float)(5 + luck * 0.2)));
|
||||
attributes.Add("HPR", Mathf.RoundToInt((float)(5 + luck * 0.2)));
|
||||
attributes.Add("MP", Mathf.RoundToInt((float)(5 + luck * 0.2)));
|
||||
attributes.Add("HP", Mathf.RoundToInt((float)(5 + luck * 0.2)));
|
||||
attributes.Add("STR", Mathf.RoundToInt((float)(5 + luck * 0.2)));
|
||||
attributes.Add("DEX", Mathf.RoundToInt((float)(5 + luck * 0.2)));
|
||||
attributes.Add("INT", Mathf.RoundToInt((float)(5 + luck * 0.2)));
|
||||
attributes.Add("LCK", Mathf.RoundToInt((float)(5 + luck * 0.2)));
|
||||
}
|
||||
}
|
||||
|
||||
private int calculateIndex(int[] indexes)
|
||||
{
|
||||
int counter = 0;
|
||||
int index = 0;
|
||||
while (true)
|
||||
{
|
||||
index = rand.Next(8);
|
||||
counter = 0;
|
||||
for (int j = 0; j < indexes.Length; j++)
|
||||
{
|
||||
if (indexes[j] == index)
|
||||
{
|
||||
counter++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (counter == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
public string getName()
|
||||
{
|
||||
return itemName;
|
||||
}
|
||||
|
||||
public ItemPlace getPlace()
|
||||
{
|
||||
return place;
|
||||
}
|
||||
|
||||
public string getDisplayText()
|
||||
{
|
||||
string displayText = "";
|
||||
displayText = displayText + itemName + "\r\n";
|
||||
if (rarity == ItemRarity.LEGENDARY)
|
||||
{
|
||||
displayText = displayText + "All attributes: +" + attributes["STR"];
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string key in attributes.Keys)
|
||||
{
|
||||
displayText = displayText + key + ": +" + attributes[key] + "\r\n";
|
||||
}
|
||||
}
|
||||
return displayText;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Item.cs.meta
Normal file
11
Assets/Scripts/Item.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1538bd0f82fb96a43bba47a68a430dcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Items.meta
Normal file
8
Assets/Scripts/Items.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ea385be8a0d614459d7ca608d06b10d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/Scripts/Items/ItemPlace.cs
Normal file
22
Assets/Scripts/Items/ItemPlace.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public enum ItemPlace
|
||||
{
|
||||
HELMET,
|
||||
SHOULDER,
|
||||
WEAPON,
|
||||
SHIELD,
|
||||
GLOVES,
|
||||
RING,
|
||||
AMULET,
|
||||
ARMOR,
|
||||
BOOTS,
|
||||
BAG
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Items/ItemPlace.cs.meta
Normal file
11
Assets/Scripts/Items/ItemPlace.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a194de2ca78d01048924703904253d86
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/Items/ItemRarity.cs
Normal file
16
Assets/Scripts/Items/ItemRarity.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public enum ItemRarity
|
||||
{
|
||||
COMMON,
|
||||
RARE,
|
||||
EPIC,
|
||||
LEGENDARY
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Items/ItemRarity.cs.meta
Normal file
11
Assets/Scripts/Items/ItemRarity.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb1c2cc6603c0684cb04dc2d22ac95b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
0
Assets/Scripts/Items/sets.json
Normal file
0
Assets/Scripts/Items/sets.json
Normal file
7
Assets/Scripts/Items/sets.json.meta
Normal file
7
Assets/Scripts/Items/sets.json.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 648f691b06a71134d8ff2a5599a25c30
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -29,8 +29,11 @@ namespace Assets.Scripts
|
||||
int dexterity;
|
||||
int intelligence;
|
||||
int level;
|
||||
int luck;
|
||||
int experience;
|
||||
int maxExperience;
|
||||
int healthRegen;
|
||||
int secondaryRegen;
|
||||
BasicRace race;
|
||||
BasicClass role;
|
||||
BasicSkill[] skills = new BasicSkill[3];
|
||||
@@ -41,6 +44,13 @@ namespace Assets.Scripts
|
||||
int killcount = -1;
|
||||
int difficulty = 0;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
SceneHandler.switchGameToMenu();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@@ -67,7 +77,10 @@ namespace Assets.Scripts
|
||||
intelligence = 5;
|
||||
experience = 0;
|
||||
maxExperience = 10;
|
||||
healthRegen = 30 / (difficulty + 1);
|
||||
secondaryRegen = 5;
|
||||
level = 0;
|
||||
luck = 20 - (difficulty * 5);
|
||||
this.race = race;
|
||||
this.race.applyBonus(this);
|
||||
this.role = role;
|
||||
@@ -117,7 +130,10 @@ namespace Assets.Scripts
|
||||
intelligence = 5;
|
||||
experience = 0;
|
||||
maxExperience = 10;
|
||||
healthRegen = 30 / (difficulty + 1);
|
||||
secondaryRegen = 5;
|
||||
level = 0;
|
||||
luck = 20 - (difficulty * 5);
|
||||
this.race.applyBonus(this);
|
||||
this.role.applyBonus(this);
|
||||
this.difficulty = PlayerPrefs.GetInt("difficulty");
|
||||
@@ -189,7 +205,7 @@ namespace Assets.Scripts
|
||||
if (now.AddSeconds(10).CompareTo(DateTime.Now) <= 0)
|
||||
{
|
||||
now = DateTime.Now;
|
||||
regainSecondary(5);
|
||||
regainSecondary();
|
||||
healPlayer();
|
||||
}
|
||||
}
|
||||
@@ -200,9 +216,9 @@ namespace Assets.Scripts
|
||||
}
|
||||
}
|
||||
|
||||
public void regainSecondary(int amount)
|
||||
public void regainSecondary()
|
||||
{
|
||||
secondary = secondary + amount;
|
||||
secondary = secondary + secondaryRegen;
|
||||
if (secondary >= maxSecondary)
|
||||
{
|
||||
secondary = maxSecondary;
|
||||
@@ -211,7 +227,7 @@ namespace Assets.Scripts
|
||||
|
||||
private void healPlayer()
|
||||
{
|
||||
health = health + 30 / (difficulty + 1);
|
||||
health = health + healthRegen;
|
||||
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S))
|
||||
{
|
||||
health = health + 5;
|
||||
@@ -300,7 +316,7 @@ namespace Assets.Scripts
|
||||
|
||||
public int[] getStats()
|
||||
{
|
||||
int[] result = { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence, level, experience, maxExperience, points};
|
||||
int[] result = { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence, level, experience, maxExperience, points, luck};
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -463,6 +479,7 @@ namespace Assets.Scripts
|
||||
uihandler.showMessage("SUCCESS;You gained a level!");
|
||||
points = points + 3;
|
||||
audioHandler.playLevelUp();
|
||||
luck = luck + 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,8 +606,11 @@ namespace Assets.Scripts
|
||||
result = result + FileHandler.generateJSON("race", "\"" + race.racename + "\"") + ",\r\n";
|
||||
result = result + FileHandler.generateJSON("role", "\"" + role.classname + "\"") + ",\r\n";
|
||||
result = result + FileHandler.generateJSON("points", points) + ",\r\n";
|
||||
result = result + FileHandler.generateJSON("healthRegen", healthRegen) + ",\r\n";
|
||||
result = result + FileHandler.generateJSON("secondaryRegen", secondaryRegen) + ",\r\n";
|
||||
result = result + FileHandler.generateJSON("isDodging", "\"" + isDodging + "\"") + ",\r\n";
|
||||
result = result + FileHandler.generateJSON("killcount", killcount) + ",\r\n";
|
||||
result = result + FileHandler.generateJSON("luck", luck) + ",\r\n";
|
||||
result = result + FileHandler.generateJSON("difficulty", difficulty);
|
||||
return result;
|
||||
}
|
||||
@@ -611,6 +631,9 @@ namespace Assets.Scripts
|
||||
loadRole(json["role"].ToString());
|
||||
loadRace(json["race"].ToString());
|
||||
points = (int)json["points"];
|
||||
luck = (int)json["luck"];
|
||||
healthRegen = (int)json["healthRegen"];
|
||||
secondaryRegen = (int)json["secondaryRegen"];
|
||||
isDodging = bool.Parse(json["isDodging"].ToString());
|
||||
killcount = (int)json["killcount"];
|
||||
difficulty = (int)json["difficulty"];
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Assets.Scripts
|
||||
{
|
||||
public class SceneHandler : MonoBehaviour
|
||||
{
|
||||
|
||||
static bool sceneSwitched = false;
|
||||
private void OnEnable()
|
||||
{
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
@@ -51,6 +51,15 @@ namespace Assets.Scripts
|
||||
SceneManager.LoadScene("GameScene");
|
||||
}
|
||||
|
||||
public static void switchGameToMenu()
|
||||
{
|
||||
if (!sceneSwitched)
|
||||
{
|
||||
SceneManager.LoadScene("MenuScene");
|
||||
sceneSwitched = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
if (scene.name == "GameScene")
|
||||
|
||||
@@ -18,10 +18,11 @@ namespace Assets.Scripts.Slimes
|
||||
protected int intelligence;
|
||||
protected int level;
|
||||
protected int experience;
|
||||
protected Item item;
|
||||
|
||||
public BasicSlime(Player player)
|
||||
{
|
||||
// { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence, playerlevel};
|
||||
//health,maxHealth,secondary,maxSecondary,strength,dexterity,intelligence,level,experience,maxExperience,points,luck
|
||||
int[] playerStats = player.getStats();
|
||||
maxHealth = playerStats[1];
|
||||
health = maxHealth;
|
||||
@@ -32,6 +33,10 @@ namespace Assets.Scripts.Slimes
|
||||
intelligence = playerStats[6];
|
||||
experience = (int)(10 + playerStats[7] * 2.5f);
|
||||
level = playerStats[7];
|
||||
if (new System.Random().Next(100) + 1 < 1000)//50 + playerStats[11])
|
||||
{
|
||||
item = new Item(playerStats[11]);
|
||||
}
|
||||
}
|
||||
|
||||
public BasicSlime(JToken json)
|
||||
@@ -95,6 +100,11 @@ namespace Assets.Scripts.Slimes
|
||||
return experience;
|
||||
}
|
||||
|
||||
public Item getItem()
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
public string saveSlime()
|
||||
{
|
||||
string result = "";
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Assets.Scripts
|
||||
public GameObject tooltip;
|
||||
public GameObject tutorial;
|
||||
public GameObject buttonsHUD;
|
||||
public GameObject inventory;
|
||||
public GameObject waterLayer;
|
||||
|
||||
public UIState state;
|
||||
@@ -80,7 +81,7 @@ namespace Assets.Scripts
|
||||
|
||||
public bool canPlayerMove()
|
||||
{
|
||||
if (state == UIState.GAME || state == UIState.CHARACTER || state == UIState.QUEST)
|
||||
if (state == UIState.GAME || state == UIState.CHARACTER || state == UIState.QUEST || state == UIState.INVENTORY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -141,6 +142,31 @@ namespace Assets.Scripts
|
||||
state = UIState.GAME;
|
||||
}
|
||||
|
||||
public void switchInventory()
|
||||
{
|
||||
if (state == UIState.INVENTORY)
|
||||
{
|
||||
closeInventory();
|
||||
}
|
||||
else
|
||||
{
|
||||
openInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public void openInventory()
|
||||
{
|
||||
hideOtherElements(inventory);
|
||||
state = UIState.INVENTORY;
|
||||
}
|
||||
|
||||
public void closeInventory()
|
||||
{
|
||||
inventory.transform.localScale = new Vector3(0, 0, 0);
|
||||
showHUD();
|
||||
state = UIState.GAME;
|
||||
}
|
||||
|
||||
public void openFight()
|
||||
{
|
||||
GameObject.Find("txtRounds").GetComponent<Text>().text = "-1";
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Assets.Scripts
|
||||
PAUSE,
|
||||
PAUSEOPTIONS,
|
||||
TUTORIAL,
|
||||
QUEST
|
||||
QUEST,
|
||||
INVENTORY
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user