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
|
|
@ -12,7 +12,6 @@ GameObject:
|
|||
- component: {fileID: 4752245148499717902}
|
||||
- component: {fileID: 4752245148499717903}
|
||||
- component: {fileID: 4752245148499717900}
|
||||
- component: {fileID: 7967442993183754557}
|
||||
m_Layer: 0
|
||||
m_Name: BaseTile
|
||||
m_TagString: Untagged
|
||||
|
|
@ -73,10 +72,10 @@ SpriteRenderer:
|
|||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: -2016319409
|
||||
m_SortingLayer: 1
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 21300000, guid: 2700e06d970d112489ff23cfb58c3f78, type: 3}
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
|
|
@ -84,7 +83,7 @@ SpriteRenderer:
|
|||
m_Size: {x: 1, y: 1}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_WasSpriteAssigned: 0
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!61 &4752245148499717903
|
||||
|
|
@ -125,18 +124,3 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 3fd8bc1d313319d4f89f11548ccb1b6a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &7967442993183754557
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4752245148499717901}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ae14b865b73e45c5b15efb9484f9cae2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
GrassTileSprite: {fileID: 21300002, guid: 2700e06d970d112489ff23cfb58c3f78, type: 3}
|
||||
FarmlandTileSprite: {fileID: 21300016, guid: 2700e06d970d112489ff23cfb58c3f78, type: 3}
|
||||
WheatSprite: {fileID: 21300078, guid: 2700e06d970d112489ff23cfb58c3f78, type: 3}
|
||||
|
|
|
|||
|
|
@ -5010,7 +5010,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
tile: {fileID: 4752245148499717901, guid: ea81011a3ce83fb4386934728a92ee2d, type: 3}
|
||||
cameraGameObject: {fileID: 0}
|
||||
cameraGameObject: {fileID: 598358736}
|
||||
--- !u!4 &1291863651
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -6610,11 +6610,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: bc5eb8967b8912c42b93a2086383ddd9, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
startItems:
|
||||
- {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2}
|
||||
- {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2}
|
||||
- {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, type: 2}
|
||||
- {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2}
|
||||
startItems: []
|
||||
--- !u!1001 &1701153146
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -6857,7 +6853,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
startMoney: 10000
|
||||
moneyTextMeshProUGUI: {fileID: 1347709342}
|
||||
moneyTextMeshProUGUI: {fileID: 0}
|
||||
--- !u!4 &1800469990
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
private Sprite _sprite;
|
||||
public Sprite Sprite => _sprite;
|
||||
|
||||
protected BaseTile(Color color)
|
||||
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")
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,21 +137,12 @@
|
|||
"dependencies": {},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.nuget.newtonsoft-json": {
|
||||
"version": "3.0.2",
|
||||
"depth": 2,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.services.core": {
|
||||
"version": "1.3.1",
|
||||
"version": "1.0.1",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.nuget.newtonsoft-json": "3.0.2",
|
||||
"com.unity.modules.androidjni": "1.0.0"
|
||||
"com.unity.modules.unitywebrequest": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
m_EditorVersion: 2021.3.2f1
|
||||
m_EditorVersionWithRevision: 2021.3.2f1 (d6360bedb9a0)
|
||||
m_EditorVersion: 2021.3.1f1
|
||||
m_EditorVersionWithRevision: 2021.3.1f1 (3b70a0754835)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue