forked from team-sg/hero-mark-2
player.tscn: scholar of the first bullet casings
This commit is contained in:
parent
79cbd62a69
commit
bc57ba4171
45 changed files with 1429 additions and 113 deletions
|
@ -4,7 +4,7 @@ onready var raycast = $Rotation/RayCast2D
|
|||
onready var anims = $AnimationPlayer
|
||||
|
||||
func _on_Sight_area_entered(area):
|
||||
if area.is_in_group("player"):
|
||||
if area.is_in_group("player_hitbox"):
|
||||
anims.play("lunge")
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||
|
|
23
objects/enemy/bullet_casing.tscn
Normal file
23
objects/enemy/bullet_casing.tscn
Normal file
|
@ -0,0 +1,23 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://graphics/particles/bullet_casing.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id=4]
|
||||
bounce = 0.75
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 1, 1.5 )
|
||||
|
||||
[node name="BoneParticle" type="RigidBody2D"]
|
||||
collision_layer = 16
|
||||
physics_material_override = SubResource( 4 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 0, 0.5 )
|
||||
shape = SubResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_group_": true
|
||||
}
|
|
@ -25,6 +25,7 @@ var turns = 0
|
|||
|
||||
const BoneParticle = preload("res://objects/enemy/bone_particle.tscn")
|
||||
const EasyBullet = preload("res://objects/enemy/roboturret_proj.tscn")
|
||||
const BulletCasing = preload("res://objects/enemy/bullet_casing.tscn")
|
||||
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
|
@ -44,7 +45,7 @@ func _physics_process(delta):
|
|||
if !shooting:
|
||||
# check for player in raycast
|
||||
var collider = shoot_cast.get_collider()
|
||||
if collider != null && (collider.is_in_group("player") or collider.is_in_group("msx")):
|
||||
if collider != null && (collider.is_in_group("player_hitbox") or collider.is_in_group("msx")):
|
||||
if Game.get_sector(global_position) == Game.get_sector(collider.global_position):
|
||||
if Game.is_easy_mode:
|
||||
var easy_bullet = EasyBullet.instance()
|
||||
|
@ -56,13 +57,16 @@ func _physics_process(delta):
|
|||
else:
|
||||
# kill player and enter shooting state temporarily
|
||||
collider.get_parent().die()
|
||||
|
||||
# play sound
|
||||
Audio.play_sound(Audio.a_die_robot, Audio.ac_boss)
|
||||
|
||||
# muzzle flash
|
||||
muzzle_flash.emitting = true
|
||||
shooting = true
|
||||
get_tree().create_timer(0.5, false).connect("timeout", self, "_stop_shoot")
|
||||
sprite.play("shoot")
|
||||
|
||||
# check other raycast to find collision passing through player
|
||||
graphics_cast.force_raycast_update()
|
||||
var hit_position = graphics_cast.to_global(Vector2(256.0, 0.0))
|
||||
|
@ -76,6 +80,16 @@ func _physics_process(delta):
|
|||
# move and play sparks
|
||||
sparks.global_position = hit_position
|
||||
sparks.emitting = true
|
||||
|
||||
# spawn a bullet casing
|
||||
var casing = BulletCasing.instance()
|
||||
casing.rotation = rand_range(0.0, 2.0*PI) # random rotation
|
||||
casing.global_position = shoot_position.global_position
|
||||
casing.linear_velocity = Vector2(45.0 * rand_range(0.5, 1.5), 0.0).rotated(rand_range(-PI, 0.0))
|
||||
casing.angular_velocity = rand_range(-PI*2.0, PI*2.0)
|
||||
var timer = get_tree().create_timer(3.0 + rand_range(0.0, 1.0), false)
|
||||
timer.connect("timeout", casing, "queue_free")
|
||||
get_parent().call_deferred("add_child", casing)
|
||||
return
|
||||
|
||||
# if there aren't turns, walk around
|
||||
|
|
|
@ -26,7 +26,7 @@ var death_blood_offset = Vector2.ZERO
|
|||
|
||||
func _on_Hitbox_area_entered(area):
|
||||
#Kill player
|
||||
if area.is_in_group("player"):
|
||||
if area.is_in_group("player_hitbox"):
|
||||
area.get_parent().die()
|
||||
|
||||
func die():
|
||||
|
|
|
@ -32,7 +32,7 @@ func _physics_process(delta):
|
|||
else: move_up_and_down(delta)
|
||||
#Speed up if in raycast
|
||||
if raycast.get_collider() != null:
|
||||
if raycast.get_collider().is_in_group("player"):
|
||||
if raycast.get_collider().is_in_group("player_hitbox"):
|
||||
go_fast = true
|
||||
timer.set_wait_time(0.5)
|
||||
timer.start()
|
||||
|
|
|
@ -25,7 +25,7 @@ func _physics_process(delta):
|
|||
sparks.emitting = true
|
||||
|
||||
var collider = cast.get_collider()
|
||||
if collider.is_in_group("player") or collider.is_in_group("msx"):
|
||||
if collider.is_in_group("player_hitbox") or collider.is_in_group("msx"):
|
||||
collider.get_parent().die()
|
||||
else:
|
||||
line.visible = false
|
||||
|
|
|
@ -18,7 +18,7 @@ func _on_Hitbox_area_entered(area):
|
|||
if area.is_in_group("explosion"):
|
||||
var timer = get_tree().create_timer(0.2, false)
|
||||
timer.connect("timeout", self, "die")
|
||||
if area.is_in_group("player"):
|
||||
if area.is_in_group("player_hitbox"):
|
||||
die()
|
||||
|
||||
func die():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue