folder refactoring, plant_base adjustments
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
|
||||
public partial class FarmingControls : Node3D
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b1sscdr4ptec8
|
||||
@@ -0,0 +1,41 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
|
||||
public enum FieldState
|
||||
{
|
||||
Empty = 0,
|
||||
Tilled = 1,
|
||||
Planted = 2,
|
||||
Watered = 3
|
||||
}
|
||||
|
||||
public partial class FieldBehaviour : Sprite3D
|
||||
{
|
||||
[Export] private Texture2D Untilled;
|
||||
[Export] private Texture2D Tilled;
|
||||
[Export] private Texture3D Watered;
|
||||
[Export] private FieldState FieldState = FieldState.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Called when the player enters the field'S interaction area and presses <E>.
|
||||
/// </summary>
|
||||
public void Farm()
|
||||
{
|
||||
switch (FieldState)
|
||||
{
|
||||
case FieldState.Empty:
|
||||
Texture = Tilled;
|
||||
FieldState = FieldState.Tilled;
|
||||
break;
|
||||
case FieldState.Tilled:
|
||||
FieldState = FieldState.Planted;
|
||||
break;
|
||||
case FieldState.Planted:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://histmmyi1wr
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
|
||||
public enum PlantState
|
||||
{
|
||||
None = 0,
|
||||
Planted = 1,
|
||||
SmallPlant = 2,
|
||||
BigPlant = 3,
|
||||
Ready = 4
|
||||
}
|
||||
|
||||
public partial class PlantBehaviour : Node3D
|
||||
{
|
||||
[Export] private Sprite3D[] _seeds;
|
||||
[Export] private Sprite3D[] _smallPlants;
|
||||
[Export] private Sprite3D[] _bigPlants;
|
||||
[Export] private Sprite3D[] _readyPlants;
|
||||
[Export] private PlantState _state = PlantState.None;
|
||||
|
||||
private Sprite3D _currentPlantSprite = null;
|
||||
|
||||
public void Grow()
|
||||
{
|
||||
switch (_state)
|
||||
{
|
||||
case PlantState.None:
|
||||
_state = PlantState.Planted;
|
||||
_currentPlantSprite = GetRandomSprite(_seeds);
|
||||
_currentPlantSprite.Visible = true;
|
||||
break;
|
||||
case PlantState.Planted:
|
||||
_state = PlantState.SmallPlant;
|
||||
_currentPlantSprite.Visible = false;
|
||||
_currentPlantSprite = GetRandomSprite(_smallPlants);
|
||||
_currentPlantSprite.Visible = true;
|
||||
break;
|
||||
case PlantState.SmallPlant:
|
||||
_state = PlantState.BigPlant;
|
||||
_currentPlantSprite.Visible = false;
|
||||
_currentPlantSprite = GetRandomSprite(_bigPlants);
|
||||
_currentPlantSprite.Visible = true;
|
||||
break;
|
||||
case PlantState.BigPlant:
|
||||
_state = PlantState.Ready;
|
||||
_currentPlantSprite.Visible = false;
|
||||
_currentPlantSprite = GetRandomSprite(_readyPlants);
|
||||
_currentPlantSprite.Visible = true;
|
||||
break;
|
||||
case PlantState.Ready:
|
||||
_state = PlantState.None;
|
||||
_currentPlantSprite.Visible = false;
|
||||
_currentPlantSprite = null;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Sprite3D GetRandomSprite(Sprite3D[] sprites)
|
||||
{
|
||||
Random rand = new Random();
|
||||
return sprites[rand.Next(sprites.Length)];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://yfnjmuuxs3oq
|
||||
Reference in New Issue
Block a user