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:
@@ -23,7 +23,7 @@ screen_text = "Hello"
|
||||
screen_turned_on = true
|
||||
metadata/_custom_type_script = "uid://bj4d1x8n8ina"
|
||||
|
||||
[node name="Model" parent="." unique_id=462471051 instance=ExtResource("2_hstrx")]
|
||||
[node name="Model" parent="." unique_id=154868613 instance=ExtResource("2_hstrx")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="ModelBroken" parent="." unique_id=1633938801 instance=ExtResource("4_drapv")]
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -7,7 +7,7 @@ func _ready():
|
||||
|
||||
func update():
|
||||
%EnergyTextContainer.modulate = (
|
||||
Color.WHITE if region.data.charges > 0
|
||||
Color.WHITE if region.data.charges > 0 and region.data.state == RegionData.State.IN_PROGRESS
|
||||
else Color.RED )
|
||||
%EnergyText.text = str(region.data.charges)
|
||||
if not region.data.pass_day_ended.is_connected(update):
|
||||
@@ -17,7 +17,7 @@ func can_interact(_p : Player) -> bool:
|
||||
return (
|
||||
region != null
|
||||
and region.data
|
||||
and region.data.charges > 0
|
||||
and region.data.charges > 0 and region.data.state == RegionData.State.IN_PROGRESS
|
||||
)
|
||||
|
||||
func interact(_p: Player) -> bool:
|
||||
|
||||
@@ -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