divers changements pour la sortie du second proto

* ajout du panneau solaire #54
* ajout d'un tutoriel #53
* equilibrage du jeu #73
* ajout d'un son pour l'annonce
This commit is contained in:
2025-09-26 16:56:35 +02:00
parent 6d0100d703
commit 099f8bb1be
56 changed files with 1129 additions and 87 deletions

View File

@@ -0,0 +1,37 @@
[gd_scene load_steps=4 format=3 uid="uid://fh3dsuvn5h78"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_ga3ae"]
[ext_resource type="Texture2D" uid="uid://bsgmxvuphn73c" path="res://common/icons/arrow-narrow-down.svg" id="2_kc1j1"]
[ext_resource type="Script" uid="uid://r6hgefyycute" path="res://gui/game/tutorial/in_game_indicator/scripts/in_game_indicator.gd" id="2_kij5i"]
[node name="InGameIndicator" type="CenterContainer"]
modulate = Color(0.91, 0.6521667, 0, 1)
offset_right = 150.0
offset_bottom = 99.0
size_flags_horizontal = 2
size_flags_vertical = 2
mouse_filter = 2
theme = ExtResource("1_ga3ae")
script = ExtResource("2_kij5i")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
theme = ExtResource("1_ga3ae")
theme_override_constants/separation = 0
[node name="Label" type="Label" parent="VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
text = "Text and a very very very long text"
horizontal_alignment = 1
autowrap_mode = 3
[node name="Arrow" type="TextureRect" parent="VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
size_flags_horizontal = 4
texture = ExtResource("2_kc1j1")
expand_mode = 1
stretch_mode = 5

View File

@@ -0,0 +1,47 @@
[gd_scene load_steps=4 format=3 uid="uid://fh3dsuvn5h78"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_ga3ae"]
[ext_resource type="Texture2D" uid="uid://bsgmxvuphn73c" path="res://common/icons/arrow-narrow-down.svg" id="2_kc1j1"]
[ext_resource type="Script" uid="uid://r6hgefyycute" path="res://gui/game/tutorial/in_game_indicator/scripts/in_game_indicator.gd" id="2_kij5i"]
[node name="InGameIndicator" type="Control"]
modulate = Color(0.91, 0.6521667, 0, 1)
layout_mode = 3
anchors_preset = 0
offset_right = 50.0
offset_bottom = 73.0
size_flags_horizontal = 0
size_flags_vertical = 0
mouse_filter = 2
theme = ExtResource("1_ga3ae")
script = ExtResource("2_kij5i")
game_position = null
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -50.0
offset_top = -64.5
offset_bottom = 8.5
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_ga3ae")
theme_override_constants/separation = 0
[node name="Label" type="Label" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Text"
horizontal_alignment = 1
[node name="Arrow" type="TextureRect" parent="VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
texture = ExtResource("2_kc1j1")
expand_mode = 1
stretch_mode = 5

View File

@@ -0,0 +1,68 @@
extends Control
class_name InGameIndicator
const UP_SHIFT = 70
const SCREEN_MARGIN = 20
enum FollowingType {GAME_POS, SCREEN_POS, ENTITY}
var following_type: FollowingType = FollowingType.SCREEN_POS
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
%Label.text = text
func follow_game_position(game_position : Vector2):
following_game_position = game_position
following_type = FollowingType.GAME_POS
func follow_screen_position(screen_position : Vector2):
following_screen_position = screen_position
following_type = FollowingType.SCREEN_POS
func follow_entity(entity : Node2D):
following_entity = entity
following_type = FollowingType.ENTITY
func _process(_d):
if camera:
show()
var screen_size = get_viewport().get_visible_rect().size
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
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
else:
hide()

View File

@@ -0,0 +1 @@
uid://r6hgefyycute

View File

@@ -0,0 +1,169 @@
extends Control
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] = [
TakeShovelStep.new(),
DigLootStep.new(),
TakeSeedStep.new(),
PlantSeedStep.new(),
RechargeStep.new(),
WaitMaturePlant.new(),
HarvestMaturePlant.new(),
]
var actual_step : Step = null : set = pass_to_step
func _process(_d):
if not GameInfo.game_data.tutorial_done:
if not actual_step and len(steps):
destroy_indicators()
pass_to_step(steps.pop_front())
if player and actual_step and actual_step.is_step_over(player):
destroy_indicators()
if len(steps):
pass_to_step(steps.pop_front())
else :
GameInfo.game_data.tutorial_done = true
func destroy_indicators():
for i in indicators:
i.queue_free()
indicators = []
func pass_to_step(new_step : Step):
actual_step = new_step
indicators = new_step.generate_indicators(camera, player)
for i in indicators:
add_child(i)
class Step:
func generate_indicator(cam : Camera2D, 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]:
return []
func is_step_over(p : Player) -> bool:
return true
class TakeShovelStep extends Step:
func generate_indicators(cam : Camera2D, p: Player) -> Array[InGameIndicator]:
for entity in p.planet.entityContainer.get_children():
if entity is ItemObject and entity.item is Shovel:
var indicator = generate_indicator(cam, "Take the Shovel")
indicator.follow_entity(entity)
return [
indicator
]
printerr("No Shovel found...")
return []
func is_step_over(p : Player) -> bool:
return p.inventory.length() > 0
class DigLootStep extends Step:
func generate_indicators(cam : Camera2D, p: Player) -> Array[InGameIndicator]:
var indicators : Array[InGameIndicator] = []
for entity in p.planet.entityContainer.get_children():
if entity is UndergroundLoot:
var indicator = generate_indicator(cam, "Dig Underground Loot")
indicator.follow_entity(entity)
indicators.append(
indicator
)
return indicators
func is_step_over(p : Player) -> bool:
for entity in p.planet.entityContainer.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]:
var indicators : Array[InGameIndicator] = []
for entity in p.planet.entityContainer.get_children():
if entity is ItemObject and entity.item is Seed:
var indicator = generate_indicator(cam, "Take a seed")
indicator.follow_entity(entity)
indicators.append(
indicator
)
return indicators
func is_step_over(p : Player) -> bool:
for item in p.inventory.items:
if item is Seed:
return true
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")
indicator.follow_game_position(Vector2(60,60) + p.planet.entityContainer.global_position)
return [indicator]
func is_step_over(p : Player) -> bool:
for entity in p.planet.entityContainer.get_children():
if entity is Plant:
return true
return false
class RechargeStep extends Step:
func generate_indicators(cam : Camera2D, p: Player) -> Array[InGameIndicator]:
for entity in p.planet.entityContainer.get_children():
var indicator = generate_indicator(cam, "Recharge to pass days")
indicator.follow_entity(entity)
if entity is RechargeStation:
return [
indicator
]
printerr("No Recharge Station found...")
return []
func is_step_over(p : Player) -> bool:
return p.planet.day > 1
class WaitMaturePlant extends Step:
func generate_indicators(_cam : Camera2D, _p: Player) -> Array[InGameIndicator]:
return []
func is_step_over(p : Player) -> bool:
for entity in p.planet.entityContainer.get_children():
if entity is Plant and entity.state == Plant.State.MATURE:
return true
return false
class HarvestMaturePlant extends Step:
var mature_plant_number : int = 0
func generate_indicators(cam : Camera2D, p: Player) -> Array[InGameIndicator]:
var indicators : Array[InGameIndicator] = []
for entity in p.planet.entityContainer.get_children():
if entity is Plant and entity.state == Plant.State.MATURE:
var indicator = generate_indicator(cam, "Harvest mature plants with shovel")
indicator.follow_entity(entity)
indicators.append(
indicator
)
mature_plant_number += 1
return indicators
func is_step_over(p : Player) -> bool:
var actual_mature_plant_number = 0
for entity in p.planet.entityContainer.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

View File

@@ -0,0 +1 @@
uid://beg7favg2ukbi

View File

@@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://dt6mptqg80dew"]
[ext_resource type="Script" uid="uid://beg7favg2ukbi" path="res://gui/game/tutorial/scripts/tutorial.gd" id="1_ie1q8"]
[node name="Tutorial" type="Control"]
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("1_ie1q8")