81 lines
1.8 KiB
C#
81 lines
1.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class GrowBlock : MonoBehaviour
|
|
{
|
|
|
|
public enum GrowthStage
|
|
{
|
|
barren,
|
|
ploughed,
|
|
planted,
|
|
growing1,
|
|
growing2,
|
|
ripe
|
|
}
|
|
|
|
public GrowthStage currentStage;
|
|
|
|
[SerializeField]
|
|
private GameObject growBlock;
|
|
|
|
[SerializeField]
|
|
private Material drySoilMaterial;
|
|
|
|
[SerializeField]
|
|
private Material wetSoilMaterial;
|
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
/*if(Keyboard.current.eKey.wasPressedThisFrame)
|
|
{
|
|
AdvanceStage();
|
|
|
|
SetSoil();
|
|
}*/
|
|
}
|
|
|
|
public void AdvanceStage()
|
|
{
|
|
currentStage = currentStage + 1;
|
|
if ((int)currentStage >= 6)
|
|
{
|
|
currentStage = GrowthStage.barren;
|
|
}
|
|
//currentStage++;
|
|
}
|
|
|
|
public void SetSoil()
|
|
{
|
|
if(currentStage == GrowthStage.barren)
|
|
{
|
|
growBlock.GetComponent<Renderer>().enabled = false;
|
|
growBlock.GetComponent<BoxCollider>().enabled = false;
|
|
// growBlock.GetComponent<Renderer>().material = drySoilMaterial;
|
|
}
|
|
else
|
|
{
|
|
growBlock.GetComponent<Renderer>().material = drySoilMaterial;
|
|
growBlock.GetComponent<Renderer>().enabled = true;
|
|
growBlock.GetComponent<BoxCollider>().enabled = true;
|
|
//growBlock.GetComponent<Renderer>().material = wetSoilMaterial;
|
|
}
|
|
}
|
|
|
|
public void PloughSoil()
|
|
{
|
|
if(currentStage == GrowthStage.barren)
|
|
{
|
|
currentStage = GrowthStage.ploughed;
|
|
SetSoil();
|
|
}
|
|
}
|
|
}
|