Fixed debugger errors in many files and optimized some scenes/code
This commit is contained in:
@@ -10,49 +10,49 @@ var counter: int = 0
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
|
||||
|
||||
if hit == true:
|
||||
if counter < 15:
|
||||
if counter % 5 == 0:
|
||||
$AnimatedSprite.visible = false
|
||||
else:
|
||||
$AnimatedSprite.visible = true
|
||||
counter += 1
|
||||
velocity = Vector2.ZERO
|
||||
else:
|
||||
counter = 0
|
||||
hit = false
|
||||
if hit == true:
|
||||
if counter < 15:
|
||||
if counter % 5 == 0:
|
||||
$AnimatedSprite.visible = false
|
||||
else:
|
||||
$AnimatedSprite.visible = true
|
||||
counter += 1
|
||||
velocity = Vector2.ZERO
|
||||
else:
|
||||
counter = 0
|
||||
hit = false
|
||||
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
return
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_exited(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = null
|
||||
return
|
||||
if body.is_in_group('player'):
|
||||
player = null
|
||||
return
|
||||
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
hit = true
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
hit = true
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
hit = true
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
hit = true
|
||||
|
||||
if health <= 0:
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
if health <= 0:
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
|
61
Enemies/Ghost Enemy.gd
Normal file
61
Enemies/Ghost Enemy.gd
Normal file
@@ -0,0 +1,61 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
export var fireball: PackedScene
|
||||
|
||||
var player: KinematicBody2D = null
|
||||
var move: Vector2 = Vector2.ZERO
|
||||
const SPEED: int = 50
|
||||
var counter: int = 0
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
var health: int = 4
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
return
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func _on_Area2D_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
if counter == 0:
|
||||
self.visible = true
|
||||
$AnimatedSprite.play('appear')
|
||||
counter = 1
|
||||
return
|
||||
|
||||
|
||||
func _on_AnimatedSprite_animation_finished() -> void:
|
||||
$AnimatedSprite.play('idle')
|
||||
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:
|
||||
$AnimatedSprite.play('vanish')
|
||||
yield($AnimatedSprite, 'animation_finished')
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
|
||||
|
||||
func _on_Projectile_Timer_timeout() -> void:
|
||||
if player:
|
||||
var projectile: Node = fireball.instance()
|
||||
projectile.init($AnimatedSprite.global_position, player.position)
|
||||
get_tree().get_current_scene().get_node('Projectiles').add_child(projectile)
|
||||
$AnimatedSprite.play('shriek')
|
||||
return
|
@@ -4,7 +4,7 @@
|
||||
[ext_resource path="res://Sprites/Assets/ghost-idle.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Sprites/Assets/ghost-shriek.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Sprites/Assets/ghost-vanish.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Enemies/Ghost_Enemy.gd" type="Script" id=5]
|
||||
[ext_resource path="res://Enemies/Ghost Enemy.gd" type="Script" id=5]
|
||||
[ext_resource path="res://Enemies/Projectiles/Fireball.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_14.png" type="Texture" id=7]
|
||||
|
||||
@@ -36,29 +36,21 @@ region = Rect2( 320, 0, 64, 80 )
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 384, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=8]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 0, 0, 64, 48 )
|
||||
[sub_resource type="AtlasTexture" id=23]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 128, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=9]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 64, 0, 64, 48 )
|
||||
[sub_resource type="AtlasTexture" id=24]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 192, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=10]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 128, 0, 64, 48 )
|
||||
[sub_resource type="AtlasTexture" id=22]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 64, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=11]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 192, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=12]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 256, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=13]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 320, 0, 64, 48 )
|
||||
[sub_resource type="AtlasTexture" id=21]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 0, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=14]
|
||||
atlas = ExtResource( 4 )
|
||||
@@ -88,21 +80,29 @@ region = Rect2( 320, 0, 64, 64 )
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 384, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=23]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 128, 0, 64, 80 )
|
||||
[sub_resource type="AtlasTexture" id=8]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 0, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=24]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 192, 0, 64, 80 )
|
||||
[sub_resource type="AtlasTexture" id=9]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 64, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=22]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 64, 0, 64, 80 )
|
||||
[sub_resource type="AtlasTexture" id=10]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 128, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=21]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 0, 0, 64, 80 )
|
||||
[sub_resource type="AtlasTexture" id=11]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 192, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=12]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 256, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=13]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 320, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=25]
|
||||
animations = [ {
|
||||
@@ -111,9 +111,9 @@ animations = [ {
|
||||
"name": "idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ) ],
|
||||
"frames": [ SubResource( 23 ), SubResource( 24 ), SubResource( 22 ), SubResource( 21 ) ],
|
||||
"loop": true,
|
||||
"name": "appear",
|
||||
"name": "shriek",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ), SubResource( 19 ), SubResource( 20 ) ],
|
||||
@@ -121,9 +121,9 @@ animations = [ {
|
||||
"name": "vanish",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 23 ), SubResource( 24 ), SubResource( 22 ), SubResource( 21 ) ],
|
||||
"frames": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ) ],
|
||||
"loop": true,
|
||||
"name": "shriek",
|
||||
"name": "appear",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
|
||||
@@ -144,10 +144,10 @@ orbit_velocity_random = 0.0
|
||||
color = Color( 0.729412, 0, 0, 1 )
|
||||
hue_variation = 1.0
|
||||
|
||||
[node name="KinematicBody2D" type="KinematicBody2D"]
|
||||
[node name="Ghost Enemy" type="KinematicBody2D"]
|
||||
z_index = 2
|
||||
script = ExtResource( 5 )
|
||||
Fireball = ExtResource( 6 )
|
||||
fireball = ExtResource( 6 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
frames = SubResource( 25 )
|
||||
@@ -165,9 +165,7 @@ shape = SubResource( 26 )
|
||||
position = Vector2( 0.530334, 11.3032 )
|
||||
shape = SubResource( 27 )
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="." groups=[
|
||||
"enemy_hitbox_1",
|
||||
]]
|
||||
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox_1"]]
|
||||
light_mask = 0
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
@@ -1,61 +0,0 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
export var Fireball: PackedScene
|
||||
onready var player = null
|
||||
var move = Vector2.ZERO
|
||||
var SPEED = 50
|
||||
var counter = 0
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
var health: int = 4
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
self.visible = false
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
velocity = move_and_slide(velocity)
|
||||
|
||||
|
||||
|
||||
func _on_Area2D_body_entered(body):
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
if counter == 0:
|
||||
self.visible = true
|
||||
$AnimatedSprite.play("appear")
|
||||
counter = 1
|
||||
|
||||
|
||||
|
||||
func _on_AnimatedSprite_animation_finished():
|
||||
$AnimatedSprite.play("idle")
|
||||
|
||||
|
||||
func _on_Hitbox_area_entered(area):
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
if health <= 0:
|
||||
$AnimatedSprite.play("vanish")
|
||||
yield($AnimatedSprite, "animation_finished")
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
|
||||
|
||||
func _on_Projectile_Timer_timeout():
|
||||
if player:
|
||||
var projectile: Node = Fireball.instance()
|
||||
projectile.init($AnimatedSprite.global_position, player.position)
|
||||
get_tree().get_current_scene().get_node('Projectiles').add_child(projectile)
|
||||
$AnimatedSprite.play("shriek")
|
@@ -10,65 +10,65 @@ var counter: int = 0
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
var angle = position.angle_to_point(player.position)
|
||||
if abs(angle) > PI/2:
|
||||
$AnimatedSprite1.scale.x = -0.563
|
||||
else:
|
||||
$AnimatedSprite1.scale.x = 0.563
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
var angle = position.angle_to_point(player.position)
|
||||
if abs(angle) > PI/2:
|
||||
$AnimatedSprite1.scale.x = -0.563
|
||||
else:
|
||||
$AnimatedSprite1.scale.x = 0.563
|
||||
|
||||
if hit == true:
|
||||
if counter < 15:
|
||||
if counter % 5 == 0:
|
||||
$AnimatedSprite1.visible = false
|
||||
else:
|
||||
$AnimatedSprite1.visible = true
|
||||
counter += 1
|
||||
velocity = Vector2.ZERO
|
||||
else:
|
||||
counter = 0
|
||||
hit = false
|
||||
if hit == true:
|
||||
if counter < 15:
|
||||
if counter % 5 == 0:
|
||||
$AnimatedSprite1.visible = false
|
||||
else:
|
||||
$AnimatedSprite1.visible = true
|
||||
counter += 1
|
||||
velocity = Vector2.ZERO
|
||||
else:
|
||||
counter = 0
|
||||
hit = false
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Running'
|
||||
return
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Running'
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_exited(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = null
|
||||
$AnimatedSprite1.animation = 'Idle'
|
||||
return
|
||||
if body.is_in_group('player'):
|
||||
player = null
|
||||
$AnimatedSprite1.animation = 'Idle'
|
||||
return
|
||||
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
hit = true
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
hit = true
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
hit = true
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
hit = true
|
||||
|
||||
if health <= 0:
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
if health <= 0:
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
|
||||
func _on_Player_Detector__Attack_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Jump'
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Jump'
|
||||
|
||||
|
||||
func _on_Player_Detector__Attack_body_exited(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Running'
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Running'
|
||||
|
@@ -1,47 +1,49 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
onready var SNOWBALL_BLUE_SCENE = preload("res://Enemies/Snowball Blue.tscn")
|
||||
onready var SNOWBALL_BLUE_SCENE: Resource = preload('res://Enemies/Snowball Blue.tscn')
|
||||
|
||||
var player = null
|
||||
var move = Vector2.ZERO
|
||||
var speed = .5
|
||||
var player: KinematicBody2D = null
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
const SPEED: int = 50
|
||||
var health: int = 2
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move = Vector2.ZERO
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player != null:
|
||||
move = position.direction_to(player.position) * speed
|
||||
else:
|
||||
move = Vector2.ZERO
|
||||
|
||||
move = move.normalized()
|
||||
move = move_and_collide(move)
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func _on_Area2D_body_entered(body: Node) -> void:
|
||||
if body != self && !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
|
||||
player = body
|
||||
return
|
||||
|
||||
|
||||
func _on_Area2D_body_exited(body: Node) -> void:
|
||||
if !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
|
||||
player = null
|
||||
return
|
||||
|
||||
|
||||
func fire():
|
||||
func fire() -> void:
|
||||
var snowball = SNOWBALL_BLUE_SCENE.instance()
|
||||
snowball.position = get_global_position()
|
||||
snowball.player = player
|
||||
get_parent().add_child(snowball)
|
||||
$Timer.set_wait_time(1)
|
||||
return
|
||||
|
||||
|
||||
func _on_Timer_timeout() -> void:
|
||||
if player != null:
|
||||
fire()
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
@@ -49,10 +51,11 @@ func _on_player_detector_area_entered(area: Area2D) -> void:
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_area_exited(_area: Area2D):
|
||||
func _on_player_detector_area_exited(_area: Area2D) -> void:
|
||||
player = null
|
||||
return
|
||||
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
|
@@ -1,47 +1,48 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
onready var SNOWBALL_SCENE = preload("res://Enemies/Snowball.tscn")
|
||||
onready var SNOWBALL_SCENE: Resource = preload('res://Enemies/Snowball.tscn')
|
||||
|
||||
var player = null
|
||||
var move = Vector2.ZERO
|
||||
var speed = .5
|
||||
var player: KinematicBody2D = null
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
const SPEED: int = 50
|
||||
var health: int = 2
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move = Vector2.ZERO
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player != null:
|
||||
move = position.direction_to(player.position) * speed
|
||||
else:
|
||||
move = Vector2.ZERO
|
||||
|
||||
move = move.normalized()
|
||||
move = move_and_collide(move)
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func _on_Area2D_body_entered(body: Node) -> void:
|
||||
if body != self && !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
|
||||
player = body
|
||||
return
|
||||
|
||||
|
||||
func _on_Area2D_body_exited(body: Node) -> void:
|
||||
if !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
|
||||
player = null
|
||||
return
|
||||
|
||||
|
||||
func fire():
|
||||
func fire() -> void:
|
||||
var snowball = SNOWBALL_SCENE.instance()
|
||||
snowball.position = get_global_position()
|
||||
snowball.player = player
|
||||
get_parent().add_child(snowball)
|
||||
$Timer.set_wait_time(1)
|
||||
return
|
||||
|
||||
|
||||
func _on_Timer_timeout() -> void:
|
||||
if player != null:
|
||||
fire()
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_area_entered(area: Area2D) -> void:
|
||||
@@ -50,12 +51,12 @@ func _on_player_detector_area_entered(area: Area2D) -> void:
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_area_exited(_area: Area2D):
|
||||
func _on_player_detector_area_exited(_area: Area2D) -> void:
|
||||
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'):
|
||||
|
@@ -1,6 +1,6 @@
|
||||
extends Label
|
||||
|
||||
signal timer_end
|
||||
signal timer_out
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
@@ -8,5 +8,5 @@ func _process(_delta: float) -> void:
|
||||
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')
|
||||
emit_signal('timer_out')
|
||||
return
|
||||
|
88
GUI/HUD.gd
88
GUI/HUD.gd
@@ -5,76 +5,76 @@ var weapon = "sword"
|
||||
|
||||
|
||||
func _on_Add_Currency_pressed() -> void:
|
||||
emit_signal('add_currency', 1)
|
||||
return
|
||||
emit_signal('add_currency', 1)
|
||||
return
|
||||
|
||||
|
||||
func update_currency(amount: int) -> void:
|
||||
$Currency.set_text(String(amount))
|
||||
return
|
||||
$Currency.set_text(String(amount))
|
||||
return
|
||||
|
||||
|
||||
func update_health(value: int) -> void:
|
||||
$'Health Bar'.value = value
|
||||
return
|
||||
$'Health Bar'.value = value
|
||||
return
|
||||
|
||||
|
||||
func _on_weapon_slot_pressed() -> void:
|
||||
$'Weapon Selection'.set_visible(not $'Weapon Selection'.visible)
|
||||
return
|
||||
$'Weapon Selection'.set_visible(not $'Weapon Selection'.visible)
|
||||
return
|
||||
|
||||
|
||||
func _on_select_bow_pressed() -> void:
|
||||
$'Weapon Selection/Bow'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Bow/Weapon'.get_normal_texture())
|
||||
$'Weapon Selection/Bow'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Bow/Weapon'.get_normal_texture())
|
||||
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "bow"
|
||||
return
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "bow"
|
||||
return
|
||||
|
||||
|
||||
func _on_select_javelin_pressed() -> void:
|
||||
$'Weapon Selection/Javelin'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Javelin/Weapon'.get_normal_texture())
|
||||
$'Weapon Selection/Javelin'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Javelin/Weapon'.get_normal_texture())
|
||||
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "javelin"
|
||||
return
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "javelin"
|
||||
return
|
||||
|
||||
|
||||
func _on_select_staff_pressed() -> void:
|
||||
$'Weapon Selection/Staff'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Staff/Weapon'.get_normal_texture())
|
||||
$'Weapon Selection/Staff'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Staff/Weapon'.get_normal_texture())
|
||||
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "staff"
|
||||
return
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "staff"
|
||||
return
|
||||
|
||||
|
||||
func _on_select_sword_pressed() -> void:
|
||||
$'Weapon Selection/Sword'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Sword/Weapon'.get_normal_texture())
|
||||
$'Weapon Selection/Sword'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Sword/Weapon'.get_normal_texture())
|
||||
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "sword"
|
||||
return
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "sword"
|
||||
return
|
||||
|
@@ -4,7 +4,7 @@ export var hub_world_path: String = 'res://Levels/Hub World.tscn'
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if get_tree().change_scene(hub_world_path) != OK:
|
||||
print('ERROR: Level Ending failed to change scene to Hub World.')
|
||||
queue_free()
|
||||
return
|
||||
if get_tree().change_scene(hub_world_path) != OK:
|
||||
print('ERROR: Level Ending failed to change scene to Hub World.')
|
||||
queue_free()
|
||||
return
|
||||
|
@@ -4,36 +4,36 @@ signal complete(option)
|
||||
|
||||
|
||||
func _on_new_game_button_pressed() -> void:
|
||||
emit_signal('complete', 'new game')
|
||||
return
|
||||
emit_signal('complete', 'new game')
|
||||
return
|
||||
|
||||
|
||||
func _on_quit_button_pressed() -> void:
|
||||
get_tree().quit()
|
||||
return
|
||||
get_tree().quit()
|
||||
return
|
||||
|
||||
|
||||
func _on_continue_button_mouse_entered() -> void:
|
||||
if not $'Menu/Menu Elements/Menu Options/Continue/Continue Button'.disabled:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
if not $'Menu/Menu Elements/Menu Options/Continue/Continue Button'.disabled:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
|
||||
|
||||
func _on_new_game_button_mouse_entered() -> void:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
|
||||
|
||||
func _on_settings_button_mouse_entered() -> void:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
|
||||
|
||||
func _on_credits_button_mouse_entered() -> void:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
|
||||
|
||||
func _on_quit_button_mouse_entered() -> void:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
|
@@ -4,26 +4,26 @@ signal complete
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Fade in
|
||||
if not $Tween.interpolate_property(self, 'self_modulate:a', 0, 1, 3, Tween.TRANS_LINEAR, Tween.EASE_IN):
|
||||
print('ERROR: Splash Screen fade in animation has errors.')
|
||||
if not $Tween.start():
|
||||
print('ERROR: Splash Screen fade in animation failed to start.')
|
||||
# Fade in
|
||||
if not $Tween.interpolate_property(self, 'self_modulate:a', 0, 1, 3, Tween.TRANS_LINEAR, Tween.EASE_IN):
|
||||
print('ERROR: Splash Screen fade in animation has errors.')
|
||||
if not $Tween.start():
|
||||
print('ERROR: Splash Screen fade in animation failed to start.')
|
||||
|
||||
yield($Tween, 'tween_completed') # Wait for fade in to complete
|
||||
yield($Tween, 'tween_completed') # Wait for fade in to complete
|
||||
|
||||
# Fade out
|
||||
if not $Tween.interpolate_property(self, 'self_modulate:a', 1, 0, 3, Tween.TRANS_LINEAR, Tween.EASE_OUT, 2):
|
||||
print('ERROR: Splash Screen fade out animation has errors.')
|
||||
if not $Tween.start():
|
||||
print('ERROR: Splash Screen fade out animation failed to start.')
|
||||
# Fade out
|
||||
if not $Tween.interpolate_property(self, 'self_modulate:a', 1, 0, 3, Tween.TRANS_LINEAR, Tween.EASE_OUT, 2):
|
||||
print('ERROR: Splash Screen fade out animation has errors.')
|
||||
if not $Tween.start():
|
||||
print('ERROR: Splash Screen fade out animation failed to start.')
|
||||
|
||||
yield($Tween, 'tween_completed') # Wait for fade out to complete
|
||||
emit_signal('complete')
|
||||
return
|
||||
yield($Tween, 'tween_completed') # Wait for fade out to complete
|
||||
emit_signal('complete')
|
||||
return
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed('ui_accept'):
|
||||
emit_signal('complete')
|
||||
return
|
||||
if event.is_action_pressed('ui_accept'):
|
||||
emit_signal('complete')
|
||||
return
|
||||
|
@@ -1,21 +0,0 @@
|
||||
extends Area2D
|
||||
|
||||
onready var portal = get_node("../PortalDarkForest")
|
||||
onready var shape = portal.get_child(0)
|
||||
# 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:
|
||||
shape.set_deferred("disabled",true)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
||||
|
||||
|
||||
func _on_ChestDetection_body_entered(body: Node) -> void:
|
||||
shape.set_deferred("disabled",false)
|
@@ -1,29 +1,13 @@
|
||||
extends Camera2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
|
||||
signal enter_portal
|
||||
|
||||
|
||||
# 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_PortalDarkForest_body_entered(body: Node) -> void:
|
||||
self.limit_bottom = -224
|
||||
self.limit_top = -736
|
||||
self.limit_left = -32
|
||||
self.limit_right = 448
|
||||
var player = get_parent()
|
||||
player.position = Vector2(256,-232)
|
||||
emit_signal('enter_portal')
|
||||
|
||||
func _on_PortalDarkForest_body_entered(_body: Node) -> void:
|
||||
limit_bottom = -224
|
||||
limit_top = -736
|
||||
limit_left = -32
|
||||
limit_right = 448
|
||||
get_parent().position = Vector2(256, -232)
|
||||
emit_signal('enter_portal')
|
||||
return
|
||||
|
15
Levels/Chest Detection.gd
Normal file
15
Levels/Chest Detection.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
extends Area2D
|
||||
|
||||
onready var portal = get_node('../PortalDarkForest')
|
||||
onready var shape = portal.get_child(0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
shape.set_deferred('disabled', true)
|
||||
return
|
||||
|
||||
|
||||
func _on_chest_detection_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
shape.set_deferred('disabled', false)
|
||||
return
|
@@ -2,16 +2,16 @@ extends Node2D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$YSort/Player.load_hud($HUD)
|
||||
$YSort/Player.load_hud($HUD)
|
||||
|
||||
for level_portal in $'YSort/Level Portals'.get_children():
|
||||
if level_portal.connect('enter_level', self, 'enter_level') != OK:
|
||||
print('ERROR: Level Portal "enter_level" signal already connected.')
|
||||
return
|
||||
for level_portal in $'YSort/Level Portals'.get_children():
|
||||
if level_portal.connect('enter_level', self, 'enter_level') != OK:
|
||||
print('ERROR: Level Portal "enter_level" signal already connected.')
|
||||
return
|
||||
|
||||
|
||||
func enter_level(level: String) -> void:
|
||||
if get_tree().change_scene(level) != OK:
|
||||
print('ERROR: Hub World failed to change scene to Level.')
|
||||
queue_free()
|
||||
return
|
||||
if get_tree().change_scene(level) != OK:
|
||||
print('ERROR: Hub World failed to change scene to Level.')
|
||||
queue_free()
|
||||
return
|
||||
|
@@ -3,8 +3,8 @@ extends Area2D
|
||||
signal coin_grabbed
|
||||
|
||||
|
||||
func _on_Node2D_body_entered(body: Node) -> void:
|
||||
if body.get_name() == 'Player':
|
||||
emit_signal("coin_grabbed")
|
||||
print("coin!")
|
||||
queue_free()
|
||||
func _on_coin_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
emit_signal('coin_grabbed')
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
|
@@ -6,7 +6,7 @@
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 6.38067
|
||||
|
||||
[node name="coin" type="Area2D"]
|
||||
[node name="Coin" type="Area2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
@@ -16,4 +16,4 @@ texture = ExtResource( 2 )
|
||||
[node name="coin" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_Node2D_body_entered"]
|
||||
[connection signal="body_entered" from="." to="." method="_on_coin_body_entered"]
|
||||
|
@@ -1,24 +1,11 @@
|
||||
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:
|
||||
func _on_AnimationPlayer_animation_finished(_anim_name: String) -> void:
|
||||
$GemSprite.visible = false
|
||||
return
|
||||
|
||||
|
||||
func _on_AnimationPlayer_animation_started(anim_name: String) -> void:
|
||||
func _on_AnimationPlayer_animation_started(_anim_name: String) -> void:
|
||||
$GemSprite.visible = true
|
||||
return
|
||||
|
@@ -4,14 +4,14 @@ var death_count: int = 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
|
||||
|
||||
func _on_dark_matter_death() -> void:
|
||||
death_count += 1
|
||||
if death_count == 5:
|
||||
if get_tree().change_scene('res://GUI/Level Complete.tscn') != OK:
|
||||
print('ERROR: Level 1 failed to change scene to Level Complete.')
|
||||
queue_free()
|
||||
return
|
||||
death_count += 1
|
||||
if death_count == 5:
|
||||
if get_tree().change_scene('res://GUI/Level Complete.tscn') != OK:
|
||||
print('ERROR: Level 1 failed to change scene to Level Complete.')
|
||||
queue_free()
|
||||
return
|
||||
|
@@ -1,18 +1,18 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
#$YSort/Player.position = get_viewport_rect().size / 2
|
||||
$YSort/Player.position = Vector2(0,0)
|
||||
$YSort/Player.load_hud($HUD)
|
||||
$HUD/Control.visible = false
|
||||
return
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
|
||||
|
||||
func _on_Area2D_body_entered(body):
|
||||
$HUD/Control.visible = true
|
||||
#print("j")
|
||||
func _on_journal_page_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
$'HUD/Journal Page Dialogue'.visible = true
|
||||
return
|
||||
|
||||
|
||||
func _on_Camera2D_enter_portal() -> void:
|
||||
$BGM1.stop()
|
||||
$BGM2.play()
|
||||
$BGM1.stop()
|
||||
$BGM2.play()
|
||||
return
|
||||
|
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=90 format=2]
|
||||
[gd_scene load_steps=91 format=2]
|
||||
|
||||
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Levels/Level 2.gd" type="Script" id=2]
|
||||
@@ -8,10 +8,10 @@
|
||||
[ext_resource path="res://Levels/Objects/Chest.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://Sprites/Assets/cliffTileset.png" type="Texture" id=7]
|
||||
[ext_resource path="res://GUI/HUD.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://Enemies/Ghost_Enemy.tscn" type="PackedScene" id=9]
|
||||
[ext_resource path="res://Enemies/Ghost Enemy.tscn" type="PackedScene" id=9]
|
||||
[ext_resource path="res://Sprites/Assets/DeadTree.png" type="Texture" id=10]
|
||||
[ext_resource path="res://Sprites/Assets/darkForestTileset.png" type="Texture" id=11]
|
||||
[ext_resource path="res://Levels/Area2D.gd" type="Script" id=12]
|
||||
[ext_resource path="res://Levels/Chest Detection.gd" type="Script" id=12]
|
||||
[ext_resource path="res://Levels/Camera2D.gd" type="Script" id=13]
|
||||
[ext_resource path="res://Sprites/Assets/Shadow.png" type="Texture" id=14]
|
||||
[ext_resource path="res://Levels/Traps/Spawn Trap.tscn" type="PackedScene" id=15]
|
||||
@@ -21,6 +21,7 @@
|
||||
[ext_resource path="res://Levels/Objects/Dialogue.tscn" type="PackedScene" id=19]
|
||||
[ext_resource path="res://Music/Level_2_2.mp3" type="AudioStream" id=20]
|
||||
[ext_resource path="res://Music/Level_2_1.mp3" type="AudioStream" id=21]
|
||||
[ext_resource path="res://Levels/Portal Dark Forest.gd" type="Script" id=22]
|
||||
|
||||
[sub_resource type="TileSet" id=1]
|
||||
0/name = "darkForestTileset.png 0"
|
||||
@@ -797,11 +798,6 @@ radius = 22.8792
|
||||
[node name="World" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="HUD" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
[node name="Control" parent="HUD" instance=ExtResource( 19 )]
|
||||
visible = false
|
||||
|
||||
[node name="YSort" type="YSort" parent="."]
|
||||
|
||||
[node name="Player" parent="YSort" instance=ExtResource( 1 )]
|
||||
@@ -897,32 +893,31 @@ position = Vector2( 350, 0 )
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
z_index = 4
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="Collectible"]
|
||||
[node name="Journal Page" type="Area2D" parent="Collectible"]
|
||||
collision_layer = 3
|
||||
collision_mask = 3
|
||||
|
||||
[node name="Sprite2" type="Sprite" parent="Collectible/Area2D"]
|
||||
[node name="Sprite" type="Sprite" parent="Collectible/Journal Page"]
|
||||
texture = ExtResource( 18 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Collectible/Area2D"]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Collectible/Journal Page"]
|
||||
shape = SubResource( 68 )
|
||||
|
||||
[node name="Pause Screen" parent="." instance=ExtResource( 5 )]
|
||||
|
||||
[node name="TreasureChest" parent="." instance=ExtResource( 6 )]
|
||||
position = Vector2( 54, 170 )
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
object_scene = ExtResource( 6 )
|
||||
|
||||
[node name="ChestDetection" type="Area2D" parent="TreasureChest"]
|
||||
[node name="Chest Detection" type="Area2D" parent="TreasureChest"]
|
||||
script = ExtResource( 12 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TreasureChest/ChestDetection"]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TreasureChest/Chest Detection"]
|
||||
position = Vector2( -1.78381, -1.75043 )
|
||||
scale = Vector2( 3.08, 1.96 )
|
||||
shape = SubResource( 65 )
|
||||
|
||||
[node name="PortalDarkForest" type="Area2D" parent="TreasureChest"]
|
||||
script = ExtResource( 22 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TreasureChest/PortalDarkForest"]
|
||||
position = Vector2( 402.642, -712.75 )
|
||||
@@ -934,6 +929,7 @@ shape = SubResource( 66 )
|
||||
|
||||
[node name="Spawn Trap" parent="Traps" instance=ExtResource( 15 )]
|
||||
position = Vector2( 296.416, -364.541 )
|
||||
enemy_path = "res://Enemies/Ghost Enemy.tscn"
|
||||
|
||||
[node name="Skull" type="TileMap" parent="."]
|
||||
modulate = Color( 0.658824, 0.658824, 0.658824, 1 )
|
||||
@@ -942,6 +938,13 @@ tile_set = SubResource( 67 )
|
||||
format = 1
|
||||
tile_data = PoolIntArray( -589828, 0, 0, -458754, 0, 0, -393220, 0, 0 )
|
||||
|
||||
[node name="HUD" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
[node name="Journal Page Dialogue" parent="HUD" instance=ExtResource( 19 )]
|
||||
visible = false
|
||||
|
||||
[node name="Pause Screen" parent="." instance=ExtResource( 5 )]
|
||||
|
||||
[node name="BGM1" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 21 )
|
||||
volume_db = -10.0
|
||||
@@ -952,6 +955,6 @@ stream = ExtResource( 20 )
|
||||
volume_db = -10.0
|
||||
|
||||
[connection signal="enter_portal" from="YSort/Player/Camera2D" to="." method="_on_Camera2D_enter_portal"]
|
||||
[connection signal="body_entered" from="Collectible/Area2D" to="." method="_on_Area2D_body_entered"]
|
||||
[connection signal="body_entered" from="TreasureChest/ChestDetection" to="TreasureChest/ChestDetection" method="_on_ChestDetection_body_entered"]
|
||||
[connection signal="body_entered" from="Collectible/Journal Page" to="." method="_on_journal_page_body_entered"]
|
||||
[connection signal="body_entered" from="TreasureChest/Chest Detection" to="TreasureChest/Chest Detection" method="_on_chest_detection_body_entered"]
|
||||
[connection signal="body_entered" from="TreasureChest/PortalDarkForest" to="YSort/Player/Camera2D" method="_on_PortalDarkForest_body_entered"]
|
||||
|
@@ -1,57 +1,52 @@
|
||||
extends Node2D
|
||||
|
||||
onready var coin = preload('res://Levels/Interactables/Coin.tscn')
|
||||
onready var coin: Resource = preload('res://Levels/Interactables/Coin.tscn')
|
||||
|
||||
var screensize
|
||||
var score = 0
|
||||
var screensize: Vector2
|
||||
var score: int = 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$YSort/Player.load_hud($HUD)
|
||||
screensize = get_viewport_rect().size
|
||||
spawn_coins(8)
|
||||
return
|
||||
$YSort/Player.load_hud($HUD)
|
||||
screensize = get_viewport_rect().size
|
||||
spawn_coins(8)
|
||||
return
|
||||
|
||||
|
||||
func spawn_coins(num: int) -> void:
|
||||
for _i in range(num):
|
||||
var g: Node = coin.instance()
|
||||
$'coin_container'.add_child(g)
|
||||
g.connect('coin_grabbed', self, '_on_coin_grabbed')
|
||||
#g.set_pos(Vector2(rand_range(0, screensize.x - 40), rand_range(0, screensize.y - 40)))
|
||||
g.position = Vector2(rand_range(0, screensize.x - 40), rand_range(0, screensize.y - 40))
|
||||
return
|
||||
for _i in range(num):
|
||||
var g: Node = coin.instance()
|
||||
$'coin_container'.add_child(g)
|
||||
if g.connect('coin_grabbed', self, '_on_coin_grabbed') != OK:
|
||||
print('ERROR: Coin "coin_grabbed" signal already connected.')
|
||||
#g.set_pos(Vector2(rand_range(0, screensize.x - 40), rand_range(0, screensize.y - 40)))
|
||||
g.position = Vector2(rand_range(0, screensize.x - 40), rand_range(0, screensize.y - 40))
|
||||
return
|
||||
|
||||
|
||||
func _on_coin_grabbed() -> void:
|
||||
score += 1
|
||||
print(score)
|
||||
$'Level 3 HUD/Label'.set_text(str(score) + '/5')
|
||||
return
|
||||
score += 1
|
||||
$'Level 3 HUD/Label'.set_text(str(score) + '/5')
|
||||
return
|
||||
|
||||
|
||||
func _timer_out() -> void:
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
queue_free()
|
||||
return
|
||||
if get_tree().change_scene('res://GUI/Level Failed.tscn') != OK:
|
||||
print('ERROR: Level 3 failed to change scene to Level Failed.')
|
||||
queue_free()
|
||||
return
|
||||
|
||||
|
||||
func _on_TreasureChest_ice_key_collected() -> void:
|
||||
$YSort/Door/doorClosed.visible = false
|
||||
$YSort/Door/doorOpened.visible = true
|
||||
$YSort/DoorCollision.layers = 5
|
||||
return
|
||||
|
||||
|
||||
func _on_DoorDetector_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
print('WIN WIN WIN')
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
return
|
||||
$YSort/Door/doorClosed.visible = false
|
||||
$YSort/Door/doorOpened.visible = true
|
||||
$YSort/DoorCollision.layers = 5
|
||||
return
|
||||
|
||||
|
||||
func _on_DoorDetector_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
get_tree().change_scene('res://GUI/Level Complete.tscn')
|
||||
queue_free()
|
||||
return
|
||||
if area.get_parent().name == 'Player':
|
||||
if get_tree().change_scene('res://GUI/Level Complete.tscn') != OK:
|
||||
print('ERROR: Level 3 failed to change scene to Level Complete.')
|
||||
queue_free()
|
||||
return
|
||||
|
@@ -127,31 +127,23 @@ position = Vector2( 250.562, 86.6365 )
|
||||
|
||||
[node name="Enemies" type="YSort" parent="YSort"]
|
||||
|
||||
[node name="Snowman 1" parent="YSort/Enemies" groups=[
|
||||
"enemies",
|
||||
] instance=ExtResource( 4 )]
|
||||
[node name="Snowman 1" parent="YSort/Enemies" groups=["enemies"] instance=ExtResource( 4 )]
|
||||
position = Vector2( 268.977, 221.859 )
|
||||
collision_layer = 4
|
||||
collision_mask = 5
|
||||
|
||||
[node name="Snowman 2" parent="YSort/Enemies" groups=[
|
||||
"enemies",
|
||||
] instance=ExtResource( 4 )]
|
||||
[node name="Snowman 2" parent="YSort/Enemies" groups=["enemies"] instance=ExtResource( 4 )]
|
||||
position = Vector2( 124.417, 123.977 )
|
||||
collision_layer = 4
|
||||
collision_mask = 5
|
||||
|
||||
[node name="Blue Snowman 1" parent="YSort/Enemies" groups=[
|
||||
"enemies",
|
||||
] instance=ExtResource( 6 )]
|
||||
[node name="Blue Snowman 1" parent="YSort/Enemies" groups=["enemies"] instance=ExtResource( 6 )]
|
||||
position = Vector2( 252.747, 40.9419 )
|
||||
collision_layer = 4
|
||||
collision_mask = 5
|
||||
script = ExtResource( 7 )
|
||||
|
||||
[node name="Blue Snowman 2" parent="YSort/Enemies" groups=[
|
||||
"enemies",
|
||||
] instance=ExtResource( 6 )]
|
||||
[node name="Blue Snowman 2" parent="YSort/Enemies" groups=["enemies"] instance=ExtResource( 6 )]
|
||||
position = Vector2( 105.053, 195.4 )
|
||||
collision_layer = 4
|
||||
collision_mask = 5
|
||||
@@ -233,3 +225,4 @@ autoplay = true
|
||||
[connection signal="ice_key_collected" from="YSort/TreasureChest" to="." method="_on_TreasureChest_ice_key_collected"]
|
||||
[connection signal="frozen" from="YSort/Player" to="Effects/SlowTime" method="start"]
|
||||
[connection signal="unfreeze" from="Effects/SlowTime" to="YSort/Player" method="_on_SlowTime_unfreeze"]
|
||||
[connection signal="timer_out" from="HUD/Countdown Timer" to="." method="_timer_out"]
|
||||
|
@@ -4,31 +4,34 @@ var gems: int = 4
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
|
||||
|
||||
func _on_TreasureChest_gem_collected() -> void:
|
||||
gems -= 1
|
||||
gems -= 1
|
||||
|
||||
if gems == 0:
|
||||
$YSort/Items/Door/doorClosed.visible = false
|
||||
$YSort/Items/Door/doorOpened.visible = true
|
||||
$DoorCollision.layers = 5
|
||||
return
|
||||
if gems == 0:
|
||||
$YSort/Items/Door/doorClosed.visible = false
|
||||
$YSort/Items/Door/doorOpened.visible = true
|
||||
$DoorCollision.layers = 5
|
||||
return
|
||||
|
||||
|
||||
func _on_NextArea_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
$YSort/Player.position.x = 195
|
||||
$YSort/Player.position.y = -335
|
||||
return
|
||||
if area.get_parent().name == 'Player':
|
||||
$YSort/Player.position.x = 195
|
||||
$YSort/Player.position.y = -335
|
||||
return
|
||||
|
||||
|
||||
func _on_Demon_Boss_demon_boss_death() -> void:
|
||||
$Timer.start()
|
||||
$Timer.start()
|
||||
return
|
||||
|
||||
|
||||
func _on_Timer_timeout() -> void:
|
||||
get_tree().change_scene('res://GUI/Level Complete.tscn')
|
||||
queue_free()
|
||||
if get_tree().change_scene('res://GUI/Level Complete.tscn') != OK:
|
||||
print('ERROR: Level 4 failed to change scene to Level Complete.')
|
||||
queue_free()
|
||||
return
|
||||
|
@@ -2,27 +2,27 @@ extends Node2D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
|
||||
|
||||
func _on_activate_boss_teleporter_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
$'Interactables/Boss Teleporter'.set_deferred('visible', true)
|
||||
$'Interactables/Activate Boss Teleporter'.call_deferred('queue_free')
|
||||
return
|
||||
if body.is_in_group('player'):
|
||||
$'Interactables/Boss Teleporter'.set_deferred('visible', true)
|
||||
$'Interactables/Activate Boss Teleporter'.call_deferred('queue_free')
|
||||
return
|
||||
|
||||
|
||||
func _on_eyeball_boss_death() -> void:
|
||||
$YSort/Enemies.call_deferred('queue_free')
|
||||
$Lights.call_deferred('queue_free')
|
||||
$Darkness.set_visible(false)
|
||||
$Ending.start()
|
||||
return
|
||||
$YSort/Enemies.call_deferred('queue_free')
|
||||
$Lights.call_deferred('queue_free')
|
||||
$Darkness.set_visible(false)
|
||||
$Ending.start()
|
||||
return
|
||||
|
||||
|
||||
func _on_ending_timeout():
|
||||
if get_tree().change_scene('res://GUI/Level Complete.tscn') != OK:
|
||||
print('ERROR: Level 5 failed to change scene to Level Complete.')
|
||||
queue_free()
|
||||
return
|
||||
if get_tree().change_scene('res://GUI/Level Complete.tscn') != OK:
|
||||
print('ERROR: Level 5 failed to change scene to Level Complete.')
|
||||
queue_free()
|
||||
return
|
||||
|
@@ -1,38 +1,33 @@
|
||||
extends AnimatedSprite
|
||||
|
||||
export(PackedScene) var object_scene: PackedScene = null
|
||||
export var object_scene: PackedScene = null
|
||||
|
||||
var is_player_inside: bool = false
|
||||
var is_opened: bool = false
|
||||
var has_key: bool = false
|
||||
|
||||
onready var animation_player: AnimationPlayer = get_node("AnimationPlayer")
|
||||
onready var tween: Tween = get_node("Key/Tween")
|
||||
|
||||
func _ready() -> void:
|
||||
assert(object_scene!=null)
|
||||
animation_player.play("closed")
|
||||
assert(object_scene != null)
|
||||
$AnimationPlayer.play('closed')
|
||||
$Key/KeySprite.visible = false
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if is_player_inside and not is_opened:
|
||||
is_opened = true
|
||||
animation_player.play("open")
|
||||
_drop_object()
|
||||
return
|
||||
|
||||
|
||||
func _on_area_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
$Area/CollisionShape2D.set_deferred('disabled', true)
|
||||
$AnimationPlayer.play('open')
|
||||
_drop_object()
|
||||
return
|
||||
|
||||
|
||||
func _drop_object() -> void:
|
||||
#print($Key.position)
|
||||
$Key/KeySprite.visible = true
|
||||
tween.interpolate_property($Key, "position", Vector2(0,0), Vector2(0, -10), 1.0, Tween.TRANS_QUAD,
|
||||
Tween.EASE_OUT)
|
||||
tween.start()
|
||||
yield(tween, "tween_completed")
|
||||
$Key/KeySprite.visible = false
|
||||
|
||||
|
||||
func _on_Area2D_player_entered(_player: KinematicBody2D) -> void:
|
||||
is_player_inside = true
|
||||
|
||||
if not $Key/Tween.interpolate_property($Key, 'position', Vector2(0,0), Vector2(0, -10), 1.0,
|
||||
Tween.TRANS_QUAD, Tween.EASE_OUT):
|
||||
print('ERROR: Chest key animation has errors.')
|
||||
if not $Key/Tween.start():
|
||||
print('ERROR: Chest key animation failed to start.')
|
||||
|
||||
func _on_Area2D_player_exited(_player: KinematicBody2D) -> void:
|
||||
is_player_inside = false
|
||||
yield($Key/Tween, 'tween_completed')
|
||||
$Key/KeySprite.visible = false
|
||||
return
|
||||
|
@@ -174,5 +174,4 @@ animation = "closed"
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Entrance"]
|
||||
anims/closed = SubResource( 6 )
|
||||
|
||||
[connection signal="body_entered" from="Area" to="." method="_on_Area2D_player_entered"]
|
||||
[connection signal="body_exited" from="Area" to="." method="_on_Area2D_player_exited"]
|
||||
[connection signal="body_entered" from="Area" to="." method="_on_area_body_entered"]
|
||||
|
@@ -1,63 +1,63 @@
|
||||
extends ColorRect
|
||||
|
||||
export var dialogPath = ""
|
||||
export(float) var textSpeed = 0.05
|
||||
export var dialog_path: String = ''
|
||||
export var text_speed: float = 0.05
|
||||
|
||||
var dialog
|
||||
var phraseNum = 0
|
||||
var dialog: Array
|
||||
var phrase_num: int = 0
|
||||
var finished = false
|
||||
|
||||
func _ready():
|
||||
# self.visible = false
|
||||
$Timer.wait_time = textSpeed
|
||||
dialog = getDialog()
|
||||
assert(dialog, "Dialong not found")
|
||||
nextPhrase()
|
||||
|
||||
|
||||
func _process(delta):
|
||||
|
||||
func _ready() -> void:
|
||||
$Timer.wait_time = text_speed
|
||||
dialog = get_dialog()
|
||||
assert(dialog, 'Dialog not found')
|
||||
next_phrase()
|
||||
return
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
$Indicator.visible = finished
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
if event.is_action_pressed('ui_accept'):
|
||||
if finished:
|
||||
nextPhrase()
|
||||
next_phrase()
|
||||
else:
|
||||
$Text.visible_characters = len($Text.text)
|
||||
func getDialog() -> Array:
|
||||
return
|
||||
|
||||
|
||||
func get_dialog() -> Array:
|
||||
var f = File.new()
|
||||
assert(f.file_exists(dialogPath), "File path does not exist")
|
||||
|
||||
f.open(dialogPath, File.READ)
|
||||
assert(f.file_exists(dialog_path), 'File path does not exist')
|
||||
|
||||
f.open(dialog_path, File.READ)
|
||||
var json = f.get_as_text()
|
||||
|
||||
|
||||
var output = parse_json(json)
|
||||
|
||||
|
||||
if typeof(output) == TYPE_ARRAY:
|
||||
return output
|
||||
else:
|
||||
return []
|
||||
|
||||
func nextPhrase() -> void:
|
||||
if phraseNum >= len(dialog):
|
||||
|
||||
func next_phrase() -> void:
|
||||
if phrase_num >= len(dialog):
|
||||
queue_free()
|
||||
return
|
||||
|
||||
|
||||
finished = false
|
||||
|
||||
$Name.bbcode_text = dialog[phraseNum]["Name"]
|
||||
$Text.bbcode_text = dialog[phraseNum]["Text"]
|
||||
|
||||
|
||||
$Name.bbcode_text = dialog[phrase_num]['Name']
|
||||
$Text.bbcode_text = dialog[phrase_num]['Text']
|
||||
|
||||
$Text.visible_characters = 0
|
||||
|
||||
|
||||
while $Text.visible_characters < len($Text.text):
|
||||
$Text.visible_characters += 1
|
||||
|
||||
|
||||
$Timer.start()
|
||||
yield($Timer, "timeout")
|
||||
|
||||
yield($Timer, 'timeout')
|
||||
|
||||
finished = true
|
||||
phraseNum += 1
|
||||
phrase_num += 1
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -28,7 +28,7 @@ tracks/0/keys = {
|
||||
"values": [ NodePath("..") ]
|
||||
}
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
[node name="Dialogue" type="Control"]
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
@@ -46,7 +46,7 @@ script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
dialogPath = "res://Levels/Objects/journalScrapDialog.json"
|
||||
dialog_path = "res://Levels/Objects/journalScrapDialog.json"
|
||||
|
||||
[node name="Name" type="RichTextLabel" parent="DialogBox"]
|
||||
anchor_bottom = 2.0
|
||||
|
@@ -1,24 +1,11 @@
|
||||
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:
|
||||
func _on_AnimationPlayer_animation_finished(_anim_name: String) -> void:
|
||||
$IceKeySprite.visible = false
|
||||
return
|
||||
|
||||
|
||||
func _on_AnimationPlayer_animation_started(anim_name: String) -> void:
|
||||
func _on_AnimationPlayer_animation_started(_anim_name: String) -> void:
|
||||
$IceKeySprite.visible = true
|
||||
return
|
||||
|
@@ -1,34 +1,20 @@
|
||||
extends Sprite
|
||||
|
||||
signal ice_key_collected
|
||||
|
||||
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")
|
||||
$Key/AnimationPlayer.play('rise')
|
||||
is_opened = true
|
||||
has_key = false
|
||||
emit_signal("ice_key_collected")
|
||||
emit_signal('ice_key_collected')
|
||||
return
|
||||
|
7
Levels/Portal Dark Forest.gd
Normal file
7
Levels/Portal Dark Forest.gd
Normal file
@@ -0,0 +1,7 @@
|
||||
extends Area2D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
$CollisionShape2D.visible = false
|
||||
return
|
@@ -1,17 +0,0 @@
|
||||
extends Area2D
|
||||
|
||||
|
||||
# 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:
|
||||
self.visible = false
|
||||
$CollisionShape2D.visible = false
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
@@ -1,6 +1,6 @@
|
||||
extends Area2D
|
||||
|
||||
export var enemy_path: String = 'res://Enemies/Ghost_Enemy.tscn'
|
||||
export var enemy_path: String = 'res://Enemies/ENEMY.tscn'
|
||||
export var relative_x_tiles: int
|
||||
export var relative_y_tiles: int
|
||||
|
||||
|
96
Main.gd
96
Main.gd
@@ -7,76 +7,76 @@ export var hub_world_path: String
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
randomize()
|
||||
var splash_screen: Node = play_splash_screen()
|
||||
yield(splash_screen, 'complete')
|
||||
splash_screen = null
|
||||
randomize()
|
||||
var splash_screen: Node = play_splash_screen()
|
||||
yield(splash_screen, 'complete')
|
||||
splash_screen = null
|
||||
|
||||
var main_menu: Node = play_main_menu()
|
||||
yield(main_menu, 'complete')
|
||||
free_connected_node(main_menu, 'main_menu_option')
|
||||
main_menu = null
|
||||
return
|
||||
var main_menu: Node = play_main_menu()
|
||||
yield(main_menu, 'complete')
|
||||
free_connected_node(main_menu, 'main_menu_option')
|
||||
main_menu = null
|
||||
return
|
||||
|
||||
|
||||
func play_splash_screen() -> Node:
|
||||
var splash_screen: Node = load(splash_screen_path).instance()
|
||||
if splash_screen.connect('complete', self, 'free_connected_node',
|
||||
[splash_screen, 'free_connected_node']) != OK:
|
||||
print('ERROR: Splash Screen "complete" signal already connected.')
|
||||
var splash_screen: Node = load(splash_screen_path).instance()
|
||||
if splash_screen.connect('complete', self, 'free_connected_node',
|
||||
[splash_screen, 'free_connected_node']) != OK:
|
||||
print('ERROR: Splash Screen "complete" signal already connected.')
|
||||
|
||||
add_child(splash_screen)
|
||||
return splash_screen
|
||||
add_child(splash_screen)
|
||||
return splash_screen
|
||||
|
||||
|
||||
func play_main_menu() -> Node:
|
||||
var main_menu: Node = load(main_menu_path).instance()
|
||||
if main_menu.connect('complete', self, 'main_menu_option') != OK:
|
||||
print('ERROR: Main Menu "complete" signal already connected.')
|
||||
var main_menu: Node = load(main_menu_path).instance()
|
||||
if main_menu.connect('complete', self, 'main_menu_option') != OK:
|
||||
print('ERROR: Main Menu "complete" signal already connected.')
|
||||
|
||||
add_child(main_menu)
|
||||
return main_menu
|
||||
add_child(main_menu)
|
||||
return main_menu
|
||||
|
||||
|
||||
func main_menu_option(option: String) -> void:
|
||||
if option == 'new game':
|
||||
if get_tree().change_scene(hub_world_path) != OK:
|
||||
print('ERROR: Main failed to change scene to Hub World.')
|
||||
queue_free()
|
||||
#var level_select_menu: Node = play_level_select_menu()
|
||||
#yield(level_select_menu, 'complete')
|
||||
#free_connected_node(level_select_menu, 'level_select_menu_option')
|
||||
#level_select_menu = null
|
||||
return
|
||||
if option == 'new game':
|
||||
if get_tree().change_scene(hub_world_path) != OK:
|
||||
print('ERROR: Main failed to change scene to Hub World.')
|
||||
queue_free()
|
||||
#var level_select_menu: Node = play_level_select_menu()
|
||||
#yield(level_select_menu, 'complete')
|
||||
#free_connected_node(level_select_menu, 'level_select_menu_option')
|
||||
#level_select_menu = null
|
||||
return
|
||||
|
||||
|
||||
func play_level_select_menu() -> Node:
|
||||
var level_select_menu: Node = load(level_select_menu_path).instance()
|
||||
if level_select_menu.connect('complete', self, 'level_select_menu_option') != OK:
|
||||
print('ERROR: Level Select Menu "complete" signal already connected.')
|
||||
var level_select_menu: Node = load(level_select_menu_path).instance()
|
||||
if level_select_menu.connect('complete', self, 'level_select_menu_option') != OK:
|
||||
print('ERROR: Level Select Menu "complete" signal already connected.')
|
||||
|
||||
add_child(level_select_menu)
|
||||
return level_select_menu
|
||||
add_child(level_select_menu)
|
||||
return level_select_menu
|
||||
|
||||
|
||||
func level_select_menu_option(option: String) -> void:
|
||||
var level: String = 'res://Levels/'
|
||||
if option == 'H':
|
||||
level += 'Hub World.tscn'
|
||||
else:
|
||||
level += 'Level ' + option + '.tscn'
|
||||
var level: String = 'res://Levels/'
|
||||
if option == 'H':
|
||||
level += 'Hub World.tscn'
|
||||
else:
|
||||
level += 'Level ' + option + '.tscn'
|
||||
|
||||
new_game(level)
|
||||
return
|
||||
new_game(level)
|
||||
return
|
||||
|
||||
func free_connected_node(node: Node, connected_function: String) -> void:
|
||||
node.disconnect('complete', self, connected_function)
|
||||
node.queue_free()
|
||||
return
|
||||
node.disconnect('complete', self, connected_function)
|
||||
node.queue_free()
|
||||
return
|
||||
|
||||
|
||||
func new_game(level: String) -> void:
|
||||
if get_tree().change_scene(level) != OK:
|
||||
print('ERROR: Main failed to change scene to Level.')
|
||||
queue_free()
|
||||
return
|
||||
if get_tree().change_scene(level) != OK:
|
||||
print('ERROR: Main failed to change scene to Level.')
|
||||
queue_free()
|
||||
return
|
||||
|
174
Player/Player.gd
174
Player/Player.gd
@@ -14,137 +14,137 @@ var velocity: Vector2 = Vector2.ZERO
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_weapon_position(Vector2(1, 0))
|
||||
return
|
||||
set_weapon_position(Vector2(1, 0))
|
||||
return
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var input_vector: Vector2 = Vector2.ZERO
|
||||
var input_vector: Vector2 = Vector2.ZERO
|
||||
|
||||
input_vector.x = Input.get_action_strength('player_right') \
|
||||
- Input.get_action_strength('player_left')
|
||||
input_vector.y = Input.get_action_strength('player_down') \
|
||||
- Input.get_action_strength('player_up')
|
||||
input_vector = input_vector.normalized()
|
||||
input_vector.x = Input.get_action_strength('player_right') \
|
||||
- Input.get_action_strength('player_left')
|
||||
input_vector.y = Input.get_action_strength('player_down') \
|
||||
- Input.get_action_strength('player_up')
|
||||
input_vector = input_vector.normalized()
|
||||
|
||||
if input_vector != Vector2.ZERO:
|
||||
$AnimationTree.set('parameters/Idle/blend_position', input_vector)
|
||||
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
|
||||
set_weapon_position(input_vector)
|
||||
else:
|
||||
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
||||
if input_vector != Vector2.ZERO:
|
||||
$AnimationTree.set('parameters/Idle/blend_position', input_vector)
|
||||
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
|
||||
set_weapon_position(input_vector)
|
||||
else:
|
||||
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func load_hud(node: CanvasLayer) -> void:
|
||||
hud = node
|
||||
if hud.connect('add_currency', self, 'add_currency') != OK:
|
||||
print('ERROR: HUD "add_currency" signal already connected.')
|
||||
hud = node
|
||||
if hud.connect('add_currency', self, 'add_currency') != OK:
|
||||
print('ERROR: HUD "add_currency" signal already connected.')
|
||||
|
||||
hud.update_health(HEALTH_SLICES[health_index])
|
||||
hud.update_currency($Inventory.get_currency())
|
||||
return
|
||||
hud.update_health(HEALTH_SLICES[health_index])
|
||||
hud.update_currency($Inventory.get_currency())
|
||||
return
|
||||
|
||||
|
||||
func set_weapon_position(pos: Vector2) -> void:
|
||||
# Facing left
|
||||
if pos[0] < 0:
|
||||
$Sword.rotation_degrees = -90
|
||||
$Javelin.rotation_degrees = -90
|
||||
# Facing left
|
||||
if pos[0] < 0:
|
||||
$Sword.rotation_degrees = -90
|
||||
$Javelin.rotation_degrees = -90
|
||||
|
||||
# Facing right
|
||||
elif pos[0] > 0:
|
||||
$Sword.rotation_degrees = 90
|
||||
$Javelin.rotation_degrees = 90
|
||||
# Facing right
|
||||
elif pos[0] > 0:
|
||||
$Sword.rotation_degrees = 90
|
||||
$Javelin.rotation_degrees = 90
|
||||
|
||||
# Facing up
|
||||
elif pos[1] < 0:
|
||||
$Sword.rotation_degrees = 0
|
||||
$Javelin.rotation_degrees = 0
|
||||
# Facing up
|
||||
elif pos[1] < 0:
|
||||
$Sword.rotation_degrees = 0
|
||||
$Javelin.rotation_degrees = 0
|
||||
|
||||
# Facing down
|
||||
elif pos[1] > 0:
|
||||
$Sword.rotation_degrees = 180
|
||||
$Javelin.rotation_degrees = 180
|
||||
return
|
||||
# Facing down
|
||||
elif pos[1] > 0:
|
||||
$Sword.rotation_degrees = 180
|
||||
$Javelin.rotation_degrees = 180
|
||||
return
|
||||
|
||||
|
||||
func add_currency(amount: int) -> void:
|
||||
$Inventory.add_currency(amount)
|
||||
return
|
||||
$Inventory.add_currency(amount)
|
||||
return
|
||||
|
||||
|
||||
func has_item(item: String) -> bool:
|
||||
return $Inventory.contains(item)
|
||||
return $Inventory.contains(item)
|
||||
|
||||
|
||||
func add_item(item: String) -> void:
|
||||
$Inventory.add(item)
|
||||
return
|
||||
$Inventory.add(item)
|
||||
return
|
||||
|
||||
|
||||
func remove_item(item: String) -> void:
|
||||
$Inventory.remove(item)
|
||||
return
|
||||
$Inventory.remove(item)
|
||||
return
|
||||
|
||||
|
||||
func _on_Inventory_update_currency(amount: int) -> void:
|
||||
hud.update_currency(amount)
|
||||
return
|
||||
hud.update_currency(amount)
|
||||
return
|
||||
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
var hit: int = 0
|
||||
var hit: int = 0
|
||||
|
||||
if area.is_in_group('enemy_hitbox_1') or area.is_in_group('enemy_projectile_1'):
|
||||
hit = 1
|
||||
elif area.is_in_group('enemy_hitbox_2') or area.is_in_group('enemy_projectile_2'):
|
||||
hit = 2
|
||||
elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'):
|
||||
hit = 3
|
||||
elif area.is_in_group('freeze'):
|
||||
emit_signal('frozen')
|
||||
$Sprite.self_modulate = Color(0, 0.5, 1)
|
||||
else:
|
||||
return
|
||||
if area.is_in_group('enemy_hitbox_1') or area.is_in_group('enemy_projectile_1'):
|
||||
hit = 1
|
||||
elif area.is_in_group('enemy_hitbox_2') or area.is_in_group('enemy_projectile_2'):
|
||||
hit = 2
|
||||
elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'):
|
||||
hit = 3
|
||||
elif area.is_in_group('freeze'):
|
||||
emit_signal('frozen')
|
||||
$Sprite.self_modulate = Color(0, 0.5, 1)
|
||||
else:
|
||||
return
|
||||
|
||||
if health_index != 0:
|
||||
health_index -= hit
|
||||
if health_index < 0:
|
||||
health_index = 0
|
||||
if health_index != 0:
|
||||
health_index -= hit
|
||||
if health_index < 0:
|
||||
health_index = 0
|
||||
|
||||
hud.update_health(HEALTH_SLICES[health_index])
|
||||
else:
|
||||
if get_tree().change_scene('res://GUI/Level Failed.tscn') != OK:
|
||||
print('ERROR: Player failed to change scene to Level Failed.')
|
||||
queue_free()
|
||||
return
|
||||
hud.update_health(HEALTH_SLICES[health_index])
|
||||
else:
|
||||
if get_tree().change_scene('res://GUI/Level Failed.tscn') != OK:
|
||||
print('ERROR: Player failed to change scene to Level Failed.')
|
||||
queue_free()
|
||||
return
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed('player_attack'):
|
||||
if hud.weapon == 'sword':
|
||||
$'Sword/Sword Animation'.play('swing')
|
||||
elif hud.weapon == 'javelin':
|
||||
$'Javelin/Javelin Animation'.play('swing')
|
||||
if event.is_action_pressed('player_attack'):
|
||||
if hud.weapon == 'sword':
|
||||
$'Sword/Sword Animation'.play('swing')
|
||||
elif hud.weapon == 'javelin':
|
||||
$'Javelin/Javelin Animation'.play('swing')
|
||||
|
||||
elif event.is_action_pressed('screenshot'):
|
||||
var img: Image = get_viewport().get_texture().get_data()
|
||||
yield(get_tree(), 'idle_frame')
|
||||
yield(get_tree(), 'idle_frame')
|
||||
elif event.is_action_pressed('screenshot'):
|
||||
var img: Image = get_viewport().get_texture().get_data()
|
||||
yield(get_tree(), 'idle_frame')
|
||||
yield(get_tree(), 'idle_frame')
|
||||
|
||||
img.flip_y()
|
||||
img.flip_y()
|
||||
|
||||
var time: Dictionary = OS.get_datetime_from_unix_time(OS.get_unix_time())
|
||||
var time_msecs: int = OS.get_system_time_msecs()
|
||||
var time: Dictionary = OS.get_datetime_from_unix_time(OS.get_unix_time())
|
||||
var time_msecs: int = OS.get_system_time_msecs()
|
||||
|
||||
if img.save_png('user://Screenshot_%d%d%d_%d.png' % [time.year, time.month, time.day, time_msecs]) != OK:
|
||||
print('ERROR: Failed saving screenshot.')
|
||||
return
|
||||
if img.save_png('user://Screenshot_%d%d%d_%d.png' % [time.year, time.month, time.day, time_msecs]) != OK:
|
||||
print('ERROR: Failed saving screenshot.')
|
||||
return
|
||||
|
||||
|
||||
func _on_SlowTime_unfreeze() -> void:
|
||||
$Sprite.self_modulate = Color(1, 1, 1)
|
||||
return
|
||||
$Sprite.self_modulate = Color(1, 1, 1)
|
||||
return
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user