Added TerraformingTools & functionality
This commit is contained in:
parent
4612938b54
commit
1e2ae28c12
8 changed files with 65 additions and 15 deletions
|
|
@ -1,13 +1,14 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Items.TerraformingTools;
|
||||
using Tiles;
|
||||
using UnityEngine;
|
||||
|
||||
public class TileBehaviour : MonoBehaviour
|
||||
{
|
||||
private BaseTile tile;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
|
@ -18,24 +19,33 @@ public class TileBehaviour : MonoBehaviour
|
|||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
Debug.Log("Clicked");
|
||||
|
||||
// SelectedItem always null for now
|
||||
BaseTile temp = tile.Clicked(PlayerController.getInstance().SelectedItem);
|
||||
if (temp != null)
|
||||
UsableItem usable = PlayerController.getInstance().SelectedItem;
|
||||
BaseTile tileToSetTo = null;
|
||||
if (usable.GetType() == typeof(TerraformingTool))
|
||||
{
|
||||
SetTile(temp);
|
||||
TerraformingTool terraformingTool = (TerraformingTool) usable;
|
||||
Type tileTypeToSetTo = terraformingTool.TileType;
|
||||
tileToSetTo = (BaseTile) Activator.CreateInstance(tileTypeToSetTo);
|
||||
}
|
||||
else
|
||||
{
|
||||
tile.Clicked(usable);
|
||||
}
|
||||
if (tileToSetTo != null)
|
||||
{
|
||||
SetTile(tileToSetTo);
|
||||
}
|
||||
}
|
||||
|
||||
void SetTile(BaseTile tileToSet)
|
||||
{
|
||||
Debug.Log("Set tile to " + tileToSet.ToString());
|
||||
tile = tileToSet;
|
||||
GetComponent<SpriteRenderer>().color = tile.getColor; // TODO: Change to Sprite
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue