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

@ -0,0 +1,20 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 761f645f009328845bc7851753024e92, type: 3}
m_Name: Shovel
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

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6bac44b5c4527b641a3ae772d217ec43
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1536,7 +1536,7 @@ MonoBehaviour:
m_HandleRect: {fileID: 2006577138} m_HandleRect: {fileID: 2006577138}
m_Direction: 2 m_Direction: 2
m_Value: 1 m_Value: 1
m_Size: 0.59324205 m_Size: 0.5932421
m_NumberOfSteps: 0 m_NumberOfSteps: 0
m_OnValueChanged: m_OnValueChanged:
m_PersistentCalls: m_PersistentCalls:
@ -6516,6 +6516,7 @@ MonoBehaviour:
- {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2} - {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2}
- {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2} - {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2}
- {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2} - {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2}
- {fileID: 11400000, guid: 6bac44b5c4527b641a3ae772d217ec43, type: 2}
--- !u!1001 &1701153146 --- !u!1001 &1701153146
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6790,6 +6791,7 @@ MonoBehaviour:
- {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2} - {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2}
- {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2} - {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2}
- {fileID: 11400000, guid: ea1a26b19bc34a0ba29bad77253c7266, type: 2} - {fileID: 11400000, guid: ea1a26b19bc34a0ba29bad77253c7266, type: 2}
- {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, type: 2}
--- !u!114 &1800469992 --- !u!114 &1800469992
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6802,12 +6804,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 05183797fdda4aa9ac518eee0d2d85d4, type: 3} m_Script: {fileID: 11500000, guid: 05183797fdda4aa9ac518eee0d2d85d4, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
allItems:
- {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2}
- {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, type: 2}
- {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2}
- {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2}
- {fileID: 11400000, guid: ea1a26b19bc34a0ba29bad77253c7266, type: 2}
--- !u!1001 &1805366398 --- !u!1001 &1805366398
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -31,7 +31,7 @@ namespace Tiles
public virtual BaseTile Clicked(UsableItem usable) public virtual BaseTile Clicked(UsableItem usable)
{ {
Debug.Log(usable.ToString() + " used on " + this.ToString()); Debug.Log(usable + " used on " + this);
return null; 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> /// <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) { public override BaseTile Clicked(UsableItem usable) {
BaseTile rv = null; BaseTile rv = null;
ItemContainer ic = ItemContainer.Instance;
if (usable != null) if (usable != null)
{ {
base.Clicked(usable); base.Clicked(usable);
if (usable.id == ItemContainer.Instance.GetItemIdByName(new string("Hoe"))) if (usable.id == ic.GetItemIdByName("Hoe")) {
{
rv = new FarmlandTile(); rv = new FarmlandTile();
} else if (usable.id == ic.GetItemIdByName("Shovel")) {
rv = new WaterTile();
} }
} }
return rv; return rv;

View file

@ -1,11 +1,42 @@
using UnityEngine; using System.Collections;
using UnityEngine;
namespace Tiles namespace Tiles
{ {
public class WaterTile : BaseTile public class WaterTile : BaseTile {
{ private double _fishingTime;
public WaterTile() : base(null) 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();
}
} }
} }