Chest + Door Functionality
This commit is contained in:
@@ -4,7 +4,9 @@ onready var SNOWBALL_BLUE_SCENE = preload("res://Enemies/Snowball Blue.tscn")
|
||||
|
||||
var player = null
|
||||
var move = Vector2.ZERO
|
||||
var speed = 1
|
||||
var speed = .5
|
||||
var health: int = 2
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move = Vector2.ZERO
|
||||
@@ -50,3 +52,13 @@ func _on_player_detector_area_entered(area: Area2D) -> void:
|
||||
func _on_player_detector_area_exited(_area: Area2D):
|
||||
player = null
|
||||
return
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
|
||||
if health <= 0:
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
|
@@ -40,7 +40,6 @@ autostart = true
|
||||
[node name="hitbox" type="Area2D" parent="." groups=[
|
||||
"enemy_hitbox_1",
|
||||
]]
|
||||
visible = false
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
|
||||
|
@@ -5,6 +5,8 @@ onready var SNOWBALL_SCENE = preload("res://Enemies/Snowball.tscn")
|
||||
var player = null
|
||||
var move = Vector2.ZERO
|
||||
var speed = .5
|
||||
var health: int = 2
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move = Vector2.ZERO
|
||||
@@ -51,3 +53,14 @@ func _on_player_detector_area_entered(area: Area2D) -> void:
|
||||
func _on_player_detector_area_exited(_area: Area2D):
|
||||
player = null
|
||||
return
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
print("HIT")
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
|
||||
if health <= 0:
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
|
@@ -28,12 +28,10 @@ rotation = 1.5708
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="detection" type="Area2D" parent="."]
|
||||
visible = false
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
|
||||
[node name="detection" type="CollisionShape2D" parent="detection"]
|
||||
visible = false
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
|
@@ -1,7 +1,10 @@
|
||||
extends Label
|
||||
|
||||
signal timer_end
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var time_seconds: int = int($Timer.get_time_left())
|
||||
set_text('%02d:%02d' % [time_seconds, int(($Timer.get_time_left() - time_seconds) * 100)])
|
||||
|
||||
if $Timer.get_time_left() == 0:
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
return
|
||||
|
@@ -14,8 +14,8 @@ margin_right = 335.0
|
||||
margin_bottom = 41.0
|
||||
rect_min_size = Vector2( 200, 0 )
|
||||
rect_scale = Vector2( 0.25, 0.25 )
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
align = 1
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
|
@@ -38,10 +38,10 @@ shape = SubResource( 2 )
|
||||
|
||||
[node name="Unlock" type="Area2D" parent="."]
|
||||
light_mask = 0
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
input_pickable = false
|
||||
monitorable = false
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Unlock"]
|
||||
visible = false
|
||||
|
@@ -1,8 +1,8 @@
|
||||
extends Node2D
|
||||
|
||||
onready var coin = preload("res://Levels/Interactives/Coin.tscn")
|
||||
onready var coin_container = get_node("/coin_container")
|
||||
|
||||
onready var coin_container = get_node("coin_container")
|
||||
onready var score_label = get_node('Level 3 HUD/Label')
|
||||
#have event for timer to run out
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ var score = 0
|
||||
func _ready() -> void:
|
||||
$YSort/Player.load_hud($HUD)
|
||||
screensize = get_viewport_rect().size
|
||||
spawn_coins(5)
|
||||
spawn_coins(8)
|
||||
return
|
||||
|
||||
|
||||
@@ -27,3 +27,26 @@ func spawn_coins(num):
|
||||
func _on_coin_grabbed():
|
||||
score+=1
|
||||
print(score)
|
||||
score_label.set_text(str(score) + "/5")
|
||||
|
||||
func _timer_out():
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
|
||||
|
||||
func _on_TreasureChest_ice_key_collected() -> void:
|
||||
$YSort/Door/doorClosed.visible = false
|
||||
$YSort/Door/doorOpened.visible = true
|
||||
$YSort/DoorCollision.layers = 5
|
||||
|
||||
|
||||
|
||||
func _on_DoorDetector_body_entered(body: Node) -> void:
|
||||
if body.get_parent().name == 'Player':
|
||||
print('WIN WIN WIN')
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
|
||||
|
||||
func _on_DoorDetector_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
print('WIN WIN WIN')
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn') # Replace with function body.
|
||||
|
File diff suppressed because one or more lines are too long
16
Levels/Objects/IceDoor.gd
Normal file
16
Levels/Objects/IceDoor.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
extends Sprite
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
21
Levels/Objects/IceDoor.tscn
Normal file
21
Levels/Objects/IceDoor.tscn
Normal file
@@ -0,0 +1,21 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Sprites/Levels/Objects/DoorOpen.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Sprites/Levels/Objects/DoorClosed.png" type="Texture" id=2]
|
||||
|
||||
[node name="IceDoor" type="Sprite"]
|
||||
|
||||
[node name="doorClosed" type="Sprite" parent="."]
|
||||
modulate = Color( 0.00392157, 0.905882, 1, 1 )
|
||||
self_modulate = Color( 0.0352941, 0.705882, 1, 1 )
|
||||
position = Vector2( 0.530327, 0.0883861 )
|
||||
scale = Vector2( 0.742002, 0.706551 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="doorOpened" type="Sprite" parent="."]
|
||||
visible = false
|
||||
modulate = Color( 0.00392157, 0.905882, 1, 1 )
|
||||
self_modulate = Color( 0.0352941, 0.705882, 1, 1 )
|
||||
position = Vector2( 0.353549, 0.97227 )
|
||||
scale = Vector2( 0.732446, 0.669794 )
|
||||
texture = ExtResource( 1 )
|
24
Levels/Objects/Key.gd
Normal file
24
Levels/Objects/Key.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
||||
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name: String) -> void:
|
||||
$IceKeySprite.visible = false
|
||||
|
||||
|
||||
func _on_AnimationPlayer_animation_started(anim_name: String) -> void:
|
||||
$IceKeySprite.visible = true
|
21
Levels/Objects/Key.tscn
Normal file
21
Levels/Objects/Key.tscn
Normal file
@@ -0,0 +1,21 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Levels/Objects/icekey.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Levels/Objects/Gem.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "rise"
|
||||
length = 1.2
|
||||
|
||||
[node name="Key" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="IceKeySprite" type="Sprite" parent="."]
|
||||
position = Vector2( -0.0417144, 0.145997 )
|
||||
scale = Vector2( 0.760146, 0.732771 )
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/rise = SubResource( 1 )
|
||||
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
|
34
Levels/Objects/TreasureChest_L3.gd
Normal file
34
Levels/Objects/TreasureChest_L3.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends Sprite
|
||||
|
||||
var is_player_inside: bool = false
|
||||
var is_opened: bool = false
|
||||
var has_key: bool = true
|
||||
|
||||
signal ice_key_collected
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
||||
|
||||
|
||||
func _on_Player_Detector_area_entered(area: Area2D) -> void:
|
||||
print(get_parent().get_parent().score)
|
||||
if area.get_parent().name == 'Player' and get_parent().get_parent().score >= 5:
|
||||
if is_opened == false:
|
||||
$chestClosed.visible = false
|
||||
$chestOpened.visible = true
|
||||
$Key.visible = true
|
||||
$Key/AnimationPlayer.play("rise")
|
||||
is_opened = true
|
||||
has_key = false
|
||||
emit_signal("ice_key_collected")
|
40
Levels/Objects/TreasureChest_L3.tscn
Normal file
40
Levels/Objects/TreasureChest_L3.tscn
Normal file
@@ -0,0 +1,40 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://Levels/Objects/TreasureChest.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Levels/Objects/Key.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Sprites/Levels/Interactables/treasureChest.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Sprites/Levels/Interactables/treasureChestOpen.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Levels/Objects/Key.gd" type="Script" id=5]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 21.3333, 17.3333 )
|
||||
|
||||
[node name="TreasureChest" type="Sprite" groups=[
|
||||
"enemies",
|
||||
]]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="chestOpened" type="Sprite" parent="."]
|
||||
visible = false
|
||||
texture = ExtResource( 4 )
|
||||
|
||||
[node name="chestClosed" type="Sprite" parent="."]
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="Key" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="Player Detector" type="Area2D" parent="."]
|
||||
input_pickable = false
|
||||
monitorable = false
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player Detector"]
|
||||
visible = false
|
||||
position = Vector2( 1, -1 )
|
||||
scale = Vector2( 1.5, 1.5 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[connection signal="area_entered" from="Player Detector" to="." method="_on_Player_Detector_area_entered"]
|
BIN
Levels/Objects/icekey.png
Normal file
BIN
Levels/Objects/icekey.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 285 B |
34
Levels/Objects/icekey.png.import
Normal file
34
Levels/Objects/icekey.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icekey.png-527d7dd5cd660f0970e78efce0eda1a1.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Levels/Objects/icekey.png"
|
||||
dest_files=[ "res://.import/icekey.png-527d7dd5cd660f0970e78efce0eda1a1.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
Sprites/Levels/Interactables/icekey.png
Normal file
BIN
Sprites/Levels/Interactables/icekey.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 285 B |
34
Sprites/Levels/Interactables/icekey.png.import
Normal file
34
Sprites/Levels/Interactables/icekey.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icekey.png-df1cf56280665fb9b333567113ef5539.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/Levels/Interactables/icekey.png"
|
||||
dest_files=[ "res://.import/icekey.png-df1cf56280665fb9b333567113ef5539.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
Reference in New Issue
Block a user