plant needs and adds
This commit was merged in pull request #5.
This commit is contained in:
@@ -9,13 +9,14 @@ extends Resource
|
||||
@export var growing_time := 1.0
|
||||
@export var dying_time := 30.0
|
||||
|
||||
@export var water_need := 0
|
||||
@export var soil_need := 0
|
||||
@export var distance_needed := 0.1
|
||||
@export var water_need := [0, 0] # min max
|
||||
@export var fertility_need := [0, 0] # min max
|
||||
@export var presence_need := [0, 0] # min max
|
||||
|
||||
@export var water_prod := 0
|
||||
@export var soil_prod := 0
|
||||
@export var fertility_prod := 0
|
||||
@export var presence_prod := 1
|
||||
|
||||
@export var dead_water_prod := 0
|
||||
@export var dead_soil_prod := 1
|
||||
@export var distance_prod := 0.1
|
||||
@export var dead_fertility_prod := 1
|
||||
@export var distance_prod := 50
|
||||
|
||||
18
scripts/planter.gd
Normal file
18
scripts/planter.gd
Normal file
@@ -0,0 +1,18 @@
|
||||
class_name Planter
|
||||
|
||||
extends Node
|
||||
|
||||
@export var plants: Array[PlantType]
|
||||
|
||||
@onready var plant_scene = preload("res://objects/Plant.tscn")
|
||||
@onready var timer: Timer = $Timer
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if Input.is_action_just_pressed("plant") and timer.is_stopped():
|
||||
var chosen_type: PlantType = plants[randi_range(0, plants.size() - 1)]
|
||||
var plant = plant_scene.instantiate()
|
||||
add_child(plant)
|
||||
plant.init(chosen_type)
|
||||
plant.plant(event.position)
|
||||
timer.start()
|
||||
@@ -1,6 +1,6 @@
|
||||
extends Node2D
|
||||
|
||||
enum Stats {WATER, FERTILITY, TEMPERATURE}
|
||||
enum Stats {WATER, FERTILITY, PRESENCE}
|
||||
|
||||
const TERRAIN_SIZE = Vector2i(300, 300)
|
||||
const LEVELS_NUMBER : int = 10
|
||||
@@ -19,7 +19,7 @@ var sum := 0.0
|
||||
signal terrain_updated
|
||||
|
||||
func _ready():
|
||||
setup_texture(Vector3i())
|
||||
setup_texture(Vector3i(0, 0, -5))
|
||||
|
||||
func map_to_pixel(
|
||||
position : Vector2
|
||||
@@ -74,7 +74,7 @@ func modification_to_levels(
|
||||
levels.x = modification
|
||||
Stats.FERTILITY:
|
||||
levels.y = modification
|
||||
Stats.TEMPERATURE:
|
||||
Stats.PRESENCE:
|
||||
levels.z = modification
|
||||
return levels
|
||||
|
||||
@@ -132,7 +132,7 @@ func modify_rect(
|
||||
func get_stat(
|
||||
pos: Vector2,
|
||||
stat : Stats
|
||||
) :
|
||||
) -> int:
|
||||
var pixel_pos = map_to_pixel(pos)
|
||||
var levels = color_to_levels(image.get_pixelv(pixel_pos))
|
||||
match stat:
|
||||
@@ -140,8 +140,10 @@ func get_stat(
|
||||
return levels.x
|
||||
Stats.FERTILITY:
|
||||
return levels.y
|
||||
Stats.TEMPERATURE:
|
||||
Stats.PRESENCE:
|
||||
return levels.z
|
||||
_:
|
||||
return 0
|
||||
|
||||
func setup_texture(
|
||||
levels : Vector3i
|
||||
|
||||
Reference in New Issue
Block a user