Dev Demo
* pleins de choses et j'ai pas le temps * mais en gros * le détecteur détecte les cellules * ajout du sprite de Demeter * ajout d'une limite dans la map * la recharge ne peut plus de nouveau être utilisée après la fin de la région
This commit is contained in:
@@ -33,4 +33,3 @@ func use(player : Player, zone: Player.ActionZone):
|
||||
detector_signal.global_position = zone.get_global_position()
|
||||
|
||||
player.region.add_child(detector_signal)
|
||||
AudioManager.play_sfx("Signal")
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
extends Node2D
|
||||
class_name DetectorSignal
|
||||
|
||||
|
||||
const SIGNAL_DURATION = 1.2
|
||||
const PARTICLES_DISTANCE = 180
|
||||
const ICON_SIZE = 40
|
||||
@@ -12,9 +13,18 @@ const DEFAULT_ICON = preload("res://common/icons/north-star.svg")
|
||||
const ENERGY_ICON = preload("res://common/icons/bolt.svg")
|
||||
const DOOR_ICON = preload("res://common/icons/logout.svg")
|
||||
const PLANT_ICON = preload("res://common/icons/seedling.svg")
|
||||
const SOUND_SOURCE : AudioStreamMP3 = preload("res://common/audio_manager/assets/sfx/signal/signal.mp3")
|
||||
const SOUND_BASE_PITCH = 1.
|
||||
const SOUND_NIVEL_LEVEL = 6
|
||||
|
||||
const CELL_DETECTION_MAX_DISTANCE = 2000.
|
||||
const CELL_DETECTION_COLOR : Color = Color("#ff006e")
|
||||
const CELL_DETECTION_MAX_PITCH = 1.5
|
||||
|
||||
var started_time = 0.
|
||||
var signals : Array[DetectorSignalIndividual] = []
|
||||
var nearest_cell : Node2D
|
||||
var nearest_cell_distance := CELL_DETECTION_MAX_DISTANCE
|
||||
|
||||
@export_tool_button("Start", "Callable") var start = func(): started_time = 0
|
||||
|
||||
@@ -37,6 +47,15 @@ func _init(region : Region, pos : Vector2):
|
||||
Color("ffa617ff")
|
||||
),
|
||||
)
|
||||
if (
|
||||
(e is EnergyCell
|
||||
or e is TalionCell)
|
||||
and e.available
|
||||
and e.global_position.distance_to(pos) < nearest_cell_distance
|
||||
):
|
||||
nearest_cell = e
|
||||
nearest_cell_distance = e.global_position.distance_to(pos)
|
||||
|
||||
# if e is Plant:
|
||||
# signals.append(
|
||||
# DetectorSignalIndividual.new(
|
||||
@@ -44,15 +63,37 @@ func _init(region : Region, pos : Vector2):
|
||||
# PLANT_ICON
|
||||
# )
|
||||
# )
|
||||
func _ready():
|
||||
var player = AudioStreamPlayer2D.new()
|
||||
player.stream = SOUND_SOURCE
|
||||
player.volume_db = -10
|
||||
player.bus = &"Sfx"
|
||||
|
||||
player.pitch_scale = lerp(
|
||||
CELL_DETECTION_MAX_PITCH,
|
||||
SOUND_BASE_PITCH,
|
||||
nearest_cell_distance/CELL_DETECTION_MAX_DISTANCE
|
||||
)
|
||||
player.pitch_scale = ceil(player.pitch_scale * SOUND_NIVEL_LEVEL) / SOUND_NIVEL_LEVEL
|
||||
add_child(player)
|
||||
player.play()
|
||||
|
||||
func _draw():
|
||||
if started_time < SIGNAL_DURATION:
|
||||
|
||||
var color = lerp(
|
||||
CELL_DETECTION_COLOR,
|
||||
Color.WHITE,
|
||||
nearest_cell_distance/CELL_DETECTION_MAX_DISTANCE
|
||||
)
|
||||
color.a = 0.7*1-started_time/SIGNAL_DURATION
|
||||
|
||||
draw_circle(
|
||||
Vector2.ZERO,
|
||||
started_time/SIGNAL_DURATION * PARTICLES_DISTANCE,
|
||||
Color(1.,1.,1.,0.5*1-started_time/SIGNAL_DURATION),
|
||||
color,
|
||||
false,
|
||||
5.
|
||||
8.
|
||||
)
|
||||
for s in signals:
|
||||
draw_texture_rect(
|
||||
|
||||
Reference in New Issue
Block a user