develop pland card
This commit is contained in:
@@ -2,8 +2,15 @@ extends Control
|
||||
|
||||
@onready var nom: Label = $Card/MarginContainer/VBoxContainer/Nom
|
||||
@onready var image: TextureRect = $Card/MarginContainer/VBoxContainer/Image
|
||||
@onready var besoins: Label = $Card/MarginContainer/VBoxContainer/Besoins
|
||||
@onready var apports: Label = $Card/MarginContainer/VBoxContainer/Apports
|
||||
|
||||
@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
|
||||
|
||||
@@ -11,5 +18,14 @@ 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)
|
||||
besoins.text = "w: [" + str(next_seed_param.water_need[0]) + ", " + str(next_seed_param.water_need[1]) + "]\nf: [" + str(next_seed_param.fertility_need[0]) + ", " + str(next_seed_param.fertility_need[1]) + "]"
|
||||
apports.text = "w: " + str(next_seed_param.water_prod) + "\nf: " + str(next_seed_param.fertility_prod)
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
extends Control
|
||||
|
||||
@onready var next_seed: TextureRect = $HBoxContainer/NextSeed
|
||||
@onready var queue: HBoxContainer = $HBoxContainer/Queue
|
||||
|
||||
@onready var queue_image := [
|
||||
$HBoxContainer/Queue/Seed1,
|
||||
$HBoxContainer/Queue/Seed2,
|
||||
$HBoxContainer/Queue/Seed3,
|
||||
$HBoxContainer/Queue/Seed4,
|
||||
$HBoxContainer/Queue/Seed5,
|
||||
]
|
||||
|
||||
var planter: Planter
|
||||
|
||||
@@ -9,7 +16,7 @@ func update_queue():
|
||||
var next_seed_param := planter.get_plant_from_queue()
|
||||
next_seed.texture = next_seed_param.seed_sprite
|
||||
var index := 0
|
||||
for child in queue.get_children():
|
||||
for child in queue_image:
|
||||
var seed_param := planter.get_plant_from_queue(index)
|
||||
child.texture = seed_param.seed_sprite
|
||||
index += 1
|
||||
|
||||
28
scripts/gui/stats_area.gd
Normal file
28
scripts/gui/stats_area.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
class_name StatsArea
|
||||
extends CenterContainer
|
||||
|
||||
@export var gradient : GradientTexture1D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
$Gradient.texture = gradient
|
||||
|
||||
func set_area(need : Array):
|
||||
var zone_grad := Gradient.new()
|
||||
|
||||
zone_grad.interpolation_mode = Gradient.GRADIENT_INTERPOLATE_CONSTANT
|
||||
|
||||
zone_grad.set_color(0, Color.BLACK)
|
||||
zone_grad.set_color(1, Color.BLACK)
|
||||
|
||||
var min = (float(need[0]) + GameTerrain.LEVELS_NUMBER/2)/GameTerrain.LEVELS_NUMBER
|
||||
var max = (float(need[1]) + GameTerrain.LEVELS_NUMBER/2)/GameTerrain.LEVELS_NUMBER
|
||||
|
||||
zone_grad.add_point(min, Color(0,0,0,0))
|
||||
zone_grad.add_point(max, Color.BLACK)
|
||||
|
||||
var texture := GradientTexture1D.new()
|
||||
|
||||
texture.gradient = zone_grad
|
||||
|
||||
$Zone.texture = texture
|
||||
Reference in New Issue
Block a user