See, it's working now (Tile sprites)
This commit is contained in:
parent
29de95f46a
commit
0288e90c78
11 changed files with 38 additions and 89 deletions
|
|
@ -10,6 +10,11 @@ public class Crop
|
|||
private bool _markedForDeletion;
|
||||
public bool MarkedForDeletion => _markedForDeletion;
|
||||
|
||||
private bool _dead;
|
||||
public bool IsDead => _dead;
|
||||
|
||||
private bool _hydrated;
|
||||
|
||||
private int _daysGrown;
|
||||
|
||||
public Crop()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ public class TileBehaviour : MonoBehaviour
|
|||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Debug.Log("Created");
|
||||
SetTile(new GrassTile());
|
||||
|
||||
HouseController.NewDayEvent.AddListener(_tile.DayLightStep);
|
||||
|
|
@ -22,8 +21,6 @@ public class TileBehaviour : MonoBehaviour
|
|||
|
||||
void OnMouseDown()
|
||||
{
|
||||
Debug.Log("Clicked");
|
||||
|
||||
UsableItem usable = null;
|
||||
BaseTile tileToSetTo = null;
|
||||
|
||||
|
|
@ -42,9 +39,8 @@ public class TileBehaviour : MonoBehaviour
|
|||
|
||||
void SetTile(BaseTile tileToSet)
|
||||
{
|
||||
Debug.Log("Set tile to " + tileToSet.ToString());
|
||||
_tile = tileToSet;
|
||||
Debug.Log(_tile.Sprite);
|
||||
GetComponent<SpriteRenderer>().sprite = _tile.Sprite; // TODO: Change to Sprite
|
||||
GetComponent<SpriteRenderer>().sprite = _tile.Sprite;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DefaultNamespace
|
||||
{
|
||||
public class TileSpriteContainer : MonoBehaviour
|
||||
{
|
||||
public static Sprite GrassTileSprite;
|
||||
public static Sprite FarmlandTileSprite;
|
||||
public static Sprite WheatSprite;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae14b865b73e45c5b15efb9484f9cae2
|
||||
timeCreated: 1654172944
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Tiles
|
||||
{
|
||||
public abstract class BaseTile
|
||||
{
|
||||
protected Color color;
|
||||
public Color getColor => color;
|
||||
// TODO: Change to Sprite, also in subclasses
|
||||
// public Sprite sprite;
|
||||
|
||||
protected BaseTile(Color color)
|
||||
private Sprite _sprite;
|
||||
public Sprite Sprite => _sprite;
|
||||
|
||||
protected BaseTile(String pathToImageFile)
|
||||
{
|
||||
this.color = color;
|
||||
this._sprite = GenerateSpriteFromFile(pathToImageFile);
|
||||
}
|
||||
|
||||
protected void Start()
|
||||
|
|
@ -34,11 +34,16 @@ namespace Tiles
|
|||
Debug.Log(usable.ToString() + " used on " + this.ToString());
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
static protected Sprite GenerateSpriteFromFile()
|
||||
|
||||
static protected Sprite GenerateSpriteFromFile(String pathToImageFile)
|
||||
{
|
||||
|
||||
byte[] data = System.IO.File.ReadAllBytes(pathToImageFile);
|
||||
Texture2D texture = new Texture2D(32, 32, TextureFormat.ARGB32, false);
|
||||
texture.LoadImage(data);
|
||||
Sprite sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 32);
|
||||
Debug.Log(sprite);
|
||||
return sprite;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +1,18 @@
|
|||
using DefaultNamespace;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Tiles
|
||||
{
|
||||
public class FarmlandTile : BaseTile
|
||||
{
|
||||
private Crop _crop;
|
||||
private bool _hydrated;
|
||||
|
||||
public FarmlandTile() : base(TileSpriteContainer.FarmlandTileSprite)
|
||||
public FarmlandTile() : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_008.png")
|
||||
{
|
||||
_crop = null;
|
||||
_hydrated = false;
|
||||
}
|
||||
|
||||
public new void DayLightStep()
|
||||
{
|
||||
if (_crop != null)
|
||||
{
|
||||
_crop.DayLightStep(_hydrated);
|
||||
if (_crop.MarkedForDeletion)
|
||||
{
|
||||
Debug.Log("Farmland crop deleted");
|
||||
_crop = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new BaseTile Clicked(UsableItem usable)
|
||||
|
|
@ -36,7 +24,7 @@ namespace Tiles
|
|||
if (usable.id == ic.GetItemIdByName("Hoe"))
|
||||
{
|
||||
Debug.Log("Farmland hydrated");
|
||||
_hydrated = true;
|
||||
//_hydrated = true;
|
||||
}
|
||||
|
||||
if (usable.id == ic.GetItemIdByName("Wheat Seed") && _crop == null)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
using DefaultNamespace;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Tiles
|
||||
{
|
||||
public class GrassTile : BaseTile
|
||||
{
|
||||
public GrassTile() : base(TileSpriteContainer.GrassTileSprite)
|
||||
public GrassTile() : base("C:/Users/maile/UnityProjects/2122_3AHITN_Scrum_sprechtl_jweissen_dhain/Assets/Farming Asset Pack/Split Assets/farming_tileset_000.png")
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue