developpement d'écran de chargement et d'écran de sélection de niveau
* modification de certains assets * optimisation de chunks * ajout d'un SceneManager * ajout d'un premier dialogue avec Demeter * changement des jour en charge * mise en place d'un système de run * etc...
This commit is contained in:
38
stages/region_selection/region_point/region_point.tscn
Normal file
38
stages/region_selection/region_point/region_point.tscn
Normal file
@@ -0,0 +1,38 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://gxbqe5rtqi58"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://j8cd0qbk4bma" path="res://stages/region_selection/region_point/scripts/region_point.gd" id="1_65ijn"]
|
||||
[ext_resource type="Script" uid="uid://b4eimt3v08jhc" path="res://common/game_data/scripts/run/run_point.gd" id="2_34ylp"]
|
||||
[ext_resource type="Script" uid="uid://ddk7j5b8p51dk" path="res://stages/terrain/planet/scripts/planet_parameter.gd" id="3_dm7jk"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqsx56wc73wry" path="res://common/icons/map-pin-check.svg" id="4_ndccb"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ndccb"]
|
||||
script = ExtResource("3_dm7jk")
|
||||
charges = 10
|
||||
objective = 10
|
||||
planet_seed = 4074963764
|
||||
|
||||
[sub_resource type="Resource" id="Resource_txxa3"]
|
||||
script = ExtResource("2_34ylp")
|
||||
level = 1
|
||||
planet_parameter = SubResource("Resource_ndccb")
|
||||
region_name = "Usaf"
|
||||
position = 61
|
||||
metadata/_custom_type_script = "uid://b4eimt3v08jhc"
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_ys0ma"]
|
||||
radius = 1.0629065
|
||||
|
||||
[node name="RegionPoint" type="Area3D"]
|
||||
script = ExtResource("1_65ijn")
|
||||
run_point = SubResource("Resource_txxa3")
|
||||
state = 0
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("SphereShape3D_ys0ma")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 1, 1, 0.5)
|
||||
pixel_size = 0.04
|
||||
billboard = 1
|
||||
texture = ExtResource("4_ndccb")
|
||||
71
stages/region_selection/region_point/scripts/region_point.gd
Normal file
71
stages/region_selection/region_point/scripts/region_point.gd
Normal file
@@ -0,0 +1,71 @@
|
||||
@tool
|
||||
extends Area3D
|
||||
class_name RegionPoint
|
||||
|
||||
enum State {VISITED, CURRENT, TO_VISIT}
|
||||
|
||||
const SPRITE_HOVER_SCALE_MULTIPLIER = 1.5
|
||||
const VISITED_OPACITY = 0.5
|
||||
const YELLOW_COLOR = Color("FFA617")
|
||||
|
||||
const VISITED_SPRITE = preload("res://common/icons/map-pin-check.svg")
|
||||
const CURRENT_SPRITE = preload("res://common/icons/map-pin.svg")
|
||||
const TO_VISIT_SPRITE = preload("res://common/icons/map-pin-empty.svg")
|
||||
|
||||
@export var run_point : RunPoint
|
||||
@export var state : State = State.CURRENT :
|
||||
set(v):
|
||||
state = v
|
||||
if is_node_ready():
|
||||
update_state()
|
||||
|
||||
var hovered := false
|
||||
|
||||
func _ready():
|
||||
update_state()
|
||||
|
||||
func _process(_delta):
|
||||
var scale_multiplier = SPRITE_HOVER_SCALE_MULTIPLIER if hovered else 1.
|
||||
%Sprite3D.scale = lerp(%Sprite3D.scale, Vector3.ONE * scale_multiplier, 0.1)
|
||||
|
||||
func _on_mouse_entered():
|
||||
hovered = true
|
||||
Pointer.inspect(self)
|
||||
|
||||
func _on_mouse_exited():
|
||||
hovered = false
|
||||
Pointer.stop_inspect(self)
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = run_point.card_info()
|
||||
var visited_text = "VISITED_REGION"
|
||||
|
||||
if state == State.CURRENT:
|
||||
visited_text = "CURRENT_REGION"
|
||||
elif state == State.TO_VISIT:
|
||||
visited_text = "REGION_TO_VISIT"
|
||||
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
visited_text,
|
||||
%Sprite3D.texture
|
||||
)
|
||||
)
|
||||
|
||||
return info
|
||||
|
||||
func update_state():
|
||||
var texture = VISITED_SPRITE
|
||||
var color = Color(1.,1.,1.,VISITED_OPACITY)
|
||||
|
||||
if state == State.CURRENT:
|
||||
texture = CURRENT_SPRITE
|
||||
color = Color.WHITE
|
||||
|
||||
elif state == State.TO_VISIT:
|
||||
texture = TO_VISIT_SPRITE
|
||||
color = YELLOW_COLOR
|
||||
|
||||
%Sprite3D.texture = texture
|
||||
%Sprite3D.modulate = color
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://j8cd0qbk4bma
|
||||
148
stages/region_selection/region_selection.tscn
Normal file
148
stages/region_selection/region_selection.tscn
Normal file
@@ -0,0 +1,148 @@
|
||||
[gd_scene load_steps=13 format=3 uid="uid://bjs67nvh61otf"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bmb4beevw5r40" path="res://stages/region_selection/scripts/region_selection.gd" id="1_gqvix"]
|
||||
[ext_resource type="PackedScene" uid="uid://cm5b7w7j6527f" path="res://stages/title_screen/planet_3d.tscn" id="5_bi8m0"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/hud.tres" id="5_twywe"]
|
||||
[ext_resource type="Script" uid="uid://dqj1qh7xcmnhc" path="res://stages/region_selection/scripts/region_selection_camera.gd" id="6_gcxbq"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="6_gqvix"]
|
||||
[ext_resource type="Shader" uid="uid://bv2rghn44mrrf" path="res://stages/title_screen/resources/shaders/stars.gdshader" id="7_2ywd4"]
|
||||
[ext_resource type="PackedScene" uid="uid://rxao2rluuwqq" path="res://gui/game/screen/screen.tscn" id="7_gqvix"]
|
||||
[ext_resource type="Script" path="res://stages/region_selection/scripts/region_selection_travel_validation.gd" id="8_jxqjc"]
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_twywe"]
|
||||
seed = 172208034
|
||||
frequency = 1.0
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ee13y"]
|
||||
shader = ExtResource("7_2ywd4")
|
||||
shader_parameter/sky_color = Color(0.03, 0.05, 0.11, 1)
|
||||
shader_parameter/star_base_color = Color(0.8, 1, 0.3, 1)
|
||||
shader_parameter/star_hue_offset = 0.6
|
||||
shader_parameter/star_intensity = 0.08
|
||||
shader_parameter/star_twinkle_speed = 0.8
|
||||
shader_parameter/star_twinkle_intensity = 0.2
|
||||
shader_parameter/layer_scale = 20.0
|
||||
shader_parameter/layer_scale_step = 10.0
|
||||
shader_parameter/layers_count = 3
|
||||
|
||||
[sub_resource type="Sky" id="Sky_65b6a"]
|
||||
sky_material = SubResource("ShaderMaterial_ee13y")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_187ay"]
|
||||
background_mode = 2
|
||||
sky = SubResource("Sky_65b6a")
|
||||
sky_custom_fov = 61.7
|
||||
reflected_light_source = 1
|
||||
tonemap_exposure = 1.54
|
||||
glow_enabled = true
|
||||
glow_intensity = 1.22
|
||||
glow_bloom = 0.39
|
||||
glow_hdr_threshold = 0.81
|
||||
glow_hdr_scale = 0.0
|
||||
glow_hdr_luminance_cap = 0.3
|
||||
fog_density = 0.0
|
||||
fog_sky_affect = 0.0
|
||||
adjustment_enabled = true
|
||||
adjustment_brightness = 1.04
|
||||
adjustment_contrast = 1.2
|
||||
adjustment_saturation = 0.88
|
||||
|
||||
[node name="RegionSelectionScreen" type="Node3D"]
|
||||
script = ExtResource("1_gqvix")
|
||||
|
||||
[node name="Planet3d" parent="." instance=ExtResource("5_bi8m0")]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(0.17364822, 0, -0.9848077, 0, 1, 0, 0.9848077, 0, 0.17364822, 0.0020446777, 0, 0)
|
||||
noise = SubResource("FastNoiseLite_twywe")
|
||||
|
||||
[node name="RegionPointContainer" type="Node3D" parent="Planet3d"]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 0, -79.21178)
|
||||
current = true
|
||||
fov = 34.0
|
||||
script = ExtResource("6_gcxbq")
|
||||
_sprite_layer = 1
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_187ay")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(0.8423772, -0.34588623, 0.4132353, -0.5388884, -0.5406809, 0.6459594, 0, -0.76682913, -0.6418513, 0, 14.918039, 0)
|
||||
|
||||
[node name="Hud" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Hud"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("5_twywe")
|
||||
|
||||
[node name="Label" type="Label" parent="Hud/MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
text = "CHOOSE_A_REGION"
|
||||
label_settings = ExtResource("6_gqvix")
|
||||
|
||||
[node name="ReturnButton" type="Button" parent="Hud/MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 8
|
||||
theme = ExtResource("5_twywe")
|
||||
text = "RETURN"
|
||||
|
||||
[node name="TravelValidation" parent="Hud" instance=ExtResource("7_gqvix")]
|
||||
unique_name_in_owner = true
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -359.0
|
||||
offset_top = -137.0
|
||||
offset_right = 359.0
|
||||
offset_bottom = 96.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
script = ExtResource("8_jxqjc")
|
||||
|
||||
[node name="TravelValidationContainer" type="VBoxContainer" parent="Hud/TravelValidation/ScreenContainer" index="0"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("5_twywe")
|
||||
alignment = 1
|
||||
|
||||
[node name="TravelValidationLabel" type="Label" parent="Hud/TravelValidation/ScreenContainer/TravelValidationContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "TRAVEL_TO_REGION_%s"
|
||||
label_settings = ExtResource("6_gqvix")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="TravelValidationButtons" type="HBoxContainer" parent="Hud/TravelValidation/ScreenContainer/TravelValidationContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("5_twywe")
|
||||
alignment = 1
|
||||
|
||||
[node name="TravelValidationGoButton" type="Button" parent="Hud/TravelValidation/ScreenContainer/TravelValidationContainer/TravelValidationButtons"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("5_twywe")
|
||||
text = "GO"
|
||||
|
||||
[node name="TravelValidationNoNowButton" type="Button" parent="Hud/TravelValidation/ScreenContainer/TravelValidationContainer/TravelValidationButtons"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("5_twywe")
|
||||
text = "NOT_NOW"
|
||||
|
||||
[connection signal="region_point_clicked" from="Camera3D" to="." method="_on_camera_3d_region_point_clicked"]
|
||||
[connection signal="button_down" from="Hud/MarginContainer/ReturnButton" to="." method="_on_return_button_button_down"]
|
||||
[connection signal="button_down" from="Hud/TravelValidation/ScreenContainer/TravelValidationContainer/TravelValidationButtons/TravelValidationGoButton" to="." method="_on_travel_validation_go_button_button_down"]
|
||||
[connection signal="button_down" from="Hud/TravelValidation/ScreenContainer/TravelValidationContainer/TravelValidationButtons/TravelValidationNoNowButton" to="." method="_on_travel_validation_no_now_button_button_down"]
|
||||
|
||||
[editable path="Hud/TravelValidation"]
|
||||
114
stages/region_selection/scripts/region_selection.gd
Normal file
114
stages/region_selection/scripts/region_selection.gd
Normal file
@@ -0,0 +1,114 @@
|
||||
@tool
|
||||
extends Node3D
|
||||
class_name RegionSelection
|
||||
|
||||
const REGION_POINT_SCENE := preload("res://stages/region_selection/region_point/region_point.tscn")
|
||||
const PLANET_REGION_POINT_MARGIN = 0
|
||||
|
||||
var target_planet_rotation = Vector2(0,0)
|
||||
var planet_acceleration := Vector2(0,0)
|
||||
var rotating := false
|
||||
var prev_mouse_pos : Vector2
|
||||
var next_mouse_pos : Vector2
|
||||
|
||||
var selected_run_point : RunPoint
|
||||
|
||||
@export_tool_button("Update Region Points", "Callable") var update_action = update_region_points
|
||||
|
||||
@onready var run_data : RunData = GameInfo.game_data.current_run
|
||||
|
||||
@onready var planet_radius = %Planet3d.radius + %Planet3d.height
|
||||
|
||||
func _ready():
|
||||
%TravelValidation.hide()
|
||||
update_region_points()
|
||||
%Planet3d.generate_noise(GameInfo.game_data.current_run.run_seed)
|
||||
if not GameInfo.game_data.get_current_planet_data():
|
||||
%ReturnButton.hide()
|
||||
|
||||
func _process(delta):
|
||||
if not Engine.is_editor_hint():
|
||||
rotate_planet(delta)
|
||||
|
||||
func rotate_planet(delta):
|
||||
next_mouse_pos = get_viewport().get_mouse_position()
|
||||
if Input.is_action_just_pressed("action"):
|
||||
rotating = true
|
||||
prev_mouse_pos = get_viewport().get_mouse_position()
|
||||
if Input.is_action_just_released("action"):
|
||||
rotating = false
|
||||
var mouse_acceleration = Vector2(
|
||||
float(next_mouse_pos.x - prev_mouse_pos.x),
|
||||
float(next_mouse_pos.y - prev_mouse_pos.y)
|
||||
)
|
||||
planet_acceleration = Vector2(mouse_acceleration.y, - mouse_acceleration.x)
|
||||
|
||||
var planet_rotation = planet_acceleration
|
||||
|
||||
if rotating:
|
||||
var mouse_rotation = Vector2(
|
||||
float(next_mouse_pos.x - prev_mouse_pos.x),
|
||||
float(next_mouse_pos.y - prev_mouse_pos.y)
|
||||
)
|
||||
planet_rotation = Vector2(mouse_rotation.y, - mouse_rotation.x)
|
||||
prev_mouse_pos = next_mouse_pos
|
||||
else :
|
||||
# var default_planet_rotation = Vector2(%Planet3d.rotation.x, %Planet3d.rotation.y) - target_planet_rotation
|
||||
planet_acceleration = planet_acceleration.lerp(Vector2.ZERO, 0.1)
|
||||
# %Planet3d.rotation.z = lerp(%Planet3d.rotation.z, 0., 0.05)
|
||||
|
||||
%Planet3d.rotate(Vector3.LEFT, planet_rotation.x * delta)
|
||||
%Planet3d.rotate(Vector3.DOWN, planet_rotation.y * delta)
|
||||
|
||||
func generate_region_point(run_point : RunPoint, state : RegionPoint.State = RegionPoint.State.VISITED) -> RegionPoint:
|
||||
var region_point := REGION_POINT_SCENE.instantiate() as RegionPoint
|
||||
region_point.run_point = run_point
|
||||
region_point.state = state
|
||||
|
||||
%RegionPointContainer.add_child(region_point)
|
||||
|
||||
|
||||
var sphere_radius = planet_radius + PLANET_REGION_POINT_MARGIN
|
||||
var default_pos = Vector3(0, sphere_radius, 0)
|
||||
var vertical_pos = default_pos.rotated(Vector3.LEFT, run_point.level/float(RunData.RUN_POINT_MAX_LEVEL) * PI)
|
||||
var final_pos = vertical_pos.rotated(Vector3.UP, (run_point.position % 360)/float(360) * 2 * PI)
|
||||
region_point.position = final_pos
|
||||
|
||||
return region_point
|
||||
|
||||
func update_region_points():
|
||||
for c in %RegionPointContainer.get_children():
|
||||
c.queue_free()
|
||||
|
||||
if run_data.current_run_point:
|
||||
generate_region_point(run_data.current_run_point, RegionPoint.State.CURRENT)
|
||||
|
||||
target_planet_rotation = Vector2(
|
||||
0.,
|
||||
- run_data.current_run_point.position/float(360) * 2 * PI,
|
||||
)
|
||||
|
||||
%Planet3d.rotation = Vector3(target_planet_rotation.x, target_planet_rotation.y, 0.)
|
||||
|
||||
for visited_rp in run_data.visited_run_points:
|
||||
generate_region_point(visited_rp, RegionPoint.State.VISITED)
|
||||
|
||||
for to_visit_rp in run_data.next_run_points:
|
||||
generate_region_point(to_visit_rp, RegionPoint.State.TO_VISIT)
|
||||
|
||||
func _on_camera_3d_region_point_clicked(rp : RunPoint):
|
||||
selected_run_point = rp
|
||||
%TravelValidationLabel.text = tr("TRAVEL_TO_REGION_%s") % rp.region_name
|
||||
%TravelValidation.show()
|
||||
|
||||
func _on_travel_validation_go_button_button_down():
|
||||
if selected_run_point:
|
||||
GameInfo.game_data.current_run.choose_next_run_point(selected_run_point)
|
||||
SceneManager.change_scene(SceneManager.PLANET_SCENE)
|
||||
|
||||
func _on_travel_validation_no_now_button_button_down():
|
||||
%TravelValidation.hide()
|
||||
|
||||
func _on_return_button_button_down():
|
||||
if GameInfo.game_data.get_current_planet_data():
|
||||
SceneManager.change_scene(SceneManager.PLANET_SCENE)
|
||||
1
stages/region_selection/scripts/region_selection.gd.uid
Normal file
1
stages/region_selection/scripts/region_selection.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bmb4beevw5r40
|
||||
43
stages/region_selection/scripts/region_selection_camera.gd
Normal file
43
stages/region_selection/scripts/region_selection_camera.gd
Normal file
@@ -0,0 +1,43 @@
|
||||
extends Camera3D
|
||||
|
||||
signal region_point_clicked(rp : RunPoint)
|
||||
|
||||
const RAY_LENGTH = 1000.
|
||||
|
||||
@export_flags_3d_physics var _sprite_layer
|
||||
|
||||
var region_point_hovered : RegionPoint = null
|
||||
var _mouse_event : InputEventMouse
|
||||
var _query_mouse := false
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventMouse:
|
||||
_mouse_event = event
|
||||
_query_mouse = true
|
||||
if event.is_action_pressed("action") and region_point_hovered and region_point_hovered.state == RegionPoint.State.TO_VISIT:
|
||||
region_point_clicked.emit(region_point_hovered.run_point)
|
||||
|
||||
func _physics_process(_delta):
|
||||
if _query_mouse:
|
||||
update_mouse_hovered_region_points()
|
||||
_query_mouse = false
|
||||
|
||||
func update_mouse_hovered_region_points() -> void:
|
||||
|
||||
var space_state = get_world_3d().direct_space_state
|
||||
var from = project_ray_origin(_mouse_event.position)
|
||||
var to = from + project_ray_normal(_mouse_event.position) * RAY_LENGTH
|
||||
|
||||
var query = PhysicsRayQueryParameters3D.create(from, to, _sprite_layer)
|
||||
query.collide_with_areas = true
|
||||
var result = space_state.intersect_ray(query)
|
||||
|
||||
if result.is_empty():
|
||||
if region_point_hovered:
|
||||
region_point_hovered._on_mouse_exited()
|
||||
region_point_hovered = null
|
||||
elif result.collider is RegionPoint:
|
||||
if region_point_hovered and region_point_hovered != result.collider:
|
||||
region_point_hovered._on_mouse_exited()
|
||||
region_point_hovered = result.collider
|
||||
region_point_hovered._on_mouse_entered()
|
||||
@@ -0,0 +1 @@
|
||||
uid://dqj1qh7xcmnhc
|
||||
Reference in New Issue
Block a user