* Suppression de la mutation éphémère * Ajout des modificateur de régions normaux Sableux et Toxique * Ajout de modificateurs challenge (Rocheux, Radioactif et Contaminé) * Ajout du modificateur de région bénéfique Résonnance * Ajout d'un distributeur toutes les 3 régions * Ajout des régions challenge * Bouclage sur les couleurs des mutations après le niveau 4 * Ajout de deux nouveaux panneaux de tutoriel, un sur les informations de plantes et l'autre sur le vaisseau
94 lines
2.6 KiB
GDScript
94 lines
2.6 KiB
GDScript
@tool
|
|
extends CanvasLayer
|
|
class_name Announce
|
|
|
|
const DEFAULT_OBJECT_ACCELERATION = Vector2(3,0)
|
|
|
|
@export var announce_object : AnnouceObject = null : set = set_announce_object
|
|
|
|
@export_tool_button("Update", "Callable") var update_action = set_announce_object
|
|
|
|
var announce_objects : Array[AnnouceObject] = []
|
|
|
|
var object_acceleration := Vector2(0,0)
|
|
|
|
var rotating := false
|
|
|
|
var prev_mouse_pos : Vector2
|
|
var next_mouse_pos : Vector2
|
|
|
|
const YELLOW_COLOR = Color("e29f32")
|
|
const RED_COLOR = Color("f20058")
|
|
|
|
func _ready():
|
|
set_announce_object()
|
|
%OkButton.button_down.connect(_on_ok_button_down)
|
|
hide()
|
|
|
|
|
|
GameInfo.game_data.player_data.inventory.tool_added.connect(
|
|
func (i : Item):
|
|
announce_objects.append(AnnounceTool.new(i))
|
|
)
|
|
|
|
func _process(delta):
|
|
if announce_object == null and not visible and len(announce_objects) > 0:
|
|
announce_object = announce_objects.pop_front()
|
|
update_rotation(delta)
|
|
|
|
func update_rotation(delta):
|
|
if visible:
|
|
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
|
|
object_acceleration = Vector2(
|
|
float(next_mouse_pos.x - prev_mouse_pos.x),
|
|
float(next_mouse_pos.y - prev_mouse_pos.y)
|
|
)
|
|
|
|
var object_rotation = object_acceleration
|
|
|
|
if rotating:
|
|
object_rotation = Vector2(
|
|
float(next_mouse_pos.x - prev_mouse_pos.x),
|
|
float(next_mouse_pos.y - prev_mouse_pos.y)
|
|
)
|
|
prev_mouse_pos = next_mouse_pos
|
|
else :
|
|
object_acceleration = object_acceleration.lerp(DEFAULT_OBJECT_ACCELERATION, 0.1)
|
|
|
|
%AnnouceObject.rotate(Vector3.UP, object_rotation.x * delta)
|
|
%AnnouceObject.rotate(Vector3.RIGHT, object_rotation.y * delta)
|
|
|
|
|
|
func set_announce_object(object := announce_object):
|
|
if is_node_ready() and object:
|
|
for children in %AnnouceObject.get_children():
|
|
children.queue_free()
|
|
|
|
%AnnouceObject.add_child(object.get_3d_object())
|
|
%AnnouceObject.rotation = Vector3.ZERO
|
|
%AnnounceTitle.text = object.get_title()
|
|
%AnnounceText.text = object.get_text()
|
|
%ObjectVisualiser.info = object.get_card_info()
|
|
|
|
if not visible:
|
|
%AnimationPlayer.play("appear")
|
|
Pointer.action_disabled = true
|
|
AudioManager.play_sfx("Ship_reveal")
|
|
elif object == null and visible:
|
|
%AnimationPlayer.play_backwards("appear")
|
|
get_tree().create_timer(0.2).timeout.connect( # Put a delay to not interfere with the ok button click
|
|
func():
|
|
Pointer.action_disabled = false
|
|
)
|
|
announce_object = object
|
|
|
|
func _on_ok_button_down():
|
|
if announce_object:
|
|
announce_object._on_dismiss()
|
|
announce_object = null
|