WaterTile.cs + Shovel.asset
This commit is contained in:
parent
efc7a3deaf
commit
1a12d986c4
6 changed files with 72 additions and 15 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue