Items adjusted prices

fixed some Tile sheeesh
selling overflowing Items in Inventory (over 999)
This commit is contained in:
d-hain 2022-06-09 00:42:36 +02:00
parent 79e86e343c
commit cdd8ae7441
21 changed files with 106 additions and 84 deletions

View file

@ -35,8 +35,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -15, y: 15}
m_SizeDelta: {x: 20, y: 20}
m_AnchoredPosition: {x: -20.432114, y: 15}
m_SizeDelta: {x: 35, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6965159940483216022
CanvasRenderer:
@ -96,11 +96,11 @@ MonoBehaviour:
m_fontSize: 20
m_fontSizeBase: 20
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_enableAutoSizing: 1
m_fontSizeMin: 20
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_HorizontalAlignment: 4
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0

View file

@ -14,7 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
displayName: Bait
description: nom nom nom
id: 0
selectedSprite: {fileID: 21300000, guid: 423719dfe7ab82942bf923c4b53737a0, type: 3}
defaultSprite: {fileID: 21300000, guid: dccb93f4efdee0745a197bd2fa7fddf3, type: 3}
price: 420
price: 80

View file

@ -16,4 +16,4 @@ MonoBehaviour:
description: Used to slap people.
selectedSprite: {fileID: 21300000, guid: 8c01c1a230575ac4bb0aee5ba1c7757a, type: 3}
defaultSprite: {fileID: 21300000, guid: d1b54b7f17e2d4d4e82d50d710d4482c, type: 3}
cost: 150
price: 150

View file

@ -14,7 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
displayName: Fishing Rod
description: Used to fish fish.
id: 5
selectedSprite: {fileID: 21300000, guid: 29803b4d3ea05bc40b6a0ba9079789c7, type: 3}
defaultSprite: {fileID: 21300000, guid: ea463a9346e5ff444b977261452fce7f, type: 3}
price: 100
price: 500

View file

@ -14,7 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
displayName: Hoe
description: on the streets
id: 0
selectedSprite: {fileID: 21300000, guid: 2b99ea4b77726f546a2925690263b82e, type: 3}
defaultSprite: {fileID: 21300000, guid: b1cc4f234b4dc684a84810adb240bf16, type: 3}
price: 50
price: 250

View file

@ -14,7 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
displayName: Scythe
description: better than in stardew valley
id: 1
selectedSprite: {fileID: 21300000, guid: d63f6b4dcc888bb4a9eab8c6175262f6, type: 3}
defaultSprite: {fileID: 21300000, guid: a08b63f61c1016646b88dba4640a10d1, type: 3}
price: 60
price: 250

View file

@ -14,7 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
displayName: Shovel
description: Used to dig ground.
id: 6
selectedSprite: {fileID: 21300000, guid: 58952d7ae1da0f0468af9c9d916af2fc, type: 3}
defaultSprite: {fileID: 21300000, guid: 1ea3a182dfc173440993d81065fdbdf0, type: 3}
cost: 200
price: 500

View file

@ -14,7 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
displayName: Watering Can
description: Waters with water
id: 2
selectedSprite: {fileID: 21300000, guid: 232469852165c5640a76569b41ae3987, type: 3}
defaultSprite: {fileID: 21300000, guid: eb0fc176cd1c0874da4fcadbc8938ff4, type: 3}
price: 80
price: 100

View file

@ -14,7 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
displayName: Wheat Seeds
description: sheeeeeeeeeeeesh
id: 3
selectedSprite: {fileID: 21300000, guid: f20f809a862a67b408c2b7fe11e87605, type: 3}
defaultSprite: {fileID: 21300000, guid: aca4991443af2a140b7400c8e4a003a1, type: 3}
price: 69
price: 20

View file

@ -12,9 +12,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5f096d187f76a734fac022700054dfec, type: 3}
m_Name: Wheat
m_EditorClassIdentifier:
displayName:
description:
id: 0
selectedSprite: {fileID: 0}
defaultSprite: {fileID: 0}
price: 0
displayName: Wheat
description: weizenmann
selectedSprite: {fileID: 21300104, guid: 2700e06d970d112489ff23cfb58c3f78, type: 3}
defaultSprite: {fileID: 21300104, guid: 2700e06d970d112489ff23cfb58c3f78, type: 3}
price: 50

View file

@ -1670,8 +1670,8 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 2006577139}
m_HandleRect: {fileID: 2006577138}
m_Direction: 2
m_Value: 1
m_Size: 0.5386614
m_Value: 0.9999999
m_Size: 0.53866136
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
@ -6669,7 +6669,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
itemsParent: {fileID: 610140154}
shopUI: {fileID: 1671356616}
shopIsOpen: 0
inventoryUI: {fileID: 1609015285}
--- !u!224 &1551890462 stripped
RectTransform:
@ -6869,6 +6868,20 @@ MonoBehaviour:
- {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, 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
PrefabInstance:
m_ObjectHideFlags: 0
@ -7225,6 +7238,7 @@ GameObject:
- component: {fileID: 1800469989}
- component: {fileID: 1800469991}
- component: {fileID: 1800469992}
- component: {fileID: 1800469993}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
@ -7244,7 +7258,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b18feac5270242d4a85c78ce72972d56, type: 3}
m_Name:
m_EditorClassIdentifier:
startMoney: 10000
startMoney: 1000
moneyTextMeshProUGUI: {fileID: 1347709342}
--- !u!4 &1800469990
Transform:
@ -7273,14 +7287,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a6462fee9117d354abebcd1ff897b920, type: 3}
m_Name:
m_EditorClassIdentifier:
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}
startItems: []
--- !u!114 &1800469992
MonoBehaviour:
m_ObjectHideFlags: 0
@ -7293,6 +7300,19 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 05183797fdda4aa9ac518eee0d2d85d4, type: 3}
m_Name:
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
PrefabInstance:
m_ObjectHideFlags: 0

View file

@ -59,13 +59,13 @@ public class Crop {
Debug.Log("Crop.Clicked UsableItem " + usableItem);
if(usableItem != null) {
ItemContainer ic = ItemContainer.Instance;
if(ic.GetItemIdByName("Hoe") == usableItem.id) {
if(ic.GetItemIdByName("Hoe") == usableItem.Id) {
ApplyAction(Hoe);
} else if(ic.GetItemIdByName("Scythe") == usableItem.id) {
} else if(ic.GetItemIdByName("Scythe") == usableItem.Id) {
ApplyAction(Scythe);
} else if(ic.GetItemIdByName("Wheat Seeds") == usableItem.id) {
} else if(ic.GetItemIdByName("Wheat Seeds") == usableItem.Id) {
ApplyAction(Seeds);
} else if(ic.GetItemIdByName("Watering Can") == usableItem.id) {
} else if(ic.GetItemIdByName("Watering Can") == usableItem.Id) {
ApplyAction(WateringCan);
}
}
@ -111,6 +111,7 @@ public class Crop {
}
private void AddCropToInventory() {
Inventory.instance.AddItem(ItemContainer.Instance.GetItemByName("Wheat Seeds"), (int)(Random.Range(1,300)));
Inventory.instance.AddItem(ItemContainer.Instance.GetItemByName("Wheat"), 1);
}

View file

@ -1,3 +1,4 @@
using System;
using UnityEngine;
public class Inventory : ItemStorage {
@ -15,17 +16,28 @@ public class Inventory : ItemStorage {
#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
*/
public override void AddItem(Item item, int amount) {
if(items.Count >= _InventorySpace) {
if(items.Count >= InventorySpace) {
Debug.Log("Not enough inventory space!");
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);
}
public void SellItem(Item item, int amount) {
PlayerController.instance.ChangeMoney(item.SellPrice);
Shop.instance.AddItem(item, amount);
RemoveItem(item, amount);
}
}

View file

@ -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
*/
private void SellItem() {
if(Item){
_playerController.ChangeMoney(Item.SellPrice);
_shop.AddItem(Item, 1);
_inventory.RemoveItem(Item, 1); // TODO: somehow sell more than 1 Item
if(Item) {
_inventory.SellItem(Item, 1); //TODO: wie machen mehr als 1 verkaufen?!
}
}

View file

@ -10,7 +10,7 @@ public class Item : ScriptableObject, IComparable<Item> {
public Sprite defaultSprite;
public int price;
public int SellPrice => Convert.ToInt32(price * 0.8);
ic int ID => _id;
public int Id => _id;
public Item(string displayName, string description, int id) {
this.displayName = displayName;

View file

@ -48,6 +48,6 @@ public class ItemContainer : MonoBehaviour {
}
public int GetItemIdByName(String name) {
return GetItemByName(name).ID;
return GetItemByName(name).Id;
}
}

View file

@ -71,6 +71,7 @@ public class ItemStorageSlot : MonoBehaviour, IPointerEnterHandler, IPointerExit
_item = null;
icon.sprite = null;
icon.enabled = false;
amountText.text = "";
}
/**

View file

@ -2,43 +2,32 @@ using System;
using System.IO;
using UnityEngine;
namespace Tiles
{
public abstract class BaseTile
{
namespace Tiles {
public abstract class BaseTile {
private Sprite _sprite;
public Sprite Sprite => _sprite;
protected GameObject _gameObject;
protected BaseTile(String pathToImageFile, GameObject gameObject)
{
this._gameObject = gameObject;
this._sprite = GenerateSpriteFromFile(pathToImageFile);
}
public void DayLightStep()
protected BaseTile(String pathToImageFile, GameObject gameObject) {
_gameObject = gameObject;
_sprite = GenerateSpriteFromFile(pathToImageFile);
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;
}
static public Sprite GenerateSpriteFromFile(String pathToImageFile)
{
static public Sprite GenerateSpriteFromFile(String pathToImageFile) {
byte[] data = File.ReadAllBytes(pathToImageFile);
Texture2D texture = new Texture2D(32, 32, TextureFormat.ARGB32, false);
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;
}
}
}

View file

@ -4,7 +4,7 @@ namespace Tiles
{
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)
{
base.Clicked(usable);
if (usable.ID == ic.GetItemIdByName("Hoe")) {
rv = new FarmlandTile();
} else if (usable.ID == ic.GetItemIdByName("Shovel")) {
rv = new WaterTile();
if (usable.Id == ic.GetItemIdByName("Hoe")) {
rv = new FarmlandTile(_gameObject);
} else if (usable.Id == ic.GetItemIdByName("Shovel")) {
rv = new WaterTile(_gameObject);
}
}
return rv;

View file

@ -1,9 +1,9 @@
using System.Collections;
using System.Collections;
using UnityEngine;
namespace Tiles {
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) {
@ -12,15 +12,15 @@ namespace Tiles {
ItemContainer ic = ItemContainer.Instance;
if (usable.ID == ic.GetItemIdByName("Fishing Rod")) {
if (usable.Id == ic.GetItemIdByName("Fishing Rod")) {
FishingController fc = FishingController.instance;
if (!fc.Fishing) {
fc.StartFishing();
} else {
fc.TryCatch();
}
} else if (usable.ID == ic.GetItemIdByName("Shovel")) {
rv = new GrassTile();
} else if (usable.Id == ic.GetItemIdByName("Shovel")) {
rv = new GrassTile(_gameObject);
}
return rv;