Items adjusted prices
fixed some Tile sheeesh selling overflowing Items in Inventory (over 999)
This commit is contained in:
parent
79e86e343c
commit
cdd8ae7441
21 changed files with 106 additions and 84 deletions
|
|
@ -35,8 +35,8 @@ RectTransform:
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 1, y: 0}
|
m_AnchorMin: {x: 1, y: 0}
|
||||||
m_AnchorMax: {x: 1, y: 0}
|
m_AnchorMax: {x: 1, y: 0}
|
||||||
m_AnchoredPosition: {x: -15, y: 15}
|
m_AnchoredPosition: {x: -20.432114, y: 15}
|
||||||
m_SizeDelta: {x: 20, y: 20}
|
m_SizeDelta: {x: 35, y: 20}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &6965159940483216022
|
--- !u!222 &6965159940483216022
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
|
|
@ -96,11 +96,11 @@ MonoBehaviour:
|
||||||
m_fontSize: 20
|
m_fontSize: 20
|
||||||
m_fontSizeBase: 20
|
m_fontSizeBase: 20
|
||||||
m_fontWeight: 400
|
m_fontWeight: 400
|
||||||
m_enableAutoSizing: 0
|
m_enableAutoSizing: 1
|
||||||
m_fontSizeMin: 18
|
m_fontSizeMin: 20
|
||||||
m_fontSizeMax: 72
|
m_fontSizeMax: 72
|
||||||
m_fontStyle: 0
|
m_fontStyle: 0
|
||||||
m_HorizontalAlignment: 1
|
m_HorizontalAlignment: 4
|
||||||
m_VerticalAlignment: 256
|
m_VerticalAlignment: 256
|
||||||
m_textAlignment: 65535
|
m_textAlignment: 65535
|
||||||
m_characterSpacing: 0
|
m_characterSpacing: 0
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
displayName: Bait
|
displayName: Bait
|
||||||
description: nom nom nom
|
description: nom nom nom
|
||||||
id: 0
|
|
||||||
selectedSprite: {fileID: 21300000, guid: 423719dfe7ab82942bf923c4b53737a0, type: 3}
|
selectedSprite: {fileID: 21300000, guid: 423719dfe7ab82942bf923c4b53737a0, type: 3}
|
||||||
defaultSprite: {fileID: 21300000, guid: dccb93f4efdee0745a197bd2fa7fddf3, type: 3}
|
defaultSprite: {fileID: 21300000, guid: dccb93f4efdee0745a197bd2fa7fddf3, type: 3}
|
||||||
price: 420
|
price: 80
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,4 @@ MonoBehaviour:
|
||||||
description: Used to slap people.
|
description: Used to slap people.
|
||||||
selectedSprite: {fileID: 21300000, guid: 8c01c1a230575ac4bb0aee5ba1c7757a, type: 3}
|
selectedSprite: {fileID: 21300000, guid: 8c01c1a230575ac4bb0aee5ba1c7757a, type: 3}
|
||||||
defaultSprite: {fileID: 21300000, guid: d1b54b7f17e2d4d4e82d50d710d4482c, type: 3}
|
defaultSprite: {fileID: 21300000, guid: d1b54b7f17e2d4d4e82d50d710d4482c, type: 3}
|
||||||
cost: 150
|
price: 150
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
displayName: Fishing Rod
|
displayName: Fishing Rod
|
||||||
description: Used to fish fish.
|
description: Used to fish fish.
|
||||||
id: 5
|
|
||||||
selectedSprite: {fileID: 21300000, guid: 29803b4d3ea05bc40b6a0ba9079789c7, type: 3}
|
selectedSprite: {fileID: 21300000, guid: 29803b4d3ea05bc40b6a0ba9079789c7, type: 3}
|
||||||
defaultSprite: {fileID: 21300000, guid: ea463a9346e5ff444b977261452fce7f, type: 3}
|
defaultSprite: {fileID: 21300000, guid: ea463a9346e5ff444b977261452fce7f, type: 3}
|
||||||
price: 100
|
price: 500
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
displayName: Hoe
|
displayName: Hoe
|
||||||
description: on the streets
|
description: on the streets
|
||||||
id: 0
|
|
||||||
selectedSprite: {fileID: 21300000, guid: 2b99ea4b77726f546a2925690263b82e, type: 3}
|
selectedSprite: {fileID: 21300000, guid: 2b99ea4b77726f546a2925690263b82e, type: 3}
|
||||||
defaultSprite: {fileID: 21300000, guid: b1cc4f234b4dc684a84810adb240bf16, type: 3}
|
defaultSprite: {fileID: 21300000, guid: b1cc4f234b4dc684a84810adb240bf16, type: 3}
|
||||||
price: 50
|
price: 250
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
displayName: Scythe
|
displayName: Scythe
|
||||||
description: better than in stardew valley
|
description: better than in stardew valley
|
||||||
id: 1
|
|
||||||
selectedSprite: {fileID: 21300000, guid: d63f6b4dcc888bb4a9eab8c6175262f6, type: 3}
|
selectedSprite: {fileID: 21300000, guid: d63f6b4dcc888bb4a9eab8c6175262f6, type: 3}
|
||||||
defaultSprite: {fileID: 21300000, guid: a08b63f61c1016646b88dba4640a10d1, type: 3}
|
defaultSprite: {fileID: 21300000, guid: a08b63f61c1016646b88dba4640a10d1, type: 3}
|
||||||
price: 60
|
price: 250
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
displayName: Shovel
|
displayName: Shovel
|
||||||
description: Used to dig ground.
|
description: Used to dig ground.
|
||||||
id: 6
|
|
||||||
selectedSprite: {fileID: 21300000, guid: 58952d7ae1da0f0468af9c9d916af2fc, type: 3}
|
selectedSprite: {fileID: 21300000, guid: 58952d7ae1da0f0468af9c9d916af2fc, type: 3}
|
||||||
defaultSprite: {fileID: 21300000, guid: 1ea3a182dfc173440993d81065fdbdf0, type: 3}
|
defaultSprite: {fileID: 21300000, guid: 1ea3a182dfc173440993d81065fdbdf0, type: 3}
|
||||||
cost: 200
|
price: 500
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
displayName: Watering Can
|
displayName: Watering Can
|
||||||
description: Waters with water
|
description: Waters with water
|
||||||
id: 2
|
|
||||||
selectedSprite: {fileID: 21300000, guid: 232469852165c5640a76569b41ae3987, type: 3}
|
selectedSprite: {fileID: 21300000, guid: 232469852165c5640a76569b41ae3987, type: 3}
|
||||||
defaultSprite: {fileID: 21300000, guid: eb0fc176cd1c0874da4fcadbc8938ff4, type: 3}
|
defaultSprite: {fileID: 21300000, guid: eb0fc176cd1c0874da4fcadbc8938ff4, type: 3}
|
||||||
price: 80
|
price: 100
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
displayName: Wheat Seeds
|
displayName: Wheat Seeds
|
||||||
description: sheeeeeeeeeeeesh
|
description: sheeeeeeeeeeeesh
|
||||||
id: 3
|
|
||||||
selectedSprite: {fileID: 21300000, guid: f20f809a862a67b408c2b7fe11e87605, type: 3}
|
selectedSprite: {fileID: 21300000, guid: f20f809a862a67b408c2b7fe11e87605, type: 3}
|
||||||
defaultSprite: {fileID: 21300000, guid: aca4991443af2a140b7400c8e4a003a1, type: 3}
|
defaultSprite: {fileID: 21300000, guid: aca4991443af2a140b7400c8e4a003a1, type: 3}
|
||||||
price: 69
|
price: 20
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,8 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 5f096d187f76a734fac022700054dfec, type: 3}
|
m_Script: {fileID: 11500000, guid: 5f096d187f76a734fac022700054dfec, type: 3}
|
||||||
m_Name: Wheat
|
m_Name: Wheat
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
displayName:
|
displayName: Wheat
|
||||||
description:
|
description: weizenmann
|
||||||
id: 0
|
selectedSprite: {fileID: 21300104, guid: 2700e06d970d112489ff23cfb58c3f78, type: 3}
|
||||||
selectedSprite: {fileID: 0}
|
defaultSprite: {fileID: 21300104, guid: 2700e06d970d112489ff23cfb58c3f78, type: 3}
|
||||||
defaultSprite: {fileID: 0}
|
price: 50
|
||||||
price: 0
|
|
||||||
|
|
|
||||||
|
|
@ -1670,8 +1670,8 @@ MonoBehaviour:
|
||||||
m_TargetGraphic: {fileID: 2006577139}
|
m_TargetGraphic: {fileID: 2006577139}
|
||||||
m_HandleRect: {fileID: 2006577138}
|
m_HandleRect: {fileID: 2006577138}
|
||||||
m_Direction: 2
|
m_Direction: 2
|
||||||
m_Value: 1
|
m_Value: 0.9999999
|
||||||
m_Size: 0.5386614
|
m_Size: 0.53866136
|
||||||
m_NumberOfSteps: 0
|
m_NumberOfSteps: 0
|
||||||
m_OnValueChanged:
|
m_OnValueChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
|
@ -6669,7 +6669,6 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
itemsParent: {fileID: 610140154}
|
itemsParent: {fileID: 610140154}
|
||||||
shopUI: {fileID: 1671356616}
|
shopUI: {fileID: 1671356616}
|
||||||
shopIsOpen: 0
|
|
||||||
inventoryUI: {fileID: 1609015285}
|
inventoryUI: {fileID: 1609015285}
|
||||||
--- !u!224 &1551890462 stripped
|
--- !u!224 &1551890462 stripped
|
||||||
RectTransform:
|
RectTransform:
|
||||||
|
|
@ -6869,6 +6868,20 @@ MonoBehaviour:
|
||||||
- {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, type: 2}
|
- {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, type: 2}
|
||||||
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
- {fileID: 11400000, guid: 6bac44b5c4527b641a3ae772d217ec43, type: 2}
|
||||||
|
- {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2}
|
||||||
|
- {fileID: 11400000, guid: ea1a26b19bc34a0ba29bad77253c7266, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a5d525b8ca07172499e8678eb6f73fb2, type: 2}
|
||||||
|
itemWasBought: 0
|
||||||
--- !u!1001 &1701153146
|
--- !u!1001 &1701153146
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -7225,6 +7238,7 @@ GameObject:
|
||||||
- component: {fileID: 1800469989}
|
- component: {fileID: 1800469989}
|
||||||
- component: {fileID: 1800469991}
|
- component: {fileID: 1800469991}
|
||||||
- component: {fileID: 1800469992}
|
- component: {fileID: 1800469992}
|
||||||
|
- component: {fileID: 1800469993}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Player
|
m_Name: Player
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -7244,7 +7258,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: b18feac5270242d4a85c78ce72972d56, type: 3}
|
m_Script: {fileID: 11500000, guid: b18feac5270242d4a85c78ce72972d56, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
startMoney: 10000
|
startMoney: 1000
|
||||||
moneyTextMeshProUGUI: {fileID: 1347709342}
|
moneyTextMeshProUGUI: {fileID: 1347709342}
|
||||||
--- !u!4 &1800469990
|
--- !u!4 &1800469990
|
||||||
Transform:
|
Transform:
|
||||||
|
|
@ -7273,14 +7287,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: a6462fee9117d354abebcd1ff897b920, type: 3}
|
m_Script: {fileID: 11500000, guid: a6462fee9117d354abebcd1ff897b920, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
startItems:
|
startItems: []
|
||||||
- {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2}
|
|
||||||
- {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2}
|
|
||||||
- {fileID: 11400000, guid: ea1a26b19bc34a0ba29bad77253c7266, type: 2}
|
|
||||||
- {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, type: 2}
|
|
||||||
- {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2}
|
|
||||||
- {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2}
|
|
||||||
- {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2}
|
|
||||||
--- !u!114 &1800469992
|
--- !u!114 &1800469992
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -7293,6 +7300,19 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 05183797fdda4aa9ac518eee0d2d85d4, type: 3}
|
m_Script: {fileID: 11500000, guid: 05183797fdda4aa9ac518eee0d2d85d4, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!114 &1800469993
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1800469988}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 00d85fb65e728cd429cb33d865a5d31a, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_exMark: {fileID: 615358670}
|
||||||
--- !u!1001 &1805366398
|
--- !u!1001 &1805366398
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,13 @@ public class Crop {
|
||||||
Debug.Log("Crop.Clicked UsableItem " + usableItem);
|
Debug.Log("Crop.Clicked UsableItem " + usableItem);
|
||||||
if(usableItem != null) {
|
if(usableItem != null) {
|
||||||
ItemContainer ic = ItemContainer.Instance;
|
ItemContainer ic = ItemContainer.Instance;
|
||||||
if(ic.GetItemIdByName("Hoe") == usableItem.id) {
|
if(ic.GetItemIdByName("Hoe") == usableItem.Id) {
|
||||||
ApplyAction(Hoe);
|
ApplyAction(Hoe);
|
||||||
} else if(ic.GetItemIdByName("Scythe") == usableItem.id) {
|
} else if(ic.GetItemIdByName("Scythe") == usableItem.Id) {
|
||||||
ApplyAction(Scythe);
|
ApplyAction(Scythe);
|
||||||
} else if(ic.GetItemIdByName("Wheat Seeds") == usableItem.id) {
|
} else if(ic.GetItemIdByName("Wheat Seeds") == usableItem.Id) {
|
||||||
ApplyAction(Seeds);
|
ApplyAction(Seeds);
|
||||||
} else if(ic.GetItemIdByName("Watering Can") == usableItem.id) {
|
} else if(ic.GetItemIdByName("Watering Can") == usableItem.Id) {
|
||||||
ApplyAction(WateringCan);
|
ApplyAction(WateringCan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -111,6 +111,7 @@ public class Crop {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddCropToInventory() {
|
private void AddCropToInventory() {
|
||||||
|
Inventory.instance.AddItem(ItemContainer.Instance.GetItemByName("Wheat Seeds"), (int)(Random.Range(1,300)));
|
||||||
Inventory.instance.AddItem(ItemContainer.Instance.GetItemByName("Wheat"), 1);
|
Inventory.instance.AddItem(ItemContainer.Instance.GetItemByName("Wheat"), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class Inventory : ItemStorage {
|
public class Inventory : ItemStorage {
|
||||||
|
|
@ -15,17 +16,28 @@ public class Inventory : ItemStorage {
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private const int _InventorySpace = 28;
|
private const int InventorySpace = 28;
|
||||||
|
private const int MaxItemStack = 999;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified amount of items to the Inventory
|
* Adds the specified amount of items to the Inventory
|
||||||
*/
|
*/
|
||||||
public override void AddItem(Item item, int amount) {
|
public override void AddItem(Item item, int amount) {
|
||||||
if(items.Count >= _InventorySpace) {
|
if(items.Count >= InventorySpace) {
|
||||||
Debug.Log("Not enough inventory space!");
|
Debug.Log("Not enough inventory space!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Sell overflowing Items
|
||||||
|
if(items.ContainsKey(item) && items[item] + amount >= MaxItemStack) {
|
||||||
|
SellItem(item, amount - (MaxItemStack - items[item]));
|
||||||
|
amount = MaxItemStack - items[item];
|
||||||
|
}
|
||||||
base.AddItem(item, amount);
|
base.AddItem(item, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SellItem(Item item, int amount) {
|
||||||
|
PlayerController.instance.ChangeMoney(item.SellPrice);
|
||||||
|
Shop.instance.AddItem(item, amount);
|
||||||
|
RemoveItem(item, amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,8 @@ public class InventorySlot : ItemStorageSlot, IPointerClickHandler {
|
||||||
* Sells the Item for the Item Sell Price and puts it in the Shop if the selling was a mistake
|
* Sells the Item for the Item Sell Price and puts it in the Shop if the selling was a mistake
|
||||||
*/
|
*/
|
||||||
private void SellItem() {
|
private void SellItem() {
|
||||||
if(Item){
|
if(Item) {
|
||||||
_playerController.ChangeMoney(Item.SellPrice);
|
_inventory.SellItem(Item, 1); //TODO: wie machen mehr als 1 verkaufen?!
|
||||||
_shop.AddItem(Item, 1);
|
|
||||||
_inventory.RemoveItem(Item, 1); // TODO: somehow sell more than 1 Item
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public class Item : ScriptableObject, IComparable<Item> {
|
||||||
public Sprite defaultSprite;
|
public Sprite defaultSprite;
|
||||||
public int price;
|
public int price;
|
||||||
public int SellPrice => Convert.ToInt32(price * 0.8);
|
public int SellPrice => Convert.ToInt32(price * 0.8);
|
||||||
ic int ID => _id;
|
public int Id => _id;
|
||||||
|
|
||||||
public Item(string displayName, string description, int id) {
|
public Item(string displayName, string description, int id) {
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,6 @@ public class ItemContainer : MonoBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetItemIdByName(String name) {
|
public int GetItemIdByName(String name) {
|
||||||
return GetItemByName(name).ID;
|
return GetItemByName(name).Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ public class ItemStorageSlot : MonoBehaviour, IPointerEnterHandler, IPointerExit
|
||||||
_item = null;
|
_item = null;
|
||||||
icon.sprite = null;
|
icon.sprite = null;
|
||||||
icon.enabled = false;
|
icon.enabled = false;
|
||||||
|
amountText.text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,43 +2,32 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Tiles
|
namespace Tiles {
|
||||||
{
|
public abstract class BaseTile {
|
||||||
public abstract class BaseTile
|
|
||||||
{
|
|
||||||
private Sprite _sprite;
|
private Sprite _sprite;
|
||||||
public Sprite Sprite => _sprite;
|
public Sprite Sprite => _sprite;
|
||||||
|
|
||||||
protected GameObject _gameObject;
|
protected GameObject _gameObject;
|
||||||
|
|
||||||
protected BaseTile(String pathToImageFile, GameObject gameObject)
|
protected BaseTile(String pathToImageFile, GameObject gameObject) {
|
||||||
{
|
_gameObject = gameObject;
|
||||||
this._gameObject = gameObject;
|
_sprite = GenerateSpriteFromFile(pathToImageFile);
|
||||||
this._sprite = GenerateSpriteFromFile(pathToImageFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DayLightStep()
|
|
||||||
HouseController.NewDayEvent.AddListener(DayLightStep);
|
HouseController.NewDayEvent.AddListener(DayLightStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DayLightStep()
|
public virtual void DayLightStep() { }
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public virtual BaseTile Clicked(UsableItem usable) {
|
||||||
|
|
||||||
public virtual BaseTile Clicked(UsableItem usable)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public Sprite GenerateSpriteFromFile(String pathToImageFile)
|
static public Sprite GenerateSpriteFromFile(String pathToImageFile) {
|
||||||
{
|
|
||||||
byte[] data = File.ReadAllBytes(pathToImageFile);
|
byte[] data = File.ReadAllBytes(pathToImageFile);
|
||||||
Texture2D texture = new Texture2D(32, 32, TextureFormat.ARGB32, false);
|
Texture2D texture = new Texture2D(32, 32, TextureFormat.ARGB32, false);
|
||||||
texture.LoadImage(data);
|
texture.LoadImage(data);
|
||||||
Sprite sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 32);
|
Sprite sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height),
|
||||||
|
new Vector2(0.5f, 0.5f), 32);
|
||||||
return sprite;
|
return sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,7 @@ namespace Tiles
|
||||||
{
|
{
|
||||||
public class GrassTile : BaseTile
|
public class GrassTile : BaseTile
|
||||||
{
|
{
|
||||||
public GrassTile() : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_000.png")
|
public GrassTile(GameObject gameObject) : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_000.png", gameObject)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -20,10 +20,10 @@ namespace Tiles
|
||||||
if (usable != null)
|
if (usable != null)
|
||||||
{
|
{
|
||||||
base.Clicked(usable);
|
base.Clicked(usable);
|
||||||
if (usable.ID == ic.GetItemIdByName("Hoe")) {
|
if (usable.Id == ic.GetItemIdByName("Hoe")) {
|
||||||
rv = new FarmlandTile();
|
rv = new FarmlandTile(_gameObject);
|
||||||
} else if (usable.ID == ic.GetItemIdByName("Shovel")) {
|
} else if (usable.Id == ic.GetItemIdByName("Shovel")) {
|
||||||
rv = new WaterTile();
|
rv = new WaterTile(_gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Tiles {
|
namespace Tiles {
|
||||||
public class WaterTile : BaseTile {
|
public class WaterTile : BaseTile {
|
||||||
public WaterTile() : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_023.png") {
|
public WaterTile(GameObject gameObject) : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_023.png", gameObject) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BaseTile Clicked(UsableItem usable) {
|
public override BaseTile Clicked(UsableItem usable) {
|
||||||
|
|
@ -12,15 +12,15 @@ namespace Tiles {
|
||||||
|
|
||||||
ItemContainer ic = ItemContainer.Instance;
|
ItemContainer ic = ItemContainer.Instance;
|
||||||
|
|
||||||
if (usable.ID == ic.GetItemIdByName("Fishing Rod")) {
|
if (usable.Id == ic.GetItemIdByName("Fishing Rod")) {
|
||||||
FishingController fc = FishingController.instance;
|
FishingController fc = FishingController.instance;
|
||||||
if (!fc.Fishing) {
|
if (!fc.Fishing) {
|
||||||
fc.StartFishing();
|
fc.StartFishing();
|
||||||
} else {
|
} else {
|
||||||
fc.TryCatch();
|
fc.TryCatch();
|
||||||
}
|
}
|
||||||
} else if (usable.ID == ic.GetItemIdByName("Shovel")) {
|
} else if (usable.Id == ic.GetItemIdByName("Shovel")) {
|
||||||
rv = new GrassTile();
|
rv = new GrassTile(_gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
||||||
|
|
@ -137,12 +137,21 @@
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
|
"com.unity.nuget.newtonsoft-json": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"depth": 2,
|
||||||
|
"source": "registry",
|
||||||
|
"dependencies": {},
|
||||||
|
"url": "https://packages.unity.com"
|
||||||
|
},
|
||||||
"com.unity.services.core": {
|
"com.unity.services.core": {
|
||||||
"version": "1.0.1",
|
"version": "1.3.1",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.modules.unitywebrequest": "1.0.0"
|
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||||
|
"com.unity.nuget.newtonsoft-json": "3.0.2",
|
||||||
|
"com.unity.modules.androidjni": "1.0.0"
|
||||||
},
|
},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue