Compare commits
4 Commits
a531843208
...
00c7e9bc4c
| Author | SHA1 | Date | |
|---|---|---|---|
| 00c7e9bc4c | |||
| 1a4ce34fa8 | |||
| 6063a4f6c2 | |||
| cedf07766b |
@ -1,7 +1,12 @@
|
|||||||
extends Resource
|
extends Resource
|
||||||
class_name GameData
|
class_name GameData
|
||||||
|
|
||||||
@export var current_planet_data : PlanetData
|
signal current_planet_data_updated(p : PlanetData)
|
||||||
|
|
||||||
|
@export var current_planet_data : PlanetData :
|
||||||
|
set(v):
|
||||||
|
current_planet_data = v
|
||||||
|
current_planet_data_updated.emit(v)
|
||||||
|
|
||||||
@export var unlocked_plant_types_path : Array[PlantType] = [
|
@export var unlocked_plant_types_path : Array[PlantType] = [
|
||||||
preload("res://entities/plants/resources/plant_types/champ.tres"),
|
preload("res://entities/plants/resources/plant_types/champ.tres"),
|
||||||
|
|||||||
@ -1,13 +1,19 @@
|
|||||||
extends Resource
|
extends Resource
|
||||||
class_name PlanetData
|
class_name PlanetData
|
||||||
|
|
||||||
|
signal quota_number_updated(quota : int)
|
||||||
|
signal contamination_updated(decontamination_surface : float)
|
||||||
|
|
||||||
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE = 400.
|
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE = 400.
|
||||||
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE = 100.
|
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE = 100.
|
||||||
const DEFAULT_BASE_SIZE = Vector2(2000,2000)
|
const DEFAULT_BASE_SIZE = Vector2(2000,2000)
|
||||||
|
|
||||||
@export var base_size : Vector2 = Vector2(2000,2000)
|
@export var base_size : Vector2 = Vector2(2000,2000)
|
||||||
@export var contamination : TerrainData
|
@export var contamination : TerrainData
|
||||||
@export var quota_number : int = 0
|
@export var quota_number : int = 0 :
|
||||||
|
set(v):
|
||||||
|
quota_number = v
|
||||||
|
quota_number_updated.emit(v)
|
||||||
|
|
||||||
func _init(_base_size : Vector2 = DEFAULT_BASE_SIZE):
|
func _init(_base_size : Vector2 = DEFAULT_BASE_SIZE):
|
||||||
base_size = _base_size
|
base_size = _base_size
|
||||||
@ -17,6 +23,7 @@ func _init(_base_size : Vector2 = DEFAULT_BASE_SIZE):
|
|||||||
DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE,
|
DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE,
|
||||||
base_size/2
|
base_size/2
|
||||||
)
|
)
|
||||||
|
contamination_updated.emit(get_decontamination_surface())
|
||||||
|
|
||||||
|
|
||||||
func impact_contamination(position : Vector2, impact_radius : float, to_value : float = 1.):
|
func impact_contamination(position : Vector2, impact_radius : float, to_value : float = 1.):
|
||||||
@ -25,6 +32,7 @@ func impact_contamination(position : Vector2, impact_radius : float, to_value :
|
|||||||
impact_radius,
|
impact_radius,
|
||||||
to_value
|
to_value
|
||||||
)
|
)
|
||||||
|
contamination_updated.emit(get_decontamination_surface())
|
||||||
|
|
||||||
func is_in_base(point):
|
func is_in_base(point):
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var game_data : GameData
|
signal game_data_updated(g : GameData)
|
||||||
|
|
||||||
|
var game_data : GameData :
|
||||||
|
set(v):
|
||||||
|
game_data = v
|
||||||
|
game_data_updated.emit(v)
|
||||||
|
|
||||||
func _init():
|
func _init():
|
||||||
if not game_data:
|
if not game_data:
|
||||||
game_data = GameData.new()
|
game_data = GameData.new()
|
||||||
@ -12,7 +12,7 @@ dest_files=["res://.godot/imported/forest_phase_1.ogg-08213a81a42ba2cf4c67c1bfac
|
|||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
loop=false
|
loop=true
|
||||||
loop_offset=0
|
loop_offset=0
|
||||||
bpm=0
|
bpm=0
|
||||||
beat_count=0
|
beat_count=0
|
||||||
|
|||||||
BIN
common/music/assets/forest_phase_2.ogg
Normal file
BIN
common/music/assets/forest_phase_2.ogg
Normal file
Binary file not shown.
19
common/music/assets/forest_phase_2.ogg.import
Normal file
19
common/music/assets/forest_phase_2.ogg.import
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="oggvorbisstr"
|
||||||
|
type="AudioStreamOggVorbis"
|
||||||
|
uid="uid://bqwiaek5b5q00"
|
||||||
|
path="res://.godot/imported/forest_phase_2.ogg-b312ca5fea9e7b3157a9ab7a4cb99dc9.oggvorbisstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://common/music/assets/forest_phase_2.ogg"
|
||||||
|
dest_files=["res://.godot/imported/forest_phase_2.ogg-b312ca5fea9e7b3157a9ab7a4cb99dc9.oggvorbisstr"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=true
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
||||||
@ -12,7 +12,7 @@ dest_files=["res://.godot/imported/vent.ogg-ae488051619e48b592cdcb0ef4467441.ogg
|
|||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
loop=false
|
loop=true
|
||||||
loop_offset=0
|
loop_offset=0
|
||||||
bpm=0
|
bpm=0
|
||||||
beat_count=0
|
beat_count=0
|
||||||
|
|||||||
@ -1,17 +1,25 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://b6hscxcrj065q"]
|
[gd_scene load_steps=5 format=3 uid="uid://b6hscxcrj065q"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://2p5d6vogtn82" path="res://common/music/scripts/music.gd" id="1_ji160"]
|
||||||
[ext_resource type="AudioStream" uid="uid://diyefcv8tqa3r" path="res://common/music/assets/forest_phase_1.ogg" id="1_stre8"]
|
[ext_resource type="AudioStream" uid="uid://diyefcv8tqa3r" path="res://common/music/assets/forest_phase_1.ogg" id="1_stre8"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://bqwiaek5b5q00" path="res://common/music/assets/forest_phase_2.ogg" id="2_ji160"]
|
||||||
[ext_resource type="AudioStream" uid="uid://d1fyd5o331360" path="res://common/music/assets/vent.ogg" id="2_n52pk"]
|
[ext_resource type="AudioStream" uid="uid://d1fyd5o331360" path="res://common/music/assets/vent.ogg" id="2_n52pk"]
|
||||||
|
|
||||||
[node name="Music" type="Node"]
|
[node name="Music" type="Node" node_paths=PackedStringArray("decontamination_musics")]
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
|
script = ExtResource("1_ji160")
|
||||||
|
decontamination_musics = [NodePath("ForestPhase1"), NodePath("ForestPhase2")]
|
||||||
|
decontamination_musics_levels = Array[float]([0.0, 30.0])
|
||||||
|
|
||||||
[node name="AudioStreamPlayer_music" type="AudioStreamPlayer" parent="."]
|
[node name="ForestPhase1" type="AudioStreamPlayer" parent="."]
|
||||||
stream = ExtResource("1_stre8")
|
stream = ExtResource("1_stre8")
|
||||||
autoplay = true
|
volume_db = -10.0
|
||||||
parameters/looping = false
|
|
||||||
|
|
||||||
[node name="AudioStreamPlayer2_ambient" type="AudioStreamPlayer" parent="."]
|
[node name="ForestPhase2" type="AudioStreamPlayer" parent="."]
|
||||||
|
stream = ExtResource("2_ji160")
|
||||||
|
volume_db = -10.0
|
||||||
|
|
||||||
|
[node name="Wind" type="AudioStreamPlayer" parent="."]
|
||||||
stream = ExtResource("2_n52pk")
|
stream = ExtResource("2_n52pk")
|
||||||
autoplay = true
|
autoplay = true
|
||||||
parameters/looping = false
|
parameters/looping = false
|
||||||
|
|||||||
63
common/music/scripts/music.gd
Normal file
63
common/music/scripts/music.gd
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
@export var default_fade_time = 1.0
|
||||||
|
|
||||||
|
@export var decontamination_musics : Array[AudioStreamPlayer]
|
||||||
|
@export var decontamination_musics_levels : Array[float]
|
||||||
|
|
||||||
|
@onready var playing_music = null : set = play_music
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
GameInfo.game_data.current_planet_data_updated.connect(_on_current_planet_data_updated)
|
||||||
|
|
||||||
|
func _on_current_planet_data_updated(planet_data : PlanetData):
|
||||||
|
if planet_data:
|
||||||
|
planet_data.contamination_updated.connect(_on_contamination_updated)
|
||||||
|
if len(decontamination_musics):
|
||||||
|
play_music(decontamination_musics[0])
|
||||||
|
|
||||||
|
func _on_contamination_updated(decontamination_surface : float):
|
||||||
|
var actual_level = 0
|
||||||
|
if len(decontamination_musics_levels) and len(decontamination_musics):
|
||||||
|
for level in range(1, len(decontamination_musics_levels)):
|
||||||
|
if decontamination_surface > decontamination_musics_levels[level]:
|
||||||
|
actual_level = level
|
||||||
|
|
||||||
|
print(actual_level)
|
||||||
|
|
||||||
|
if len(decontamination_musics) > actual_level:
|
||||||
|
play_music(decontamination_musics[actual_level])
|
||||||
|
|
||||||
|
func stop_music():
|
||||||
|
play_music(null)
|
||||||
|
|
||||||
|
func play_music(music : AudioStreamPlayer):
|
||||||
|
if playing_music != null:
|
||||||
|
if playing_music != music:
|
||||||
|
if playing_music:
|
||||||
|
await audio_fade(playing_music, false).finished
|
||||||
|
|
||||||
|
if music:
|
||||||
|
music.play()
|
||||||
|
elif music != null and music != playing_music:
|
||||||
|
music.play()
|
||||||
|
playing_music = music
|
||||||
|
|
||||||
|
func audio_fade(music : AudioStreamPlayer, fade_in = true, fade_time = default_fade_time) -> Tween:
|
||||||
|
var fade_tween : Tween = get_tree().create_tween()
|
||||||
|
var music_default_volume = music.volume_db
|
||||||
|
var target_volume = music_default_volume if fade_in else -80.
|
||||||
|
|
||||||
|
if fade_in:
|
||||||
|
music.volume_db = -80.
|
||||||
|
music.play()
|
||||||
|
|
||||||
|
fade_tween.tween_property(music, "volume_db", target_volume, fade_time)
|
||||||
|
|
||||||
|
if not fade_in:
|
||||||
|
fade_tween.finished.connect(
|
||||||
|
func():
|
||||||
|
music.stop()
|
||||||
|
music.volume_db = music_default_volume
|
||||||
|
)
|
||||||
|
return fade_tween
|
||||||
1
common/music/scripts/music.gd.uid
Normal file
1
common/music/scripts/music.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://2p5d6vogtn82
|
||||||
@ -111,11 +111,11 @@ pitch_scale = 1.5
|
|||||||
|
|
||||||
[node name="AudioStreamPlayer_pick_up" type="AudioStreamPlayer" parent="Audio"]
|
[node name="AudioStreamPlayer_pick_up" type="AudioStreamPlayer" parent="Audio"]
|
||||||
stream = SubResource("AudioStreamRandomizer_24ehl")
|
stream = SubResource("AudioStreamRandomizer_24ehl")
|
||||||
volume_db = -15.0
|
volume_db = -25.0
|
||||||
|
|
||||||
[node name="AudioStreamPlayer_movement" type="AudioStreamPlayer" parent="Audio"]
|
[node name="AudioStreamPlayer_movement" type="AudioStreamPlayer" parent="Audio"]
|
||||||
stream = SubResource("AudioStreamRandomizer_bwdx1")
|
stream = SubResource("AudioStreamRandomizer_bwdx1")
|
||||||
volume_db = -20.0
|
volume_db = -80.0
|
||||||
|
|
||||||
[node name="AudioStreamPlayer_drop" type="AudioStreamPlayer" parent="Audio"]
|
[node name="AudioStreamPlayer_drop" type="AudioStreamPlayer" parent="Audio"]
|
||||||
stream = SubResource("AudioStreamRandomizer_yqrof")
|
stream = SubResource("AudioStreamRandomizer_yqrof")
|
||||||
|
|||||||
BIN
stages/terrain/planet/assets/sounds/alarm.wav
Normal file
BIN
stages/terrain/planet/assets/sounds/alarm.wav
Normal file
Binary file not shown.
24
stages/terrain/planet/assets/sounds/alarm.wav.import
Normal file
24
stages/terrain/planet/assets/sounds/alarm.wav.import
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://6bud8chekm8v"
|
||||||
|
path="res://.godot/imported/alarm.wav-4982454a388199bced4344e009ba7c4b.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://stages/terrain/planet/assets/sounds/alarm.wav"
|
||||||
|
dest_files=["res://.godot/imported/alarm.wav-4982454a388199bced4344e009ba7c4b.sample"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
Loading…
Reference in New Issue
Block a user