Exit for Area11 and Area12 template

This commit is contained in:
Sagi Dayan 2020-11-27 23:08:47 -05:00
parent 5d4222b061
commit 61f9c43d81
8 changed files with 159 additions and 10 deletions

View file

@ -744,6 +744,7 @@ wait_time = 0.12
one_shot = true
[node name="DashParticlesLeft" parent="." instance=ExtResource( 3 )]
light_mask = 14
[node name="DashParticlesRight" parent="." instance=ExtResource( 1 )]

View file

@ -4,7 +4,8 @@ extends Node2D
var LIGHTS = {
"DAY": Color(1, 1, 1, 1),
"NIGHT": Color(0.678431, 0.576471, 0.576471),
"AREA1": Color(0.639216, 0.666667, 0.635294)
"AREA1": Color(0.639216, 0.666667, 0.635294),
"AREA2": Color(0.639216, 0.966667, 0.635294)
}
export var _current_light = 'DAY'

View file

@ -8,7 +8,8 @@ var _level_resources := {
"hub" : load("res://src/GameWorld/Levels/WorldHub.tscn"),
"zones": {
1: [
load("res://src/GameWorld/Levels/Area1/Area11.tscn")
load("res://src/GameWorld/Levels/Area1/Area11.tscn"),
load("res://src/GameWorld/Levels/Area1/Area12.tscn")
],
2: [
@ -20,7 +21,7 @@ var _level_resources := {
}
var _levels = [
[_level_resources.pre_game, _level_resources.zones[1][0]],
[_level_resources.pre_game, _level_resources.zones[1][0], _level_resources.zones[1][1]],
]

View file

@ -73,11 +73,11 @@ scale = Vector2( 2, 2 )
texture = ExtResource( 12 )
[node name="Light2D" type="Light2D" parent="BG/Sprite"]
position = Vector2( -31.1, 25.3 )
position = Vector2( -29.425, 25.15 )
texture = ExtResource( 2 )
texture_scale = 5.0
color = Color( 0.227451, 0.419608, 1, 1 )
energy = 1.566
energy = 1.628
range_item_cull_mask = 2048
[node name="AnimationPlayer" type="AnimationPlayer" parent="BG/Sprite"]
@ -146,6 +146,9 @@ position = Vector2( 392, 336 )
position = Vector2( -33, -1 )
is_exit = false
[node name="Exit" parent="." instance=ExtResource( 4 )]
position = Vector2( 857, 177 )
[node name="Enemies" type="Node2D" parent="."]
position = Vector2( 417, 320 )

View file

@ -0,0 +1,8 @@
extends Level
# func ready() -> void:
func _enter_tree() -> void:
AudioManager.play_music(AudioManager.Music.Abandon)
AmbiantLighting.change_light("AREA2")

File diff suppressed because one or more lines are too long

View file

@ -35,6 +35,7 @@ func _ready():
func init_level_config(prev_level_:Vector2, level_coords_:Vector2):
print("Initializing [%s]: prev = %s | current = %s" % [self.name, prev_level_, level_coords_])
_set_warp_enabled(false)
self.prev_level = prev_level_
self.level_coords = level_coords_
self.next_level = Vector2(level_coords.x, level_coords.y + 1)
@ -43,9 +44,11 @@ func init_level_config(prev_level_:Vector2, level_coords_:Vector2):
func _set_active(activated:bool, is_entering:bool):
print("Setting active [%s]: active = %s " % [self.name, activated])
is_active_level = activated
_set_warp_enabled(false)
if activated:
if _first_time_init: _set_wrap_zones()
_set_player_position(is_entering)
_set_warp_enabled(true)
emit_signal("level_ready")
func set_player(player:Player):
@ -53,6 +56,7 @@ func set_player(player:Player):
_player = player
_camera = _player.get_camera()
_set_camera_limits()
print("Level %s, adding player"% [self.name])
add_child(_player)
@ -94,9 +98,9 @@ func _set_wrap_zones():
if not has_custom_level:
if not warp.is_exit: warp.to_level_coord = self.prev_level
else: warp.to_level_coord = self.next_level
print("Warp has no costum level set to: %s" % [warp.to_level_coord])
print("Warp %s has no costum level set to: %s" % [warp.name, warp.to_level_coord])
else:
print("Warp a costum level: %s" % [warp.to_level_coord])
print("Warp %s a costum level: %s" % [warp.name, warp.to_level_coord])
func _on_WarpZone_player_entered(is_exit, to_level_coord) -> void:
print("_on_WarpZone_player_entered is_exit=%s to_level=%s" % [is_exit, to_level_coord])
@ -112,3 +116,9 @@ func _get_all_warps():
warps.push_back(node)
print("_get_all_warps [%s]: #%d of warps found" % [self.name, len(warps)])
return warps
func _set_warp_enabled(enabled:bool):
var warps = _get_all_warps()
for warp in warps:
print("Settings warp ENABLED=%s" % [enabled])
warp.enabled(enabled)

View file

@ -7,6 +7,7 @@ export var to_level_coord:Vector2 = Vector2(-1, -1)
export var is_exit:bool = true
const spawn_offset = 30
var _enabled:bool = false
const NON_SPECIFIED_LEVEL :=Vector2(-1, -1)
@ -14,10 +15,14 @@ const NON_SPECIFIED_LEVEL :=Vector2(-1, -1)
func _on_body_entered(body:Node):
if body.name == "Player" and get_parent().is_active_level:
print("Warp - exit=%s to_level=%s" % [is_exit, to_level_coord])
if _enabled and body.name == "Player" and get_parent().is_active_level:
print("Warp %s in Level %s: exit=%s to_level=%s" % [name, get_parent().name, is_exit, to_level_coord])
_enabled = false
emit_signal("player_entered", is_exit, to_level_coord)
func get_checkpoint_position():
var factor = -1 if is_exit else 1
return position + Vector2(factor * spawn_offset, 0)
return position + Vector2(factor * spawn_offset, 0)
func enabled(enabled:bool):
_enabled = enabled