changement du scene manager, amélioration du cockpit et autres
* refonte du scene manager * refonte du audio manager * premier rework des plantes * nettoyage des dossiers/fichiers * renommage de planète en region * fix des run
This commit is contained in:
@@ -2,15 +2,35 @@ extends Node3D
|
||||
class_name Cockpit
|
||||
|
||||
func _ready():
|
||||
if not GameInfo.game_data.get_current_planet_data():
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
var region_data := GameInfo.game_data.current_region_data
|
||||
|
||||
if not GameInfo.game_data.current_region_data:
|
||||
%ExitAction.hide()
|
||||
%ExitAction.pickable = false
|
||||
|
||||
if region_data:
|
||||
var state := region_data.get_state()
|
||||
match state:
|
||||
RegionData.State.IN_PROGRESS:
|
||||
%StateAnimationPlayer.play("InProgress")
|
||||
%MapAction.hide()
|
||||
%MapAction.pickable = false
|
||||
RegionData.State.FAILED:
|
||||
%StateAnimationPlayer.play("Failed")
|
||||
RegionData.State.SUCCEEDED:
|
||||
%StateAnimationPlayer.play("Succeeded")
|
||||
update_screen_info(region_data)
|
||||
|
||||
func _on_map_action_clicked():
|
||||
SceneManager.change_scene(SceneManager.REGION_SELECTION_SCREEN)
|
||||
SceneManager.change_scene("REGION_SELECTION")
|
||||
|
||||
func _on_exit_action_clicked():
|
||||
if GameInfo.game_data.get_current_planet_data():
|
||||
%ArriveAnimationPlayer.play_backwards("arrive")
|
||||
await %ArriveAnimationPlayer.animation_finished
|
||||
SceneManager.change_scene(SceneManager.PLANET_SCENE)
|
||||
if GameInfo.game_data.current_region_data:
|
||||
SceneManager.change_scene("REGION")
|
||||
|
||||
func update_screen_info(region_data : RegionData):
|
||||
%RegionNameInfo.text = region_data.region_name
|
||||
%DayNumberInfo.text = tr("DAY_%d") % region_data.day
|
||||
%PlantNumberInfo.text = tr("%d_PLANTS") % len(region_data.score_by_plant)
|
||||
%PlantPointInfo.text = tr("SCORE_%d") % region_data.get_score()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
extends Area3D
|
||||
class_name CockpitAction
|
||||
|
||||
var pickable = true
|
||||
|
||||
signal clicked
|
||||
|
||||
@export var animation_player : AnimationPlayer
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
extends Camera3D
|
||||
|
||||
const RAY_LENGTH = 1000.
|
||||
|
||||
var cockpit_action_hovered : CockpitAction = 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 cockpit_action_hovered and cockpit_action_hovered:
|
||||
cockpit_action_hovered.click()
|
||||
|
||||
func _physics_process(_delta):
|
||||
if _query_mouse:
|
||||
update_mouse_hovered_cockpit_actions()
|
||||
_query_mouse = false
|
||||
|
||||
func update_mouse_hovered_cockpit_actions() -> 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)
|
||||
query.collide_with_areas = true
|
||||
var result = space_state.intersect_ray(query)
|
||||
|
||||
if result.is_empty():
|
||||
if cockpit_action_hovered:
|
||||
cockpit_action_hovered._on_mouse_exited()
|
||||
cockpit_action_hovered = null
|
||||
elif result.collider is CockpitAction:
|
||||
if cockpit_action_hovered and cockpit_action_hovered != result.collider:
|
||||
cockpit_action_hovered._on_mouse_exited()
|
||||
cockpit_action_hovered = result.collider
|
||||
cockpit_action_hovered._on_mouse_entered()
|
||||
@@ -1 +0,0 @@
|
||||
uid://jsxatpqfid88
|
||||
Reference in New Issue
Block a user