des trucs

This commit is contained in:
2024-09-04 20:04:20 +02:00
parent fc4be1f695
commit e20ad3db95
33 changed files with 470 additions and 55 deletions

View File

@@ -37,6 +37,11 @@ func update_mouse_position(mouse_position):
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)
var next_seed_param := planter.get_plant_from_queue()
var needs := GameTerrain.get_levels(mouse_position)
var meet_water: bool = needs.x >= next_seed_param.water_need[0] and needs.x <= next_seed_param.water_need[1]
waterNeeds.set_cursor(GameTerrain.get_color(mouse_position).r, meet_water)
var meet_fert: bool = needs.y >= next_seed_param.fertility_need[0] and needs.y <= next_seed_param.fertility_need[1]
fertilityNeeds.set_cursor(GameTerrain.get_color(mouse_position).g, meet_fert)
var meet_pop: bool = needs.z + GameTerrain.LEVELS_NUMBER / 2 >= next_seed_param.presence_need[0] and needs.z + GameTerrain.LEVELS_NUMBER / 2 <= next_seed_param.presence_need[1]
populationNeeds.set_cursor(GameTerrain.get_color(mouse_position).b, meet_pop)

View File

@@ -4,6 +4,8 @@ extends CenterContainer
@export var gradient : GradientTexture1D
const CURSOR_WIDTH = 0.04
const VALID_COLOR := Color(0.1, 0.9, 0.85, 1.0)
const NOT_VALID_COLOR := Color(1.0, 0.0, 0.3, 1.0)
# Called when the node enters the scene tree for the first time.
func _ready():
@@ -29,7 +31,7 @@ func set_area(need : Array):
$Zone.texture = texture
func set_cursor(color_value):
func set_cursor(color_value, is_valid: bool):
var zone_grad := Gradient.new()
zone_grad.interpolation_mode = Gradient.GRADIENT_INTERPOLATE_CONSTANT
@@ -37,8 +39,13 @@ func set_cursor(color_value):
zone_grad.set_color(0, Color(1,1,1,0))
zone_grad.set_color(1, Color(1,1,1,0))
zone_grad.add_point(max(color_value - CURSOR_WIDTH/2, 0.0), Color(1,1,1,1))
zone_grad.add_point(min(color_value + CURSOR_WIDTH/2, 1.0), Color(1,1,1,0))
var color := NOT_VALID_COLOR
if is_valid:
color = VALID_COLOR
zone_grad.add_point(max(color_value - CURSOR_WIDTH/2, 0.0), color)
color.a = 0
zone_grad.add_point(min(color_value + CURSOR_WIDTH/2, 1.0), color)
var texture := GradientTexture1D.new()