36 lines
801 B
C#
36 lines
801 B
C#
using UnityEngine;
|
|
|
|
public class CropManager : MonoBehaviour
|
|
{
|
|
private Crop[,] cropGrid;
|
|
public static CropManager Instance { get; private set; }
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
Instance = this;
|
|
else
|
|
Destroy(gameObject);
|
|
|
|
cropGrid = new Crop[32, 32];
|
|
}
|
|
|
|
public void PlantCrop(Crop crop, int x, int y)
|
|
{
|
|
// Add the crop to the grid
|
|
cropGrid[x, y] = crop;
|
|
|
|
// Update the crop's position in the world
|
|
// todo: fix this tranform
|
|
// crop.transform.position = new Vector3(x, y, 0);
|
|
}
|
|
|
|
public Crop HarvestCrop(int x, int y)
|
|
{
|
|
// Remove the crop from the grid
|
|
var crop = cropGrid[x, y];
|
|
cropGrid[x, y] = null;
|
|
|
|
return crop;
|
|
}
|
|
} |