Merge sprechtl develop

This commit is contained in:
s-prechtl 2022-06-09 00:00:26 +02:00
commit f8da73695c
4 changed files with 45 additions and 16 deletions

View file

@ -5,19 +5,26 @@ using UnityEngine;
public class Item : ScriptableObject, IComparable<Item> {
public string displayName;
public string description;
public int id; //TODO: create an actual ID System that makes snens
private int _id = -1;
public Sprite selectedSprite;
public Sprite defaultSprite;
public int price;
public int SellPrice => Convert.ToInt32(price * 0.8);
ic int ID => _id;
public Item(string displayName, string description, int id) {
this.displayName = displayName;
this.description = description;
this.id = id;
this._id = id;
}
public int CompareTo(Item other) {
return this.id - other.id;
return this._id - other._id;
}
public void SetID(int id) {
if (_id != -1) {
_id = id;
}
}
}

View file

@ -15,6 +15,9 @@ namespace Tiles
{
this._gameObject = gameObject;
this._sprite = GenerateSpriteFromFile(pathToImageFile);
}
public void DayLightStep()
HouseController.NewDayEvent.AddListener(DayLightStep);
}

View file

@ -4,7 +4,7 @@ namespace Tiles
{
public class GrassTile : BaseTile
{
public GrassTile(GameObject gameObject) : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_000.png", gameObject)
public GrassTile() : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_000.png")
{
}
@ -16,12 +16,14 @@ namespace Tiles
/// <returns>a subclass of BaseTile if the Tile has to change, null if it stays the same type</returns>
public override BaseTile Clicked(UsableItem usable) {
BaseTile rv = null;
ItemContainer ic = ItemContainer.Instance;
if (usable != null)
{
base.Clicked(usable);
if (usable.id == ItemContainer.Instance.GetItemIdByName(new string("Hoe")))
{
rv = new FarmlandTile(_gameObject);
if (usable.ID == ic.GetItemIdByName("Hoe")) {
rv = new FarmlandTile();
} else if (usable.ID == ic.GetItemIdByName("Shovel")) {
rv = new WaterTile();
}
}
return rv;

View file

@ -1,12 +1,29 @@
using UnityEngine;
using System.Collections;
using UnityEngine;
namespace Tiles
{
public class WaterTile : BaseTile
{
public WaterTile() : base(null, null)
{
namespace Tiles {
public class WaterTile : BaseTile {
public WaterTile() : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_023.png") {
}
public override BaseTile Clicked(UsableItem usable) {
base.Clicked(usable);
BaseTile rv = null;
ItemContainer ic = ItemContainer.Instance;
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();
}
return rv;
}
}
}