added Player GameObject, updated GrassTile.Clicked()
This commit is contained in:
parent
433158e658
commit
4612938b54
5 changed files with 76 additions and 5 deletions
|
|
@ -253,3 +253,48 @@ Transform:
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &1800469988
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1800469990}
|
||||||
|
- component: {fileID: 1800469989}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Player
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &1800469989
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1800469988}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 7ff39a43f7a5df74b9d3456085e32adf, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
startMoney: 100
|
||||||
|
--- !u!4 &1800469990
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1800469988}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0.741637, y: -0.3807241, z: -0.019921448}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 2
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ public class PlayerController : MonoBehaviour {
|
||||||
private Dictionary<Item, int> inventory;
|
private Dictionary<Item, int> inventory;
|
||||||
private int money;
|
private int money;
|
||||||
private UsableItem selectedItem;
|
private UsableItem selectedItem;
|
||||||
|
|
||||||
|
public UsableItem SelectedItem => selectedItem;
|
||||||
|
|
||||||
private static PlayerController instance;
|
private static PlayerController instance;
|
||||||
|
|
||||||
public int startMoney = 100;
|
public int startMoney = 100;
|
||||||
|
|
@ -39,4 +41,6 @@ public class PlayerController : MonoBehaviour {
|
||||||
Debug.Log("An item requested to select isn't in the inventory" + item);
|
Debug.Log("An item requested to select isn't in the inventory" + item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,18 @@ public class TileBehaviour : MonoBehaviour
|
||||||
void OnMouseDown()
|
void OnMouseDown()
|
||||||
{
|
{
|
||||||
Debug.Log("Clicked");
|
Debug.Log("Clicked");
|
||||||
tile.Clicked(/* Current tool */ null);
|
|
||||||
|
// SelectedItem always null for now
|
||||||
|
BaseTile temp = tile.Clicked(PlayerController.getInstance().SelectedItem);
|
||||||
|
if (temp != null)
|
||||||
|
{
|
||||||
|
SetTile(temp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTile(BaseTile tileToSet)
|
void SetTile(BaseTile tileToSet)
|
||||||
{
|
{
|
||||||
tile = tileToSet;
|
tile = tileToSet;
|
||||||
GetComponent<SpriteRenderer>().color = tile.getColor;
|
GetComponent<SpriteRenderer>().color = tile.getColor; // TODO: Change to Sprite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace Tiles
|
||||||
{
|
{
|
||||||
protected Color color;
|
protected Color color;
|
||||||
public Color getColor => color;
|
public Color getColor => color;
|
||||||
// Later to be replaced with
|
// TODO: Change to Sprite, also in subclasses
|
||||||
// public Sprite sprite;
|
// public Sprite sprite;
|
||||||
|
|
||||||
protected BaseTile(Color color)
|
protected BaseTile(Color color)
|
||||||
|
|
@ -32,9 +32,10 @@ namespace Tiles
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clicked(UsableItem usable)
|
public BaseTile Clicked(UsableItem usable)
|
||||||
{
|
{
|
||||||
Debug.Log(usable.ToString() + " used on " + this.ToString());
|
Debug.Log(usable.ToString() + " used on " + this.ToString());
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,20 @@ namespace Tiles
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// to be invoked when the Tile is clicked, handles the actions following on the click
|
||||||
|
/// </summary>
|
||||||
|
/// <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>
|
||||||
|
new public BaseTile Clicked(UsableItem usable) {
|
||||||
|
base.Clicked(usable);
|
||||||
|
BaseTile rv = null;
|
||||||
|
if (usable.GetType() == typeof(Items.Hoe))
|
||||||
|
{
|
||||||
|
rv = new FarmlandTile();
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue