Hit animation and prism wand works with eco

This commit is contained in:
Logan 2020-07-21 15:00:32 -05:00
parent add6d2ca02
commit 343a66396b
17 changed files with 90 additions and 51 deletions

View file

@ -11,6 +11,9 @@ const UP = Vector2(0, -1)
var velocity = Vector2() var velocity = Vector2()
func play_hit():
$AnimationPlayer2.play("Hit")
func get_player_position(): func get_player_position():
return Player.position return Player.position

View file

@ -8,6 +8,7 @@ onready var PlayerRaycast: RayCast2D = $PlayerRaycast
func _ready(): func _ready():
health = 0.5 health = 0.5
knockback_amount = 700
func _physics_process(_delta): func _physics_process(_delta):
if knockback != Vector2.ZERO: if knockback != Vector2.ZERO:

View file

@ -9,7 +9,7 @@
extents = Vector2( 5.06709, 5.78183 ) extents = Vector2( 5.06709, 5.78183 )
[sub_resource type="Animation" id=2] [sub_resource type="Animation" id=2]
length = 0.6 length = 0.65
loop = true loop = true
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/path = NodePath("Hell:frame") tracks/0/path = NodePath("Hell:frame")
@ -30,11 +30,11 @@ collision_mask = 11
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, 1.87833 ) position = Vector2( 0, 2 )
shape = SubResource( 1 ) shape = SubResource( 1 )
[node name="Hell" type="Sprite" parent="."] [node name="Hell" type="Sprite" parent="."]
position = Vector2( -7.56425, -7.87261 ) position = Vector2( -8, -8 )
texture = ExtResource( 1 ) texture = ExtResource( 1 )
centered = false centered = false
hframes = 8 hframes = 8

View file

@ -1,9 +1,8 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=2] [ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=2]
[ext_resource path="res://ai/Hell.tscn" type="PackedScene" id=3] [ext_resource path="res://ai/ogre.tscn" type="PackedScene" id=3]
[ext_resource path="res://Music and Fonts(Misc.)/Main music.ogg" type="AudioStream" id=4]
[node name="Node2D" type="Node2D"] [node name="Node2D" type="Node2D"]
@ -13,10 +12,5 @@ tile_data = PoolIntArray( 65536, 0, 8, 65537, 0, 10, 65538, 0, 10, 65539, 0, 10,
[node name="Player" parent="." instance=ExtResource( 1 )] [node name="Player" parent="." instance=ExtResource( 1 )]
position = Vector2( 60, 176 ) position = Vector2( 60, 176 )
[node name="KinematicBody2D" parent="." instance=ExtResource( 3 )] [node name="Ogre" parent="." instance=ExtResource( 3 )]
position = Vector2( 266, 142 ) position = Vector2( 345, 153 )
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 4 )
volume_db = -14.136
autoplay = true

View file

@ -1,17 +1,26 @@
extends Node2D extends Node2D
class_name Beam class_name Beam
var damage = 1
var energy_cost = 1
var max_cast = Vector2(400, 0) var max_cast = Vector2(400, 0)
onready var Beam: Sprite = $Beam func get_collider():
onready var Begin: Sprite = $Begin return $RayCast2D.get_collider()
onready var Ray: RayCast2D = $Raycast2D
onready var End: Position2D = $End func activate():
$Beam.visible = true
$RayCast2D.enabled = true
func deactivate():
$Beam.visible = false
$RayCast2D.enabled = false
func _physics_process(delta): func _physics_process(delta):
Ray.cast_to = max_cast $RayCast2D.cast_to = max_cast
if Ray.is_colliding(): if $RayCast2D.is_colliding():
End.global_position = Ray.get_collision_point() $End.global_position = $RayCast2D.get_collision_point()
else: else:
End.position = max_cast $End.position = max_cast
Beam. $Beam.region_rect.end.x = $End.position.length()

View file

@ -1 +1,4 @@
extends Node2D extends Beam
func _ready():
energy_cost = 1

View file

@ -18,5 +18,6 @@ region_rect = Rect2( 0, 0, 8, 8 )
[node name="RayCast2D" type="RayCast2D" parent="."] [node name="RayCast2D" type="RayCast2D" parent="."]
enabled = true enabled = true
cast_to = Vector2( 400, 0 ) cast_to = Vector2( 400, 0 )
collision_mask = 6
[node name="End" type="Position2D" parent="."] [node name="End" type="Position2D" parent="."]

View file

@ -12,7 +12,7 @@ func on_impact(collision):
elif bounces_left != 0: elif bounces_left != 0:
bounces_left -= 1 bounces_left -= 1
look_at(position + velocity.bounce(collision.normal)) look_at(position + velocity.bounce(collision.normal))
launch(null, null) launch(null)
else: else:
explode() explode()
@ -20,6 +20,8 @@ func explode():
for body in $Area2D.get_overlapping_bodies(): for body in $Area2D.get_overlapping_bodies():
if body.get("health") != null and body.get_type() != "player": if body.get("health") != null and body.get_type() != "player":
body.health -= damage body.health -= damage
if body.has_method("play_hit"):
body.play_hit()
$Particles2D.emitting = true $Particles2D.emitting = true
$KillTimer.start() $KillTimer.start()
set_physics_process(false) set_physics_process(false)

View file

@ -37,7 +37,7 @@ func _physics_process(delta):
if collision != null: if collision != null:
on_impact(collision) on_impact(collision)
func launch(wand, effect): func launch(wand):
velocity = (Vector2(speed, 0)).rotated(rotation) velocity = (Vector2(speed, 0)).rotated(rotation)
get_wand_type(wand) get_wand_type(wand)
return energy_cost * energy_mod return energy_cost * energy_mod
@ -46,10 +46,11 @@ func on_impact(collision):
if collision.collider.has_method("get_type") && collision.collider.get_type() == "enemy": if collision.collider.has_method("get_type") && collision.collider.get_type() == "enemy":
var c = collision.collider var c = collision.collider
c.health -= damage * damage_mod c.health -= damage * damage_mod
c.play_hit()
queue_free() queue_free()
elif bounces_left != 0: elif bounces_left != 0:
bounces_left -= 1 bounces_left -= 1
look_at(position + velocity.bounce(collision.normal)) look_at(position + velocity.bounce(collision.normal))
launch(null, null) launch(null)
else: else:
queue_free() queue_free()

View file

@ -10,10 +10,11 @@ func on_impact(collision):
var c = collision.collider var c = collision.collider
c.health -= damage * damage_mod c.health -= damage * damage_mod
c.do_knockback(collision.normal) c.do_knockback(collision.normal)
c.play_hit()
queue_free() queue_free()
elif bounces_left != 0: elif bounces_left != 0:
bounces_left -= 1 bounces_left -= 1
look_at(position + velocity.bounce(collision.normal)) look_at(position + velocity.bounce(collision.normal))
launch(null, null) launch(null)
else: else:
queue_free() queue_free()

34
magic/Wands/PrismWand.gd Normal file
View file

@ -0,0 +1,34 @@
extends Wand
func _ready():
$ProjectileSpawn.add_child(Globals.ecobeam_ps.instance())
$ProjectileSpawn/EcoBeam.deactivate()
func get_beam_type(p):
if p == Globals.Magic[Globals.Projectile1]:
return $ProjectileSpawn/EcoBeam
elif p == Globals.Magic[Globals.Projectile2]:
return null
elif p == Globals.Magic[Globals.Projectile3]:
return null
elif p == Globals.Magic[Globals.Projectile4]:
return null
else:
return null
func fire(projectile):
var beam = get_beam_type(projectile)
if beam != null:
beam.activate()
if $ShootDelay.is_stopped():
$ShootDelay.start()
var c = beam.get_collider()
print(c)
if c != null and c.has_method("get_type") && c.get_type() == "enemy":
c.health -= beam.damage
return beam.energy_cost
func _input(event):
if event.is_action_released("shoot"):
for c in $ProjectileSpawn.get_children():
c.deactivate()

View file

@ -1,10 +1,10 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://art/PrismaticWand.png" type="Texture" id=1] [ext_resource path="res://art/PrismaticWand.png" type="Texture" id=1]
[ext_resource path="res://magic/Wands/WandClass.gd" type="Script" id=2] [ext_resource path="res://magic/Wands/PrismWand.gd" type="Script" id=2]
[node name="PrismWand" type="Sprite"] [node name="PrismWand" type="Sprite"]
position = Vector2( 4, 0 ) position = Vector2( 1, 0 )
rotation = 1.5708 rotation = 1.5708
texture = ExtResource( 1 ) texture = ExtResource( 1 )
offset = Vector2( 0, -10 ) offset = Vector2( 0, -10 )
@ -15,5 +15,5 @@ position = Vector2( 0, -20 )
rotation = -1.5708 rotation = -1.5708
[node name="ShootDelay" type="Timer" parent="."] [node name="ShootDelay" type="Timer" parent="."]
wait_time = 0.3 wait_time = 0.2
one_shot = true one_shot = true

View file

@ -3,7 +3,7 @@ extends Wand
func _ready(): func _ready():
wand_type = Globals.Conduit2 wand_type = Globals.Conduit2
func fire(projectile, effect): func fire(projectile):
if $ShootDelay.is_stopped() and projectile != null: if $ShootDelay.is_stopped() and projectile != null:
var temp1 = projectile.instance() var temp1 = projectile.instance()
var temp2 = projectile.instance() var temp2 = projectile.instance()
@ -14,8 +14,8 @@ func fire(projectile, effect):
temp1.global_transform = $ProjectileSpawn1.global_transform temp1.global_transform = $ProjectileSpawn1.global_transform
temp2.global_transform = $ProjectileSpawn2.global_transform temp2.global_transform = $ProjectileSpawn2.global_transform
temp3.global_transform = $ProjectileSpawn3.global_transform temp3.global_transform = $ProjectileSpawn3.global_transform
var energy_cost = temp1.launch(wand_type, effect_type) var energy_cost = temp1.launch(wand_type)
energy_cost += temp2.launch(wand_type, effect_type) energy_cost += temp2.launch(wand_type)
energy_cost += temp3.launch(wand_type, effect_type) energy_cost += temp3.launch(wand_type)
$ShootDelay.start() $ShootDelay.start()
return energy_cost return energy_cost

View file

@ -1,13 +1,12 @@
extends Sprite extends Sprite
class_name Wand class_name Wand
var wand_type var wand_type
var effect_type
func fire(projectile, effect): func fire(projectile):
if $ShootDelay.is_stopped() and projectile != null: if $ShootDelay.is_stopped() and projectile != null:
var temp = projectile.instance() var temp = projectile.instance()
get_tree().current_scene.add_child(temp) get_tree().current_scene.add_child(temp)
temp.global_transform = $ProjectileSpawn.global_transform temp.global_transform = $ProjectileSpawn.global_transform
var energy_cost = temp.launch(wand_type, effect_type) var energy_cost = temp.launch(wand_type)
$ShootDelay.start() $ShootDelay.start()
return energy_cost return energy_cost

View file

@ -161,11 +161,6 @@ inventory={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
] ]
} }
open={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":70,"unicode":0,"echo":false,"script":null)
]
}
[layer_names] [layer_names]

View file

@ -12,7 +12,7 @@ func set_current_conduit(conduit):
func _process(delta): func _process(delta):
if Input.is_action_pressed("shoot") and get_child_count() != 0 and parent.Stats.energy > 0 and not parent.Inventory.open: if Input.is_action_pressed("shoot") and get_child_count() != 0 and parent.Stats.energy > 0 and not parent.Inventory.open:
var energy_cost = get_children()[0].fire(get_parent().Inventory.active_projectile, null) var energy_cost = get_children()[0].fire(get_parent().Inventory.active_projectile)
if energy_cost != null: if energy_cost != null:
parent.energy -= energy_cost parent.energy -= energy_cost
parent.Stats.interrupt_regen() parent.Stats.interrupt_regen()

View file

@ -17,10 +17,10 @@ var projectile2_ps = preload("res://magic/Projectiles/PhantomProjectile.tscn")
var projectile3_ps = preload("res://magic/Projectiles/WaveProjectile.tscn") var projectile3_ps = preload("res://magic/Projectiles/WaveProjectile.tscn")
var projectile4_ps = preload("res://magic/Projectiles/ExplosiveProjectile.tscn") var projectile4_ps = preload("res://magic/Projectiles/ExplosiveProjectile.tscn")
var effect1_ps var ecobeam_ps = preload("res://magic/Beams/EcoBeam.tscn")
var effect2_ps var phasebeam_ps
var effect3_ps var wavebeam_ps
var effect4_ps var explosivebeam_ps
var Magic: Array = [ var Magic: Array = [
conduit1_ps, conduit1_ps,
@ -31,10 +31,6 @@ var Magic: Array = [
projectile2_ps, projectile2_ps,
projectile3_ps, projectile3_ps,
projectile4_ps, projectile4_ps,
effect1_ps,
effect2_ps,
effect3_ps,
effect4_ps,
] ]
### ###