Feature pour l'alpha 1.3
* Ajout d'un mode infini (pour nos hard core gamers) * Ajout d'un message de découverte d'un nouvel outil * Séparation de la pelle en deux outils : la pioche et la fourche * Amélioration de la lisibilité des capsules d'énergies * Changement léger des texture du sol et de la pierre * Correction d'un bug lors du clic frénétique sur le porte de sortie du vaisseau * Ajout d'un icône de recharge * Fix de la mutation Ancien qui ne s'améliorait pas au niveau 4 + début de dev des artefacts avec un distributeur
This commit is contained in:
@@ -1,12 +1,89 @@
|
||||
extends Control
|
||||
@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 announce(title : String, text : String, band_color : Color = YELLOW_COLOR):
|
||||
%AnnounceTitle.text = title
|
||||
%AnnounceText.text = text
|
||||
%AnnounceTexture.modulate = band_color
|
||||
%AnimationPlayer.play("pass")
|
||||
AudioManager.play_sfx("Announce")
|
||||
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")
|
||||
AudioManager.play_sfx("Ship_reveal")
|
||||
elif object == null and visible:
|
||||
%AnimationPlayer.play_backwards("appear")
|
||||
|
||||
announce_object = object
|
||||
|
||||
func _on_ok_button_down():
|
||||
if announce_object:
|
||||
announce_object._on_dismiss()
|
||||
announce_object = null
|
||||
|
||||
Reference in New Issue
Block a user