improved Tiles, added Split Sprites
This commit is contained in:
parent
d28a1947eb
commit
71fc280d2e
9 changed files with 72 additions and 32 deletions
|
|
@ -12,6 +12,7 @@ GameObject:
|
||||||
- component: {fileID: 4752245148499717902}
|
- component: {fileID: 4752245148499717902}
|
||||||
- component: {fileID: 4752245148499717903}
|
- component: {fileID: 4752245148499717903}
|
||||||
- component: {fileID: 4752245148499717900}
|
- component: {fileID: 4752245148499717900}
|
||||||
|
- component: {fileID: 7967442993183754557}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: BaseTile
|
m_Name: BaseTile
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -124,3 +125,18 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 3fd8bc1d313319d4f89f11548ccb1b6a, type: 3}
|
m_Script: {fileID: 11500000, guid: 3fd8bc1d313319d4f89f11548ccb1b6a, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
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}
|
||||||
|
|
|
||||||
|
|
@ -1639,7 +1639,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.5932421
|
m_Size: 0.59324205
|
||||||
m_NumberOfSteps: 0
|
m_NumberOfSteps: 0
|
||||||
m_OnValueChanged:
|
m_OnValueChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
|
@ -4545,7 +4545,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 0
|
m_IsActive: 1
|
||||||
--- !u!114 &1291863650
|
--- !u!114 &1291863650
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -6236,7 +6236,11 @@ 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: []
|
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}
|
||||||
--- !u!1001 &1805366398
|
--- !u!1001 &1805366398
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,9 @@
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Items.TerraformingTools;
|
|
||||||
using Tiles;
|
using Tiles;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class TileBehaviour : MonoBehaviour
|
public class TileBehaviour : MonoBehaviour
|
||||||
{
|
{
|
||||||
private BaseTile tile;
|
private BaseTile _tile;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
|
|
@ -15,7 +11,7 @@ public class TileBehaviour : MonoBehaviour
|
||||||
Debug.Log("Created");
|
Debug.Log("Created");
|
||||||
SetTile(new GrassTile());
|
SetTile(new GrassTile());
|
||||||
|
|
||||||
HouseController.NewDayEvent.AddListener(tile.DayLightStep);
|
HouseController.NewDayEvent.AddListener(_tile.DayLightStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
|
@ -27,20 +23,17 @@ public class TileBehaviour : MonoBehaviour
|
||||||
void OnMouseDown()
|
void OnMouseDown()
|
||||||
{
|
{
|
||||||
Debug.Log("Clicked");
|
Debug.Log("Clicked");
|
||||||
|
|
||||||
UsableItem usable = PlayerController.instance.GetSelectedItem();
|
UsableItem usable = null;
|
||||||
BaseTile tileToSetTo = null;
|
BaseTile tileToSetTo = null;
|
||||||
if (usable.GetType() == typeof(TerraformingTool))
|
|
||||||
|
if (PlayerController.instance.GetSelectedItem() != null)
|
||||||
{
|
{
|
||||||
TerraformingTool terraformingTool = (TerraformingTool) usable;
|
usable = PlayerController.instance.GetSelectedItem();
|
||||||
Type tileTypeToSetTo = terraformingTool.TileType;
|
|
||||||
tileToSetTo = (BaseTile) Activator.CreateInstance(tileTypeToSetTo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tileToSetTo = tile.Clicked(usable);
|
|
||||||
Debug.Log("AMOGUS " + tileToSetTo.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tileToSetTo = _tile.Clicked(usable);
|
||||||
|
|
||||||
if (tileToSetTo != null)
|
if (tileToSetTo != null)
|
||||||
{
|
{
|
||||||
SetTile(tileToSetTo);
|
SetTile(tileToSetTo);
|
||||||
|
|
@ -50,7 +43,8 @@ public class TileBehaviour : MonoBehaviour
|
||||||
void SetTile(BaseTile tileToSet)
|
void SetTile(BaseTile tileToSet)
|
||||||
{
|
{
|
||||||
Debug.Log("Set tile to " + tileToSet.ToString());
|
Debug.Log("Set tile to " + tileToSet.ToString());
|
||||||
tile = tileToSet;
|
_tile = tileToSet;
|
||||||
GetComponent<SpriteRenderer>().color = tile.getColor; // TODO: Change to Sprite
|
Debug.Log(_tile.Sprite);
|
||||||
|
GetComponent<SpriteRenderer>().sprite = _tile.Sprite; // TODO: Change to Sprite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
Assets/Scripts/TileSpriteContainer.cs
Normal file
12
Assets/Scripts/TileSpriteContainer.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DefaultNamespace
|
||||||
|
{
|
||||||
|
public class TileSpriteContainer : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static Sprite GrassTileSprite;
|
||||||
|
public static Sprite FarmlandTileSprite;
|
||||||
|
public static Sprite WheatSprite;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/TileSpriteContainer.cs.meta
Normal file
3
Assets/Scripts/TileSpriteContainer.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ae14b865b73e45c5b15efb9484f9cae2
|
||||||
|
timeCreated: 1654172944
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Tiles
|
||||||
|
|
||||||
public void DayLightStep()
|
public void DayLightStep()
|
||||||
{
|
{
|
||||||
Debug.Log("I evolve");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual BaseTile Clicked(UsableItem usable)
|
public virtual BaseTile Clicked(UsableItem usable)
|
||||||
|
|
@ -34,5 +34,11 @@ namespace Tiles
|
||||||
Debug.Log(usable.ToString() + " used on " + this.ToString());
|
Debug.Log(usable.ToString() + " used on " + this.ToString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
static protected Sprite GenerateSpriteFromFile()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using UnityEngine;
|
using DefaultNamespace;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Tiles
|
namespace Tiles
|
||||||
{
|
{
|
||||||
|
|
@ -7,7 +8,7 @@ namespace Tiles
|
||||||
private Crop _crop;
|
private Crop _crop;
|
||||||
private bool _hydrated;
|
private bool _hydrated;
|
||||||
|
|
||||||
public FarmlandTile() : base(Color.black)
|
public FarmlandTile() : base(TileSpriteContainer.FarmlandTileSprite)
|
||||||
{
|
{
|
||||||
_crop = null;
|
_crop = null;
|
||||||
_hydrated = false;
|
_hydrated = false;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
using UnityEngine;
|
using DefaultNamespace;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Tiles
|
namespace Tiles
|
||||||
{
|
{
|
||||||
public class GrassTile : BaseTile
|
public class GrassTile : BaseTile
|
||||||
{
|
{
|
||||||
public GrassTile() : base(Color.green)
|
public GrassTile() : base(TileSpriteContainer.GrassTileSprite)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -15,11 +16,14 @@ namespace Tiles
|
||||||
/// <param name="usable">the UsableItem that the Tile was clicked on with</param>
|
/// <param name="usable">the UsableItem that the Tile was clicked on with</param>
|
||||||
/// <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) {
|
||||||
base.Clicked(usable);
|
|
||||||
BaseTile rv = null;
|
BaseTile rv = null;
|
||||||
if (usable.id == ItemContainer.Instance.GetItemIdByName("Hoe"))
|
if (usable != null)
|
||||||
{
|
{
|
||||||
rv = new FarmlandTile();
|
base.Clicked(usable);
|
||||||
|
if (usable.id == ItemContainer.Instance.GetItemIdByName(new string("Hoe")))
|
||||||
|
{
|
||||||
|
rv = new FarmlandTile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ namespace Tiles
|
||||||
{
|
{
|
||||||
public class WaterTile : BaseTile
|
public class WaterTile : BaseTile
|
||||||
{
|
{
|
||||||
public WaterTile() : base(Color.blue)
|
public WaterTile() : base(null)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue