ajout du camion #87

* changements des objectifs, donnent juste des graines, sprite moins gros et objectifs plus nombreux
* changement de la probabilité de mutation
* refactor du code terrain et planet
This commit is contained in:
2025-10-12 19:59:53 +02:00
parent ef392595de
commit d90d4c5df6
52 changed files with 627 additions and 346 deletions

View File

@@ -57,7 +57,7 @@ func update_no_energy_left_info(energy):
func _on_planet_new_quota_started(planet:Planet):
%Announce.announce(
"New Quota",
"Reach " + str(roundi(planet.next_quota)) + " units before " + str(Planet.DEFAULT_DAY_LIMIT) + " days"
"Reach " + str(roundi(planet.next_quota)) + " garden score before " + str(Planet.DEFAULT_DAY_LIMIT) + " days"
)
func _on_planet_pass_day_ended(planet:Planet):
@@ -65,12 +65,12 @@ func _on_planet_pass_day_ended(planet:Planet):
if remaining_days == 1:
%Announce.announce(
"Last day for reaching quota",
str(roundi(planet.next_quota - planet.decontamination_surface)) + " units left to decontaminate",
str(roundi(planet.next_quota - planet.garden_score)) + " garden score left",
Announce.RED_COLOR
)
if remaining_days == 2:
%Announce.announce(
"2 days left before quota's ending",
str(roundi(planet.next_quota - planet.decontamination_surface)) + " units left to decontaminate",
str(roundi(planet.next_quota - planet.garden_score)) + " garden score left",
Announce.YELLOW_COLOR
)

View File

@@ -11,15 +11,12 @@ var following_game_position : Vector2 = Vector2()
var following_screen_position : Vector2 = Vector2()
var following_entity : Node2D = null
@export var camera : Camera2D
var arrow_up : Texture = preload("res://common/icons/arrow-narrow-up.svg")
var arrow_down : Texture = preload("res://common/icons/arrow-narrow-down.svg")
var arrow_right : Texture = preload("res://common/icons/arrow-narrow-right.svg")
var arrow_left : Texture = preload("res://common/icons/arrow-narrow-left.svg")
func setup(_camera : Camera2D, text : String):
camera = _camera
func setup(text : String):
%Label.text = text
func follow_game_position(game_position : Vector2):
@@ -35,34 +32,34 @@ func follow_entity(entity : Node2D):
following_type = FollowingType.ENTITY
func _process(_d):
if camera:
show()
var screen_size = get_viewport().get_visible_rect().size
show()
var abs_position : Vector2 = following_screen_position
if following_type == FollowingType.GAME_POS:
abs_position = following_game_position - camera.global_position + screen_size / 2 + Vector2.UP * UP_SHIFT - size/2
elif following_type == FollowingType.ENTITY and following_entity:
abs_position = following_entity.global_position - camera.global_position + screen_size / 2 + Vector2.UP * UP_SHIFT - size/2
var camera = get_viewport().get_camera_2d()
position = Vector2(
min(max(abs_position.x, SCREEN_MARGIN), screen_size.x - SCREEN_MARGIN),
min(max(abs_position.y, SCREEN_MARGIN), screen_size.y - SCREEN_MARGIN)
)
var screen_size = get_viewport().get_visible_rect().size
var arrow_texture : Texture = arrow_down
if abs_position.y < 0:
arrow_texture = arrow_up
if abs_position.x < 0 :
arrow_texture = arrow_left
if abs_position.x > screen_size.x :
arrow_texture = arrow_right
position.x -= size.x
if abs_position.y > screen_size.y :
arrow_texture = arrow_down
position.y -= size.y
var abs_position : Vector2 = following_screen_position
if following_type == FollowingType.GAME_POS:
abs_position = following_game_position - camera.global_position + screen_size / 2 + Vector2.UP * UP_SHIFT - size/2
elif following_type == FollowingType.ENTITY and following_entity:
abs_position = following_entity.global_position - camera.global_position + screen_size / 2 + Vector2.UP * UP_SHIFT - size/2
%Arrow.texture = arrow_texture
else:
hide()
position = Vector2(
min(max(abs_position.x, SCREEN_MARGIN), screen_size.x - SCREEN_MARGIN),
min(max(abs_position.y, SCREEN_MARGIN), screen_size.y - SCREEN_MARGIN)
)
var arrow_texture : Texture = arrow_down
if abs_position.y < 0:
arrow_texture = arrow_up
if abs_position.x < 0 :
arrow_texture = arrow_left
if abs_position.x > screen_size.x :
arrow_texture = arrow_right
position.x -= size.x
if abs_position.y > screen_size.y :
arrow_texture = arrow_down
position.y -= size.y
%Arrow.texture = arrow_texture

View File

@@ -4,7 +4,6 @@ class_name Tutorial
const INDICATOR_SCENE = preload("res://gui/game/tutorial/in_game_indicator/in_game_indicator.tscn")
var indicators : Array[InGameIndicator]
@export var camera : Camera2D
@export var player : Player
@onready var steps : Array[Step] = [
@@ -38,30 +37,29 @@ func destroy_indicators():
func pass_to_step(new_step : Step):
actual_step = new_step
indicators = new_step.generate_indicators(camera, player)
indicators = new_step.generate_indicators(player)
for i in indicators:
add_child(i)
class Step:
func generate_indicator(cam : Camera2D, text : String) -> InGameIndicator:
func generate_indicator(text : String) -> InGameIndicator:
var new_indicator : InGameIndicator = INDICATOR_SCENE.instantiate()
new_indicator.setup(
cam,
text
)
return new_indicator
func generate_indicators(_cam : Camera2D, _player : Player) -> Array[InGameIndicator]:
func generate_indicators(_player : Player) -> Array[InGameIndicator]:
return []
func is_step_over(p : Player) -> bool:
func is_step_over(_p : Player) -> bool:
return true
class TakeShovelStep extends Step:
func generate_indicators(cam : Camera2D, p: Player) -> Array[InGameIndicator]:
func generate_indicators(p: Player) -> Array[InGameIndicator]:
for entity in p.planet.entity_container.get_children():
if entity is ItemObject and entity.item is Shovel:
var indicator = generate_indicator(cam, "Take the Shovel")
var indicator = generate_indicator("Take the Shovel")
indicator.follow_entity(entity)
return [
indicator
@@ -73,11 +71,11 @@ class TakeShovelStep extends Step:
return p.inventory.length() > 0
class DigLootStep extends Step:
func generate_indicators(cam : Camera2D, p: Player) -> Array[InGameIndicator]:
func generate_indicators(p: Player) -> Array[InGameIndicator]:
var indicators : Array[InGameIndicator] = []
for entity in p.planet.entity_container.get_children():
if entity is UndergroundLoot:
var indicator = generate_indicator(cam, "Dig Underground Loot")
var indicator = generate_indicator("Dig Underground Loot")
indicator.follow_entity(entity)
indicators.append(
indicator
@@ -85,17 +83,17 @@ class DigLootStep extends Step:
return indicators
func is_step_over(p : Player) -> bool:
for entity in p.planet.entity_container.get_children():
for entity in p.terrain.entity_container.get_children():
if entity is ItemObject and entity.item is Seed:
return true
return false
class TakeSeedStep extends Step:
func generate_indicators(cam : Camera2D, p: Player) -> Array[InGameIndicator]:
func generate_indicators(p: Player) -> Array[InGameIndicator]:
var indicators : Array[InGameIndicator] = []
for entity in p.planet.entity_container.get_children():
for entity in p.terrain.entity_container.get_children():
if entity is ItemObject and entity.item is Seed:
var indicator = generate_indicator(cam, "Take a seed")
var indicator = generate_indicator("Take a seed")
indicator.follow_entity(entity)
indicators.append(
indicator
@@ -109,23 +107,23 @@ class TakeSeedStep extends Step:
return false
class PlantSeedStep extends Step:
func generate_indicators(cam : Camera2D, p: Player) -> Array[InGameIndicator]:
var indicator = generate_indicator(cam, "Plant the seed in decontamined zone")
func generate_indicators(p: Player) -> Array[InGameIndicator]:
var indicator = generate_indicator("Plant the seed in decontamined zone")
indicator.follow_game_position(Vector2(0,0) + p.planet.entity_container.global_position)
return [indicator]
func is_step_over(p : Player) -> bool:
for entity in p.planet.entity_container.get_children():
for entity in p.terrain.entity_container.get_children():
if entity is Plant:
return true
return false
class RechargeStep extends Step:
func generate_indicators(cam : Camera2D, p: Player) -> Array[InGameIndicator]:
func generate_indicators(p: Player) -> Array[InGameIndicator]:
for entity in p.planet.entity_container.get_children():
var indicator = generate_indicator(cam, "Recharge to pass days")
var indicator = generate_indicator("Recharge to pass days")
indicator.follow_entity(entity)
if entity is RechargeStation:
if entity is TruckRecharge:
return [
indicator
]
@@ -133,13 +131,17 @@ class RechargeStep extends Step:
return []
func is_step_over(p : Player) -> bool:
if p.planet == null :
return false
return p.planet.day > 1
class WaitMaturePlant extends Step:
func generate_indicators(_cam : Camera2D, _p: Player) -> Array[InGameIndicator]:
func generate_indicators(_p: Player) -> Array[InGameIndicator]:
return []
func is_step_over(p : Player) -> bool:
if p.planet == null :
return false
for entity in p.planet.entity_container.get_children():
if entity is Plant and entity.state == Plant.State.MATURE:
return true
@@ -149,11 +151,11 @@ class HarvestMaturePlant extends Step:
var mature_plant_number : int = 0
func generate_indicators(cam : Camera2D, p: Player) -> Array[InGameIndicator]:
func generate_indicators(p: Player) -> Array[InGameIndicator]:
var indicators : Array[InGameIndicator] = []
for entity in p.planet.entity_container.get_children():
if entity is Plant and entity.state == Plant.State.MATURE:
var indicator = generate_indicator(cam, "Harvest mature plants with shovel")
var indicator = generate_indicator("Harvest mature plants with shovel")
indicator.follow_entity(entity)
indicators.append(
indicator
@@ -162,8 +164,10 @@ class HarvestMaturePlant extends Step:
return indicators
func is_step_over(p : Player) -> bool:
if p.planet == null :
return false
var actual_mature_plant_number = 0
for entity in p.planet.entity_container.get_children():
if entity is Plant and entity.state == Plant.State.MATURE:
actual_mature_plant_number += 1
return mature_plant_number != actual_mature_plant_number
return mature_plant_number != actual_mature_plant_number