This commit is contained in:
Diego 2020-07-23 23:04:24 -05:00
parent c3043f1a7e
commit 3cbee20d2f
8 changed files with 52 additions and 29 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=7 format=2]
[ext_resource path="res://ai/Script/Skeleton Enemy.gd" type="Script" id=1] [ext_resource path="res://ai/Script/Skeleton Enemy.gd" type="Script" id=1]
[ext_resource path="res://Music and Fonts(Misc.)/Skeleton Hit.tres" type="Animation" id=2] [ext_resource path="res://Music and Fonts(Misc.)/Skeleton Hit.tres" type="Animation" id=2]
@ -24,6 +24,9 @@ tracks/0/keys = {
"values": [ 0, 1, 2, 3, 4, 5, 6, 7 ] "values": [ 0, 1, 2, 3, 4, 5, 6, 7 ]
} }
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 6, 2 )
[node name="Skeleton Enemy" type="KinematicBody2D"] [node name="Skeleton Enemy" type="KinematicBody2D"]
collision_layer = 4 collision_layer = 4
collision_mask = 15 collision_mask = 15
@ -59,3 +62,13 @@ autoplay = "Skeleton Jump"
[node name="AnimationPlayer2" type="AnimationPlayer" parent="."] [node name="AnimationPlayer2" type="AnimationPlayer" parent="."]
anims/Hit = ExtResource( 2 ) anims/Hit = ExtResource( 2 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 0, -6 )
shape = SubResource( 3 )
[node name="DamageCD" type="Timer" parent="."]
wait_time = 0.5
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

View file

@ -5,8 +5,8 @@
[ext_resource path="res://Music and Fonts(Misc.)/Ogre Hit.tres" type="Animation" id=3] [ext_resource path="res://Music and Fonts(Misc.)/Ogre Hit.tres" type="Animation" id=3]
[ext_resource path="res://Music and Fonts(Misc.)/Ogre Run.tres" type="Animation" id=4] [ext_resource path="res://Music and Fonts(Misc.)/Ogre Run.tres" type="Animation" id=4]
[sub_resource type="CapsuleShape2D" id=1] [sub_resource type="RectangleShape2D" id=3]
height = 4.0 extents = Vector2( 11.7397, 12.875 )
[sub_resource type="CapsuleShape2D" id=2] [sub_resource type="CapsuleShape2D" id=2]
radius = 12.0 radius = 12.0
@ -22,11 +22,10 @@ script = ExtResource( 1 )
position = Vector2( 0, -17 ) position = Vector2( 0, -17 )
texture = ExtResource( 2 ) texture = ExtResource( 2 )
hframes = 4 hframes = 4
frame = 3
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 1, -12 ) position = Vector2( -0.25, -12.25 )
shape = SubResource( 1 ) shape = SubResource( 3 )
[node name="DamageCD" type="Timer" parent="."] [node name="DamageCD" type="Timer" parent="."]
wait_time = 0.5 wait_time = 0.5
@ -44,5 +43,5 @@ anims/Hit = ExtResource( 3 )
collision_layer = 0 collision_layer = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 1, -13 ) position = Vector2( -0.375, -11.625 )
shape = SubResource( 2 ) shape = SubResource( 2 )

View file

@ -24,7 +24,7 @@ func _physics_process(_delta):
var collider = PlayerRaycast.get_collider() var collider = PlayerRaycast.get_collider()
if dist <= 200: if dist <= 250:
velocity.x = position.direction_to(player_position).normalized().x * speed velocity.x = position.direction_to(player_position).normalized().x * speed
if collider != null && collider.has_method("get_type") && collider.get_type() == "player": if collider != null && collider.has_method("get_type") && collider.get_type() == "player":
shoot_fireball(position.direction_to(player_position)) shoot_fireball(position.direction_to(player_position))

View file

@ -1,12 +1,15 @@
extends Enemy extends Enemy
export var max_range: int = 200 export var max_range: int = 250
export var stationary: bool = false export var stationary: bool = false
var contact_damage = 0.5
var Spinning_Bone = preload("res://ai/Scenes/SpinningBone.tscn") var Spinning_Bone = preload("res://ai/Scenes/SpinningBone.tscn")
onready var ShootDelay : Timer = $ShootDelay onready var ShootDelay : Timer = $ShootDelay
onready var ProjectileSpawn: Node2D = $Position2D onready var ProjectileSpawn: Node2D = $Position2D
onready var Hurtbox = $Area2D
onready var DamageCD = $DamageCD
func _ready(): func _ready():
health = 1.5 health = 1.5
@ -69,3 +72,11 @@ func do_knockback(normal):
else: else:
knockback = Vector2(4, 0) knockback = Vector2(4, 0)
func deal_damage():
if DamageCD.is_stopped():
for body in Hurtbox.get_overlapping_bodies():
if body.has_method("get_type") && body.get_type() == "player":
body.health -= contact_damage
DamageCD.start()

View file

@ -13,6 +13,7 @@ func _ready():
health = 5 health = 5
func _physics_process(delta): func _physics_process(delta):
print(is_on_wall())
if knockback != Vector2.ZERO: if knockback != Vector2.ZERO:
knockback = lerp(knockback, Vector2.ZERO, 0.5) knockback = lerp(knockback, Vector2.ZERO, 0.5)
move_and_slide(-knockback * knockback_amount) move_and_slide(-knockback * knockback_amount)
@ -21,22 +22,23 @@ func _physics_process(delta):
return return
var player = Player.position var player = Player.position
var distance = global_position.distance_to(player) var distance = global_position.distance_to(player)
if distance <= 200 and is_on_floor(): if distance <= 250 and is_on_floor():
if player.x > global_position.x: if player.x > global_position.x:
Spr.flip_h = false Spr.flip_h = false
velocity.x = speed velocity.x = speed
elif player.x < global_position.x: elif player.x < global_position.x:
Spr.flip_h = true Spr.flip_h = true
velocity.x = -speed velocity.x = -speed
else:
velocity.x = 0
if stationary: if stationary:
velocity.x = 0 velocity.x = 0
if health <= 0: if health <= 0:
queue_free() queue_free()
if not is_on_floor(): if not is_on_floor():
velocity.y = gravity velocity.y = gravity
if is_on_floor() and is_on_wall(): if is_on_floor() and is_on_wall() == true:
velocity.y = -100 velocity.y = -150
print("jump")
velocity = move_and_slide(velocity, Vector2.UP) velocity = move_and_slide(velocity, Vector2.UP)
deal_damage() deal_damage()

View file

@ -92,7 +92,7 @@ margin_top = 60.0
margin_right = 435.0 margin_right = 435.0
margin_bottom = 137.0 margin_bottom = 137.0
custom_fonts/font = SubResource( 1 ) custom_fonts/font = SubResource( 1 )
text = "Experiment with combos, and craft the best magic for the situation." text = "Experiment with combo's, and craft the best magic for the situation."
align = 1 align = 1
valign = 1 valign = 1
autowrap = true autowrap = true
@ -149,7 +149,7 @@ color = Color( 0.564706, 0.564706, 0.564706, 1 )
[node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Sprite" type="Sprite" parent="CanvasLayer"] [node name="Sprite" type="Sprite" parent="CanvasLayer"]
modulate = Color( 0, 0, 0, 1 ) modulate = Color( 0, 0, 0, 0 )
texture = ExtResource( 7 ) texture = ExtResource( 7 )
centered = false centered = false
@ -167,7 +167,7 @@ percent_visible = 0.0
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[connection signal="body_entered" from="Leap" to="Timer" method="_on_Leap_body_entered"]
[connection signal="body_entered" from="Leap" to="AnimationPlayer2" method="_on_Leap_body_entered"]
[connection signal="body_entered" from="Leap" to="AnimationPlayer" method="_on_Leap_body_entered"] [connection signal="body_entered" from="Leap" to="AnimationPlayer" method="_on_Leap_body_entered"]
[connection signal="body_entered" from="Leap" to="AnimationPlayer2" method="_on_Leap_body_entered"]
[connection signal="body_entered" from="Leap" to="Timer" method="_on_Leap_body_entered"]
[connection signal="timeout" from="Timer" to="Timer" method="_on_Timer_timeout"] [connection signal="timeout" from="Timer" to="Timer" method="_on_Timer_timeout"]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long