Added locked barriers and a new ghost enemy

This commit is contained in:
VoidTwo
2021-12-04 18:23:05 -06:00
parent fcea3cee03
commit 9101bf2f65
21 changed files with 472 additions and 41 deletions

View File

@@ -17,12 +17,12 @@ func _physics_process(_delta: float) -> void:
func _on_player_detector_body_entered(body: Node) -> void:
if 'player' in body.get_groups():
if body.is_in_group('player'):
player = body
return
func _on_player_detector_body_exited(body: Node) -> void:
if 'player' in body.get_groups():
if body.is_in_group('player'):
player = null
return

View File

@@ -2,8 +2,8 @@
[ext_resource path="res://Resources/Level_5_Enemy_Glowing_Ghost_Occluder.tres" type="OccluderPolygon2D" id=1]
[ext_resource path="res://Sprites/Assets/Light.png" type="Texture" id=2]
[ext_resource path="res://Sprites/Enemies/Glowing_Ghost.png" type="Texture" id=3]
[ext_resource path="res://Enemies/Glowing Ghost.gd" type="Script" id=4]
[ext_resource path="res://Sprites/Enemies/Chasing_Glowing_Ghost.png" type="Texture" id=3]
[ext_resource path="res://Enemies/Chasing Glowing Ghost.gd" type="Script" id=4]
[sub_resource type="CapsuleShape2D" id=3]
radius = 1.5
@@ -16,7 +16,7 @@ height = 2.0
[sub_resource type="CircleShape2D" id=2]
radius = 50.0
[node name="Glowing Ghost" type="KinematicBody2D" groups=["enemy"]]
[node name="Chasing Glowing Ghost" type="KinematicBody2D" groups=["enemy"]]
collision_layer = 4
collision_mask = 5
script = ExtResource( 4 )

View File

@@ -0,0 +1,41 @@
extends KinematicBody2D
const SPEED: int = 35
export var creepy_hand: PackedScene
var player: KinematicBody2D = null
var velocity: Vector2 = Vector2.ZERO
func _physics_process(_delta: float) -> void:
velocity = Vector2.ZERO
if player:
if position.distance_to(player.position) < 40:
velocity = position.direction_to(player.position).normalized() * -SPEED
elif position.distance_to(player.position) > 41:
velocity = position.direction_to(player.position).normalized() * SPEED
velocity = move_and_slide(velocity)
return
func _on_player_detector_body_entered(body: Node) -> void:
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
func _on_projectile_timer_timeout() -> void:
if player:
var projectile: Node = creepy_hand.instance()
projectile.init($Sprite.global_position, player.position)
get_tree().get_current_scene().get_node('Projectiles').add_child(projectile)
return

View File

@@ -0,0 +1,82 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://Resources/Level_5_Enemy_Glowing_Ghost_Occluder.tres" type="OccluderPolygon2D" id=1]
[ext_resource path="res://Sprites/Assets/Light.png" type="Texture" id=2]
[ext_resource path="res://Sprites/Enemies/Creepy_Glowing_Ghost.png" type="Texture" id=3]
[ext_resource path="res://Enemies/Creepy Glowing Ghost.gd" type="Script" id=4]
[ext_resource path="res://Enemies/Projectiles/Creepy Hand.tscn" type="PackedScene" id=5]
[sub_resource type="CapsuleShape2D" id=3]
radius = 1.5
height = 3.0
[sub_resource type="CapsuleShape2D" id=1]
radius = 3.0
height = 2.0
[sub_resource type="CircleShape2D" id=2]
radius = 60.0
[node name="Creepy Glowing Ghost" type="KinematicBody2D" groups=["enemy"]]
collision_layer = 4
collision_mask = 5
script = ExtResource( 4 )
creepy_hand = ExtResource( 5 )
[node name="Sprite" type="Sprite" parent="."]
light_mask = 4
position = Vector2( 0, -3 )
texture = ExtResource( 3 )
offset = Vector2( 0, 0.5 )
[node name="Collision" type="CollisionShape2D" parent="."]
visible = false
light_mask = 0
rotation = 1.5708
shape = SubResource( 3 )
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox"]]
collision_layer = 4
collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
visible = false
light_mask = 0
position = Vector2( 0, -2.5 )
shape = SubResource( 1 )
[node name="Player Detector" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 2
input_pickable = false
monitorable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player Detector"]
visible = false
light_mask = 0
shape = SubResource( 2 )
[node name="Light" type="Light2D" parent="."]
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 2 )
color = Color( 0.698039, 0.211765, 0.984314, 0.392157 )
energy = 2.0
range_item_cull_mask = 11
[node name="Eyes" type="Light2D" parent="."]
scale = Vector2( 0.1, 0.1 )
texture = ExtResource( 2 )
offset = Vector2( 5, -35 )
range_item_cull_mask = 4
[node name="Occluder" type="LightOccluder2D" parent="."]
show_behind_parent = true
occluder = ExtResource( 1 )
[node name="Projectile Timer" type="Timer" parent="."]
wait_time = 2.0
autostart = true
[connection signal="body_entered" from="Player Detector" to="." method="_on_player_detector_body_entered"]
[connection signal="body_exited" from="Player Detector" to="." method="_on_player_detector_body_exited"]
[connection signal="timeout" from="Projectile Timer" to="." method="_on_projectile_timer_timeout"]

View File

@@ -0,0 +1,28 @@
extends Area2D
const SPEED: int = 35
var player_position: Vector2
var velocity: Vector2 = Vector2.ZERO
func init(spawn_position: Vector2, shoot_position: Vector2) -> void:
position = spawn_position
player_position = shoot_position
$Sprite.rotation = player_position.angle_to_point(position) + deg2rad(90)
return
func _physics_process(delta: float) -> void:
velocity = Vector2.ZERO
if position.distance_to(player_position) > 1:
velocity = position.direction_to(player_position).normalized() * SPEED * delta
position += velocity
return
func _on_tifetime_timeout() -> void:
call_deferred('queue_free')
return

View File

@@ -0,0 +1,41 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Sprites/Assets/Light.png" type="Texture" id=1]
[ext_resource path="res://Sprites/Enemies/Projectiles/Creepy_Hand.png" type="Texture" id=2]
[ext_resource path="res://Enemies/Projectiles/Creepy Hand.gd" type="Script" id=3]
[sub_resource type="CircleShape2D" id=1]
radius = 12.0
[node name="Creepy Hand" type="Area2D" groups=["enemy_hitbox"]]
light_mask = 0
scale = Vector2( 0.5, 0.5 )
collision_layer = 0
collision_mask = 2
input_pickable = false
monitoring = false
script = ExtResource( 3 )
[node name="Sprite" type="Sprite" parent="."]
light_mask = 0
texture = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
light_mask = 0
shape = SubResource( 1 )
[node name="Light" type="Light2D" parent="."]
texture = ExtResource( 1 )
texture_scale = 0.3
color = Color( 0.698039, 0.211765, 0.984314, 1 )
energy = 1.5
range_item_cull_mask = 15
shadow_item_cull_mask = 0
[node name="Lifetime" type="Timer" parent="."]
wait_time = 2.0
one_shot = true
autostart = true
[connection signal="timeout" from="Lifetime" to="." method="_on_tifetime_timeout"]

View File

@@ -0,0 +1,23 @@
extends StaticBody2D
export var alignment: String = 'V'
func _ready() -> void:
if not alignment in ['V', 'H']:
print('Silver Barrier rotation needs to be "V" or "H"')
elif alignment == 'H':
rotation_degrees = 90
return
func _on_unlock_body_entered(body: Node) -> void:
if not 'player' in body.get_groups():
return
if body.has_item('Silver Key'):
body.remove_item('Silver Key')
$Sprite.animation = 'open'
$Collision.set_deferred('disabled', true)
$Unlock.set_deferred('monitoring', false)
return

View File

@@ -0,0 +1,51 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Sprites/Levels/Interactables/Silver_Barrier_Open.png" type="Texture" id=1]
[ext_resource path="res://Sprites/Levels/Interactables/Silver_Barrier_Closed.png" type="Texture" id=2]
[ext_resource path="res://Levels/Interactables/Silver Barrier.gd" type="Script" id=3]
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 1 ) ],
"loop": true,
"name": "open",
"speed": 5.0
}, {
"frames": [ ExtResource( 2 ) ],
"loop": true,
"name": "closed",
"speed": 5.0
} ]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 6, 8 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 12, 10 )
[node name="Silver Barrier" type="StaticBody2D"]
collision_mask = 0
script = ExtResource( 3 )
[node name="Sprite" type="AnimatedSprite" parent="."]
light_mask = 8
frames = SubResource( 1 )
animation = "closed"
[node name="Collision" type="CollisionShape2D" parent="."]
light_mask = 0
shape = SubResource( 2 )
[node name="Unlock" type="Area2D" parent="."]
light_mask = 0
collision_layer = 0
collision_mask = 2
input_pickable = false
monitorable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Unlock"]
visible = false
light_mask = 0
shape = SubResource( 3 )
[connection signal="body_entered" from="Unlock" to="." method="_on_unlock_body_entered"]

File diff suppressed because one or more lines are too long

View File

@@ -3,43 +3,38 @@ extends Node
signal update_currency(amount)
var __currency: int
var __weapons: Array
var __accessories: Array
var __categories: Dictionary
var __items: Array
func _ready() -> void:
self.__currency = 100
self.__weapons = []
self.__accessories = []
self.__categories = {
'Weapon': self.__weapons,
'Accessory': self.__accessories}
__currency = 100
__items = []
return
func get_currency() -> int:
return self.__currency
return __currency
func add_currency(amount: int) -> void:
self.__currency += amount
emit_signal('update_currency', self.__currency)
__currency += amount
emit_signal('update_currency', __currency)
return
func add(item) -> void:
self.__categories[item.type].append(item)
func contains(item: String) -> bool:
if item in __items:
return true
return false
func add(item: String) -> void:
__items.append(item)
return
func discard(item) -> void:
var index: int = 0
for itr in self.__categories[item.type]:
if itr.equals(item):
self.__categories[item.type].remove(index)
break
index += 1
func remove(item: String) -> void:
for k in range(len(__items)):
if __items[k] == item:
__items.remove(k)
return

View File

@@ -45,8 +45,17 @@ func add_currency(amount: int) -> void:
return
func has_item(item: String) -> bool:
return $Inventory.contains(item)
func add_item(item: String) -> void:
print('%s added to inventory' % [item])
$Inventory.add(item)
return
func remove_item(item: String) -> void:
$Inventory.remove(item)
return

View File

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 141 B

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Chasing_Glowing_Ghost.png-058a2155c6f21646fb4dbe49b2572e1a.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Enemies/Chasing_Glowing_Ghost.png"
dest_files=[ "res://.import/Chasing_Glowing_Ghost.png-058a2155c6f21646fb4dbe49b2572e1a.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=2
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=0
process/fix_alpha_border=false
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Creepy_Glowing_Ghost.png-a6711d66d268c21b09d75a78af11cb3c.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Enemies/Creepy_Glowing_Ghost.png"
dest_files=[ "res://.import/Creepy_Glowing_Ghost.png-a6711d66d268c21b09d75a78af11cb3c.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=2
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=false
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

View File

@@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/Glowing_Ghost.png-46379ff53bc263370d2e0d62c670229c.stex"
path="res://.import/Creepy_Hand.png-08a92e3a11f7b6f5409d8d2c9c2390a5.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Enemies/Glowing_Ghost.png"
dest_files=[ "res://.import/Glowing_Ghost.png-46379ff53bc263370d2e0d62c670229c.stex" ]
source_file="res://Sprites/Enemies/Projectiles/Creepy_Hand.png"
dest_files=[ "res://.import/Creepy_Hand.png-08a92e3a11f7b6f5409d8d2c9c2390a5.stex" ]
[params]

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Silver_Barrier_Closed.png-f21af0f8676e345e4c4665869fd9b81c.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Levels/Interactables/Silver_Barrier_Closed.png"
dest_files=[ "res://.import/Silver_Barrier_Closed.png-f21af0f8676e345e4c4665869fd9b81c.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=2
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=0
process/fix_alpha_border=false
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Silver_Barrier_Open.png-98c2210bfdfd797f9554a71cb67cfeee.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Levels/Interactables/Silver_Barrier_Open.png"
dest_files=[ "res://.import/Silver_Barrier_Open.png-98c2210bfdfd797f9554a71cb67cfeee.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=2
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=0
process/fix_alpha_border=false
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0