mirror of
https://github.com/DerTyp7/harvestdale-unity.git
synced 2025-10-29 20:52:10 +01:00
d
This commit is contained in:
@@ -52,6 +52,7 @@ public class Field : Building
|
|||||||
fieldController.GetComponent<FieldController>().SetField(this);
|
fieldController.GetComponent<FieldController>().SetField(this);
|
||||||
|
|
||||||
TimeManager.OnDayChanged += DayInterval;
|
TimeManager.OnDayChanged += DayInterval;
|
||||||
|
TimeManager.OnMonthChanged += MonthInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnPlace()
|
public override void OnPlace()
|
||||||
@@ -90,13 +91,19 @@ public class Field : Building
|
|||||||
state = FieldState.DEAD;
|
state = FieldState.DEAD;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
daysSincePlanted++;
|
// SetSprite(crop.Sprites[daysSincePlanted]);
|
||||||
if (daysSincePlanted >= crop.daysToGrow)
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MonthInterval()
|
||||||
|
{
|
||||||
|
if (state == FieldState.GROWING)
|
||||||
|
{
|
||||||
|
if (crop.SeasonToHarvest == TimeManager.CurrentSeason)
|
||||||
{
|
{
|
||||||
state = FieldState.HARVESTABLE;
|
state = FieldState.HARVESTABLE;
|
||||||
}
|
}
|
||||||
SetSprite(crop.sprites[daysSincePlanted]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +116,7 @@ public class Field : Building
|
|||||||
daysSincePlanted = 0;
|
daysSincePlanted = 0;
|
||||||
state = FieldState.GROWING;
|
state = FieldState.GROWING;
|
||||||
crop = newCrop;
|
crop = newCrop;
|
||||||
SetSprite(crop.sprites[0]);
|
SetSprite(crop.Sprites[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -122,7 +129,7 @@ public class Field : Building
|
|||||||
{
|
{
|
||||||
if (state == FieldState.HARVESTABLE)
|
if (state == FieldState.HARVESTABLE)
|
||||||
{
|
{
|
||||||
FarmManager.Instance.HarvestInventory.Add(crop.harvest, size.x * size.y);
|
FarmManager.Instance.HarvestInventory.Add(crop.HarvestItem, size.x * size.y);
|
||||||
state = FieldState.EMPTY;
|
state = FieldState.EMPTY;
|
||||||
SetSprite(null);
|
SetSprite(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ public class Inventory<TItem> where TItem : Item
|
|||||||
{
|
{
|
||||||
int remainingCount = count;
|
int remainingCount = count;
|
||||||
|
|
||||||
// check if the item is stackable
|
|
||||||
if (item.stackable)
|
|
||||||
{
|
|
||||||
|
|
||||||
// look for an existing stack of the same item in the inventory
|
// look for an existing stack of the same item in the inventory
|
||||||
for (int i = 0; i < items.Length; i++)
|
for (int i = 0; i < items.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -63,7 +59,7 @@ public class Inventory<TItem> where TItem : Item
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,35 @@ using System.Collections.Generic;
|
|||||||
[CreateAssetMenu(fileName = "Crop", menuName = "Harvestdale/Items/Crop", order = 0)]
|
[CreateAssetMenu(fileName = "Crop", menuName = "Harvestdale/Items/Crop", order = 0)]
|
||||||
public class Crop : Item
|
public class Crop : Item
|
||||||
{
|
{
|
||||||
public int daysToGrow;
|
[SerializeField]
|
||||||
public List<Sprite> sprites = new List<Sprite>();
|
private List<Sprite> sprites = new List<Sprite>();
|
||||||
public Harvest harvest;
|
|
||||||
|
[SerializeField]
|
||||||
|
private Harvest harvestItem;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private Season seasonToPlant;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private Season seasonToHarvest;
|
||||||
|
|
||||||
|
public List<Sprite> Sprites
|
||||||
|
{
|
||||||
|
get { return sprites; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Harvest HarvestItem
|
||||||
|
{
|
||||||
|
get { return harvestItem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Season SeasonToPlant
|
||||||
|
{
|
||||||
|
get { return seasonToPlant; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Season SeasonToHarvest
|
||||||
|
{
|
||||||
|
get { return seasonToHarvest; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
[CreateAssetMenu(fileName = "Harvest", menuName = "Harvestdale/Items/Harvest", order = 0)]
|
[CreateAssetMenu(fileName = "Harvest", menuName = "Harvestdale/Items/Harvest", order = 0)]
|
||||||
public class Harvest : Item
|
public class Harvest : Item
|
||||||
{
|
{
|
||||||
|
[SerializeField]
|
||||||
|
private int price;
|
||||||
|
|
||||||
|
public int Price
|
||||||
|
{
|
||||||
|
get { return price; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,21 +3,28 @@ using UnityEngine;
|
|||||||
[CreateAssetMenu(fileName = "Item", menuName = "Harvestdale/Items/Item", order = 0)]
|
[CreateAssetMenu(fileName = "Item", menuName = "Harvestdale/Items/Item", order = 0)]
|
||||||
public class Item : ScriptableObject
|
public class Item : ScriptableObject
|
||||||
{
|
{
|
||||||
public string uuid;
|
[SerializeField]
|
||||||
public string itemName;
|
private string uuid;
|
||||||
|
|
||||||
public Sprite sprite;
|
[SerializeField]
|
||||||
|
private string itemName;
|
||||||
|
|
||||||
[Tooltip("Tools will set this to false on Awake()")]
|
[SerializeField]
|
||||||
public bool stackable = true;
|
private Sprite icon;
|
||||||
public int maxStackSize = 100;
|
|
||||||
|
|
||||||
|
|
||||||
private void OnEnable()
|
public string UUID
|
||||||
{
|
{
|
||||||
if (!stackable)
|
get { return uuid; }
|
||||||
{
|
|
||||||
maxStackSize = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ItemName
|
||||||
|
{
|
||||||
|
get { return itemName; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sprite Icon
|
||||||
|
{
|
||||||
|
get { return icon; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,14 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
public enum Season
|
||||||
|
{
|
||||||
|
SPRING = 1,
|
||||||
|
SUMMER = 2,
|
||||||
|
AUTUMN = 3,
|
||||||
|
WINTER = 4
|
||||||
|
}
|
||||||
|
|
||||||
public class TimeManager : MonoBehaviour
|
public class TimeManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static Action OnMinuteChanged;
|
public static Action OnMinuteChanged;
|
||||||
@@ -16,6 +24,8 @@ public class TimeManager : MonoBehaviour
|
|||||||
public static int Month { get; private set; }
|
public static int Month { get; private set; }
|
||||||
public static int Year { get; private set; }
|
public static int Year { get; private set; }
|
||||||
|
|
||||||
|
public static Season CurrentSeason => (Season)Month;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
[Range(.05f, 10f)]
|
[Range(.05f, 10f)]
|
||||||
private float minuteToRealTime = .05f;
|
private float minuteToRealTime = .05f;
|
||||||
|
|||||||
Reference in New Issue
Block a user