43 lines
1.8 KiB
GDScript
43 lines
1.8 KiB
GDScript
extends Control
|
|
|
|
@onready var nom: Label = $Card/MarginContainer/VBoxContainer/Nom
|
|
@onready var image: TextureRect = $Card/MarginContainer/VBoxContainer/Image
|
|
|
|
@onready var waterNeeds : StatsArea = $Card/MarginContainer/VBoxContainer/WaterNeeds/StatsArea
|
|
@onready var fertilityNeeds : StatsArea = $Card/MarginContainer/VBoxContainer/FertilityNeeds/StatsArea
|
|
@onready var populationNeeds : StatsArea = $Card/MarginContainer/VBoxContainer/Population/StatsArea
|
|
|
|
@onready var waterSupply : Label = $Card/MarginContainer/VBoxContainer/WaterSupply/Supply
|
|
@onready var fertilitySupply : Label = $Card/MarginContainer/VBoxContainer/FertilitySupply/Supply
|
|
@onready var populationSupply : Label = $Card/MarginContainer/VBoxContainer/PopulationSupply/Supply
|
|
|
|
|
|
var planter: Planter
|
|
|
|
func update_card():
|
|
var next_seed_param := planter.get_plant_from_queue()
|
|
nom.text = next_seed_param.type
|
|
image.texture = next_seed_param.sprite_frames.get_frame_texture("GROWN", 0)
|
|
|
|
waterNeeds.set_area(next_seed_param.water_need)
|
|
fertilityNeeds.set_area(next_seed_param.fertility_need)
|
|
var real_presence_need = next_seed_param.presence_need.map(
|
|
func(value): return value - GameTerrain.LEVELS_NUMBER/2
|
|
)
|
|
populationNeeds.set_area(real_presence_need)
|
|
|
|
waterSupply.text = str(next_seed_param.water_prod)
|
|
fertilitySupply.text = str(next_seed_param.fertility_prod)
|
|
populationSupply.text = str(next_seed_param.presence_prod)
|
|
|
|
func update_mouse_position(mouse_position):
|
|
if (
|
|
mouse_position.x > 0
|
|
and mouse_position.y > 0
|
|
and mouse_position.x < GameTerrain.TERRAIN_SIZE.x * GameTerrain.MAP_RATIO
|
|
and mouse_position.y < GameTerrain.TERRAIN_SIZE.y * GameTerrain.MAP_RATIO
|
|
):
|
|
waterNeeds.set_cursor(GameTerrain.get_color(mouse_position).r)
|
|
fertilityNeeds.set_cursor(GameTerrain.get_color(mouse_position).g)
|
|
populationNeeds.set_cursor(GameTerrain.get_color(mouse_position).b)
|