Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
s-prechtl 2022-06-03 12:17:38 +02:00
commit 8211a11c2c
9 changed files with 33 additions and 75 deletions

View file

@ -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()

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: ae14b865b73e45c5b15efb9484f9cae2
timeCreated: 1654172944

View file

@ -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(Sprite sprite)
private Sprite _sprite;
public Sprite Sprite => _sprite;
protected BaseTile(String pathToImageFile)
{
this.Sprite = sprite;
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;
}
*/
}
}

View file

@ -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)

View file

@ -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")
{
}