mirror of
https://github.com/DerTyp7/harvestdale-unity.git
synced 2025-10-30 04:57:09 +01:00
asd
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Building : MonoBehaviour
|
||||
public abstract class Building : MonoBehaviour
|
||||
{
|
||||
public bool isPlaced = false;
|
||||
public PlaceableObject placeableObject;
|
||||
|
||||
public abstract void OnPlace();
|
||||
public void Place()
|
||||
{
|
||||
isPlaced = true;
|
||||
BuildingManager.buildings.Add(this);
|
||||
OnPlace();
|
||||
}
|
||||
|
||||
public void Demolish()
|
||||
@@ -20,6 +22,6 @@ public class Building : MonoBehaviour
|
||||
|
||||
public Vector3Int GetGridPosition()
|
||||
{
|
||||
return new Vector3Int(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y), 0);
|
||||
return new Vector3Int(Mathf.FloorToInt(transform.position.x), Mathf.RoundToInt(transform.position.y), 0);
|
||||
}
|
||||
}
|
||||
|
||||
17
Assets/Scripts/Clock.cs
Normal file
17
Assets/Scripts/Clock.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class Clock : MonoBehaviour
|
||||
{
|
||||
private TextMeshProUGUI text;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
text = GetComponent<TextMeshProUGUI>();
|
||||
TimeManager.OnMinuteChanged += GetTime;
|
||||
}
|
||||
private void GetTime()
|
||||
{
|
||||
text.SetText($"{TimeManager.Day:00}D | {TimeManager.Hour:00}:{TimeManager.Minute:00}");
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Clock.cs.meta
Normal file
11
Assets/Scripts/Clock.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6f62dc7e95d02c44b723d837f05cbbf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,7 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Tilemaps;
|
||||
|
||||
public class Field : MonoBehaviour
|
||||
public class Field : Building
|
||||
{
|
||||
public Crop crop;
|
||||
public int daysSincePlanted;
|
||||
@@ -15,4 +15,9 @@ public class Field : MonoBehaviour
|
||||
{
|
||||
daysSincePlanted++;
|
||||
}
|
||||
|
||||
public override void OnPlace()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,13 @@ public class GridBuildingSystem : MonoBehaviour
|
||||
private void Update()
|
||||
{
|
||||
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
int snappedX = Mathf.RoundToInt(mousePosition.x);
|
||||
int snappedY = Mathf.RoundToInt(mousePosition.y);
|
||||
int snappedX = Mathf.FloorToInt(mousePosition.x);
|
||||
int snappedY = Mathf.FloorToInt(mousePosition.y);
|
||||
Vector3Int snappedMousePosition = new Vector3Int(snappedX, snappedY, 0);
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
UnselectBuilding();
|
||||
isDemolishing = !isDemolishing;
|
||||
Debug.Log(isDemolishing);
|
||||
}
|
||||
@@ -71,6 +72,7 @@ public class GridBuildingSystem : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor.visible = true;
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Building demoBuilding = BuildingManager.GetBuildingByGridPosition(snappedMousePosition);
|
||||
|
||||
11
Assets/Scripts/House.cs
Normal file
11
Assets/Scripts/House.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Tilemaps;
|
||||
|
||||
public class House : Building
|
||||
{
|
||||
|
||||
public override void OnPlace()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/House.cs.meta
Normal file
11
Assets/Scripts/House.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 446f2f1c1f6389b4f967c615a6ff567b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user