WaterTile.cs + Shovel.asset

This commit is contained in:
s-prechtl 2022-06-08 11:44:22 +02:00
parent efc7a3deaf
commit 1a12d986c4
6 changed files with 72 additions and 15 deletions

View file

@ -31,7 +31,7 @@ namespace Tiles
public virtual BaseTile Clicked(UsableItem usable)
{
Debug.Log(usable.ToString() + " used on " + this.ToString());
Debug.Log(usable + " used on " + this);
return null;
}

View file

@ -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")))
{
if (usable.id == ic.GetItemIdByName("Hoe")) {
rv = new FarmlandTile();
} else if (usable.id == ic.GetItemIdByName("Shovel")) {
rv = new WaterTile();
}
}
return rv;

View file

@ -1,11 +1,42 @@
using UnityEngine;
using System.Collections;
using UnityEngine;
namespace Tiles
{
public class WaterTile : BaseTile
{
public WaterTile() : base(null)
{
public class WaterTile : BaseTile {
private double _fishingTime;
private bool _fishing = false;
private bool _catchable = false;
private int _lastCall = 0;
public WaterTile() : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_023.png") {
}
public override BaseTile Clicked(UsableItem usable) {
base.Clicked(usable);
ItemContainer ic = ItemContainer.Instance;
if (usable.id == ic.GetItemIdByName("Fishing Rod")) {
if (!_fishing) {
_fishing = true;
_fishingTime = 0f;
Fish();
} else if (_catchable) {
_fishing = false;
Debug.Log("Fished for" + _fishingTime/1000);
}
}
return null;
}
private void Fish() {
if (_fishing) {
if (_catchable) {
// _fishingTime += _lastCall - System.DateTime.Now; deltaTime between last recursive call
}
//Fish();
}
}
}