diff --git a/Assets/Scripts/Item.cs b/Assets/Scripts/Item.cs index 9b08db5..8a08062 100644 --- a/Assets/Scripts/Item.cs +++ b/Assets/Scripts/Item.cs @@ -5,19 +5,26 @@ using UnityEngine; public class Item : ScriptableObject, IComparable { 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; + } } } diff --git a/Assets/Scripts/Tiles/BaseTile.cs b/Assets/Scripts/Tiles/BaseTile.cs index 208d5bd..f697db0 100644 --- a/Assets/Scripts/Tiles/BaseTile.cs +++ b/Assets/Scripts/Tiles/BaseTile.cs @@ -15,6 +15,9 @@ namespace Tiles { this._gameObject = gameObject; this._sprite = GenerateSpriteFromFile(pathToImageFile); + } + + public void DayLightStep() HouseController.NewDayEvent.AddListener(DayLightStep); } diff --git a/Assets/Scripts/Tiles/GrassTile.cs b/Assets/Scripts/Tiles/GrassTile.cs index 21eb78d..2902e7a 100644 --- a/Assets/Scripts/Tiles/GrassTile.cs +++ b/Assets/Scripts/Tiles/GrassTile.cs @@ -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 /// a subclass of BaseTile if the Tile has to change, null if it stays the same type 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; diff --git a/Assets/Scripts/Tiles/WaterTile.cs b/Assets/Scripts/Tiles/WaterTile.cs index c262015..621ee65 100644 --- a/Assets/Scripts/Tiles/WaterTile.cs +++ b/Assets/Scripts/Tiles/WaterTile.cs @@ -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; } } } \ No newline at end of file