forked from team-sg/hero-mark-2
the damage system refactor!
killing is now done based on groups, the same way enemies already killed the player. these groups go on the entity's hitbox, not the entity itself. enemies' hitboxes have all been put in "enemy_hitbox" the arrow_projectile has a variable for the target group, so it could easily be simply set to "player" for arrows shot by enemies blocking is also done with groups. any hitbox with "blocks_arrow" will block arrows, same with "blocks_sword" and "blocks_squash"
This commit is contained in:
parent
5a02d02ceb
commit
a2974d8dd3
14 changed files with 102 additions and 66 deletions
|
@ -1,5 +1,7 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
const ArrowProjectile = preload("res://objects/player/arrow_projectile.tscn")
|
||||
|
||||
##CLEAN UP CODE LATER
|
||||
##Children
|
||||
onready var sprite = $Sprite
|
||||
|
@ -30,7 +32,6 @@ var can_move_in_air = false
|
|||
#Positions
|
||||
var arrowpos = Vector2(5,3)
|
||||
##Preload
|
||||
var pre_arrow = preload("res://objects/player/arrow_projectile.tscn")
|
||||
|
||||
#Set initial respawn point
|
||||
func _ready():
|
||||
|
@ -187,7 +188,13 @@ func _process_shoot():
|
|||
|
||||
func spawn_arrow():
|
||||
Game.play_sound(Game.a_shoot,Game.ac_jump)
|
||||
Game.instance_node(pre_arrow,global_position.x+(arrowpos.x*sprite.scale.x),global_position.y+arrowpos.y,map)
|
||||
var arrow = ArrowProjectile.instance()
|
||||
arrow.global_position = Vector2(
|
||||
global_position.x + arrowpos.x * sprite.scale.x,
|
||||
global_position.y + arrowpos.y
|
||||
)
|
||||
arrow.direction = sprite.scale.x
|
||||
map.add_child(arrow)
|
||||
|
||||
func check_jump():
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
|
@ -291,3 +298,15 @@ func _on_AnimationPlayer_animation_finished(anim_name):
|
|||
else:
|
||||
current_state = State.FALL
|
||||
return
|
||||
|
||||
|
||||
func _on_SwordArea_area_entered(area):
|
||||
if area.is_in_group("enemy_hitbox"):
|
||||
var target = area.get_parent()
|
||||
# create block text and return if blocked
|
||||
if area.is_in_group("blocks_sword"):
|
||||
var pos = target.global_position
|
||||
Game.instance_node(Game.block_text, pos.x, pos.y, target.get_parent())
|
||||
return
|
||||
else:
|
||||
target.die()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue