Made kamikaze behavior and also fixed borders
This commit is contained in:
parent
ac263a1e65
commit
1ee0b529a8
10 changed files with 41 additions and 44 deletions
|
|
@ -52,9 +52,12 @@ func _physics_process(_delta):
|
|||
ship.rotation = rotation
|
||||
scalar_velocity = linear_velocity.length()
|
||||
|
||||
func _on_body_entered(_body):
|
||||
func _on_body_entered(body):
|
||||
if scalar_velocity >= velocity_collision_treshold:
|
||||
ship.shield.deal_damage(20.0 * (scalar_velocity / velocity_collision_treshold))
|
||||
var damage = collision_damage * (scalar_velocity / velocity_collision_treshold)
|
||||
ship.shield.deal_damage(damage)
|
||||
if body is Ship:
|
||||
body.shield.deal_damage(damage / 2)
|
||||
|
||||
func warp_to_position(location: Vector2):
|
||||
position = location
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ func _ready() -> void:
|
|||
destroyed.connect(destroy_timeout)
|
||||
|
||||
func destroy_timeout():
|
||||
get_tree().create_timer(0.02).timeout.connect(destroy)
|
||||
destroy()
|
||||
get_tree().create_timer(0.05).timeout.connect(hull.warp_to_position.bind(spawn_position))
|
||||
|
||||
## Reset all required variables
|
||||
func destroy() -> void:
|
||||
|
|
@ -32,7 +33,6 @@ func destroy() -> void:
|
|||
hull.linear_velocity = Vector2.ZERO
|
||||
hull.angular_velocity = 0.0
|
||||
shield.capacity = shield.max_capacity
|
||||
hull.warp_to_position(spawn_position)
|
||||
|
||||
## Swaps old hull with the new one
|
||||
func change_hull(new_hull_id: String) -> void:
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ extends Node2D
|
|||
## Shortcut to get_parent()
|
||||
@onready var ship: Ship = get_parent()
|
||||
## List of weapons
|
||||
@onready var list: Array[Node] = get_children() as Array[Node]
|
||||
@onready var list: Array[Node] = get_children()
|
||||
|
||||
## Updates list with actual children of this node
|
||||
func update_weapon_list() -> void:
|
||||
list = get_children() as Array[Node]
|
||||
list = get_children()
|
||||
|
||||
## Removes weapon with given ID
|
||||
func remove_weapon(id: String) -> void:
|
||||
|
|
@ -25,8 +25,8 @@ func add_weapon(_id: String) -> void:
|
|||
pass
|
||||
|
||||
## Returns a reference to weapon with given id if it exists, otherwise returns null
|
||||
func get_weapon(id: String) -> Weapon:
|
||||
func get_weapon(id: String) -> Node:
|
||||
for weapon in list:
|
||||
if weapon.id == id:
|
||||
return weapon as Weapon
|
||||
return weapon
|
||||
return null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue