µ
This commit is contained in:
parent
98b571c2aa
commit
f7b593045f
9 changed files with 49 additions and 132 deletions
|
|
@ -75,7 +75,7 @@ SpriteRenderer:
|
|||
m_SortingLayerID: -2016319409
|
||||
m_SortingLayer: 1
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
|
||||
m_Sprite: {fileID: 21300000, guid: 2700e06d970d112489ff23cfb58c3f78, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
|
|
|
|||
|
|
@ -4906,7 +4906,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
menu: {fileID: 1395531174}
|
||||
dayCountTextMeshProUGUI: {fileID: 1089918735}
|
||||
dayCountTextMeshProUGUI: {fileID: 0}
|
||||
--- !u!212 &1278234715
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -5010,7 +5010,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
tile: {fileID: 4752245148499717901, guid: ea81011a3ce83fb4386934728a92ee2d, type: 3}
|
||||
CameraGameObject: {fileID: 598358736}
|
||||
cameraGameObject: {fileID: 0}
|
||||
--- !u!4 &1291863651
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class ItemStorageUI : MonoBehaviour {
|
||||
public Transform itemsParent;
|
||||
public GameObject inventoryUI;
|
||||
private Inventory _inventory;
|
||||
private InventorySlot[] _slots;
|
||||
|
||||
private void Start() {
|
||||
// Get Inventory instance and add UpdateUI method to OnItemChanged delegate
|
||||
_inventory = Inventory.instance;
|
||||
_inventory.onItemChangedCallback += UpdateUI;
|
||||
|
||||
// Add all InventorySlot GameObjects to _slots and turn off the Inventory UI
|
||||
_slots = itemsParent.GetComponentsInChildren<InventorySlot>();
|
||||
ToggleInventory();
|
||||
|
||||
// Set the icon to not be a raycast target for the Description Hovering to work
|
||||
foreach(InventorySlot slot in _slots) {
|
||||
slot.icon.raycastTarget = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
// When "Inventory" button is pressed turn on/off Inventory UI
|
||||
if(Input.GetButtonDown("Inventory")) {
|
||||
ToggleInventory();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn on/off the Inventory UI
|
||||
*/
|
||||
private void ToggleInventory() {
|
||||
inventoryUI.SetActive(!inventoryUI.activeSelf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called when something in the Inventory UI should update
|
||||
*/
|
||||
private void UpdateUI() {
|
||||
// Add all items to the correct slots and clear the ones where no item should be
|
||||
for(int i = 0; i < _slots.Length; i++) {
|
||||
if(i < _inventory.items.Count) {
|
||||
_slots[i].AddItem(_inventory.items.ElementAt(i).Key);
|
||||
if(_inventory.items[_inventory.items.ElementAt(i).Key] > 1) {
|
||||
_slots[i].amountText.text = "" + _inventory.items[_inventory.items.ElementAt(i).Key];
|
||||
}
|
||||
} else {
|
||||
_slots[i].ClearSlot();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 21b91c5ff9ffa4d45a5e71b08b141657
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -6,12 +6,12 @@ public class ShopUI : MonoBehaviour {
|
|||
public GameObject shopUI;
|
||||
private Shop _shop;
|
||||
private ShopSlot[] _slots;
|
||||
|
||||
|
||||
private void Start() {
|
||||
// Get Shop instance and add UpdateUI method to OnItemChanged delegate
|
||||
_shop = Shop.instance;
|
||||
_shop.onItemChangedCallback += UpdateUI;
|
||||
|
||||
|
||||
// Add all ShopSlot GameObjects to _slots and turn off the Shop UI
|
||||
_slots = itemsParent.GetComponentsInChildren<ShopSlot>();
|
||||
ToggleShop();
|
||||
|
|
@ -45,7 +45,7 @@ public class ShopUI : MonoBehaviour {
|
|||
if(i < _shop.items.Count) {
|
||||
_slots[i].AddItem(_shop.items.ElementAt(i).Key);
|
||||
_slots[i].nameText.text = _slots[i].Item.displayName;
|
||||
_slots[i].costText.text = _slots[i].Item.cost + " €";
|
||||
_slots[i].costText.text = _slots[i].Item.cost + " µ";
|
||||
_slots[i].amountText.text = _shop.items[_shop.items.ElementAt(i).Key] + " #";
|
||||
} else {
|
||||
_slots[i].ClearSlot();
|
||||
|
|
|
|||
|
|
@ -5,52 +5,39 @@ using Items.TerraformingTools;
|
|||
using Tiles;
|
||||
using UnityEngine;
|
||||
|
||||
public class TileBehaviour : MonoBehaviour
|
||||
{
|
||||
private BaseTile tile;
|
||||
|
||||
public class TileBehaviour : MonoBehaviour {
|
||||
private BaseTile _tile;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
private void Start() {
|
||||
Debug.Log("Created");
|
||||
SetTile(new GrassTile());
|
||||
|
||||
HouseController.NewDayEvent.AddListener(tile.DayLightStep);
|
||||
|
||||
HouseController.NewDayEvent.AddListener(_tile.DayLightStep);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
private void OnMouseDown() {
|
||||
Debug.Log("Clicked");
|
||||
|
||||
|
||||
UsableItem usable = PlayerController.instance.GetSelectedItem();
|
||||
BaseTile tileToSetTo = null;
|
||||
if (usable.GetType() == typeof(TerraformingTool))
|
||||
{
|
||||
TerraformingTool terraformingTool = (TerraformingTool) usable;
|
||||
if(usable.GetType() == typeof(TerraformingTool)) {
|
||||
TerraformingTool terraformingTool = (TerraformingTool)usable;
|
||||
Type tileTypeToSetTo = terraformingTool.TileType;
|
||||
tileToSetTo = (BaseTile) Activator.CreateInstance(tileTypeToSetTo);
|
||||
}
|
||||
else
|
||||
{
|
||||
tileToSetTo = tile.Clicked(usable);
|
||||
tileToSetTo = (BaseTile)Activator.CreateInstance(tileTypeToSetTo);
|
||||
} else {
|
||||
tileToSetTo = _tile.Clicked(usable);
|
||||
Debug.Log("AMOGUS " + tileToSetTo.ToString());
|
||||
}
|
||||
if (tileToSetTo != null)
|
||||
{
|
||||
|
||||
if(tileToSetTo != null) {
|
||||
SetTile(tileToSetTo);
|
||||
}
|
||||
}
|
||||
|
||||
void SetTile(BaseTile tileToSet)
|
||||
{
|
||||
private void SetTile(BaseTile tileToSet) {
|
||||
Debug.Log("Set tile to " + tileToSet.ToString());
|
||||
tile = tileToSet;
|
||||
GetComponent<SpriteRenderer>().color = tile.getColor; // TODO: Change to Sprite
|
||||
_tile = tileToSet;
|
||||
GetComponent<SpriteRenderer>().color = _tile.getColor; // TODO: Change to Sprite
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,38 +3,25 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TileController : MonoBehaviour
|
||||
{
|
||||
public class TileController : MonoBehaviour {
|
||||
public GameObject tile;
|
||||
|
||||
public GameObject CameraGameObject;
|
||||
|
||||
public GameObject cameraGameObject;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Camera camera = CameraGameObject.GetComponent<Camera>();
|
||||
Vector3 screen = camera.ViewportToWorldPoint(new Vector3(1,1,camera.nearClipPlane));
|
||||
void Start() {
|
||||
Camera camera = cameraGameObject.GetComponent<Camera>();
|
||||
Vector3 screen = camera.ViewportToWorldPoint(new Vector3(1, 1, camera.nearClipPlane));
|
||||
int x = Convert.ToInt32(Math.Ceiling(screen.x));
|
||||
int y = Convert.ToInt32(Math.Ceiling(screen.y));
|
||||
|
||||
|
||||
Debug.Log(screen);
|
||||
for (int xx = -x; xx <= x; xx++)
|
||||
{
|
||||
for (int yy = -y; yy <= y; yy++)
|
||||
{
|
||||
if (tile != null)
|
||||
{
|
||||
for(int xx = -x; xx <= x; xx++) {
|
||||
for(int yy = -y; yy <= y; yy++) {
|
||||
if(tile != null) {
|
||||
Instantiate(tile, new Vector3(xx, yy, 0), Quaternion.identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue