Added interaction for trees and stones, added items wood, stone, book and slimeball, v1.4.0
This commit is contained in:
@@ -9,13 +9,21 @@ namespace Assets.Scripts
|
||||
{
|
||||
public Book(int luck) : base(luck)
|
||||
{
|
||||
|
||||
itemName = "The kings diary #1";
|
||||
loadImage();
|
||||
rarityColor = Color.white;
|
||||
}
|
||||
|
||||
public Book(JToken json) : base(json)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
override
|
||||
protected void loadImage()
|
||||
{
|
||||
image = Resources.Load<Texture>("Items/Inv_Book");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -357,19 +357,32 @@ namespace Assets.Scripts
|
||||
Item endItem = endDrag.getItem(endDrag.getCurrentBag());
|
||||
if (endItem != null)
|
||||
{
|
||||
if (((Equipment)endItem).getPlace() != startDrag.place)
|
||||
if (endItem is Equipment)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (startDrag.place == ItemPlace.BAG)
|
||||
{
|
||||
startDrag.setItem(endItem, endDrag.getCurrentBag());
|
||||
if (((Equipment)endItem).getPlace() != startDrag.place)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
startDrag.setEquip((Equipment)endItem);
|
||||
inventory.calculateStatBoost(attributes, false);
|
||||
inventory.calculateStatBoost(((Equipment)endItem).getAttributes(), true);
|
||||
if (startDrag.place == ItemPlace.BAG)
|
||||
{
|
||||
startDrag.setItem(endItem, endDrag.getCurrentBag());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (endItem is Equipment)
|
||||
{
|
||||
startDrag.setEquip((Equipment)endItem);
|
||||
inventory.calculateStatBoost(attributes, false);
|
||||
inventory.calculateStatBoost(((Equipment)endItem).getAttributes(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
isSwap = true;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,19 @@ namespace Assets.Scripts
|
||||
{
|
||||
luck = luck + GameObject.Find("Inventory").GetComponent<Inventory>().getEquipmentBonus()["LCK"];
|
||||
calculateRarity(luck);
|
||||
chooseItem();
|
||||
setColor();
|
||||
loadImage();
|
||||
}
|
||||
|
||||
public Item(string name)
|
||||
{
|
||||
rarity = ItemRarity.COMMON;
|
||||
itemName = name;
|
||||
rarityColor = Color.white;
|
||||
loadImage();
|
||||
}
|
||||
|
||||
public Item(JToken json)
|
||||
{
|
||||
rarity = (ItemRarity)Enum.Parse(typeof(ItemRarity), json["rarity"].ToString());
|
||||
@@ -72,7 +81,18 @@ namespace Assets.Scripts
|
||||
|
||||
protected virtual void loadImage()
|
||||
{
|
||||
|
||||
switch (itemName)
|
||||
{
|
||||
case "Slimeball":
|
||||
image = Resources.Load<Texture>("Items/Inv_Slimeball");
|
||||
break;
|
||||
case "Wood":
|
||||
image = Resources.Load<Texture>("Items/Inv_Wood");
|
||||
break;
|
||||
case "Stone":
|
||||
image = Resources.Load<Texture>("Items/Inv_Stone");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string saveGame()
|
||||
@@ -100,7 +120,20 @@ namespace Assets.Scripts
|
||||
|
||||
public virtual string getInformation()
|
||||
{
|
||||
return "";
|
||||
string result = "";
|
||||
switch (itemName)
|
||||
{
|
||||
case "Slimeball":
|
||||
result = "Soft and sticky... Does it have a use?";
|
||||
break;
|
||||
case "Wood":
|
||||
result = "Quite a nice piece of wood";
|
||||
break;
|
||||
case "Stone":
|
||||
result = "A small stone to craft with";
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual void move(InventorySlot startDrag, Inventory inventory, InventorySlot endDrag)
|
||||
@@ -114,9 +147,39 @@ namespace Assets.Scripts
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
endDrag.setItem(this, startDrag.getCurrentBag());
|
||||
startDrag.setItem(item, endDrag.getCurrentBag());
|
||||
}
|
||||
else
|
||||
{
|
||||
startDrag.removeItem();
|
||||
}
|
||||
|
||||
endDrag.setItem(this, startDrag.getCurrentBag());
|
||||
}
|
||||
|
||||
private void chooseItem()
|
||||
{
|
||||
/* Common: Slimeball
|
||||
* Rare:
|
||||
* Epic:
|
||||
* Legendary:
|
||||
*/
|
||||
int index = rand.Next(10);
|
||||
switch (rarity)
|
||||
{
|
||||
case ItemRarity.COMMON:
|
||||
itemName = "Slimeball";
|
||||
break;
|
||||
case ItemRarity.RARE:
|
||||
itemName = "Slimeball";
|
||||
break;
|
||||
case ItemRarity.EPIC:
|
||||
itemName = "Slimeball";
|
||||
break;
|
||||
case ItemRarity.LEGENDARY:
|
||||
itemName = "Slimeball";
|
||||
break;
|
||||
}
|
||||
startDrag.setItem(item, endDrag.getCurrentBag());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user