Beginning to update weapon components
This commit is contained in:
parent
db57a0234e
commit
e3fb082139
11 changed files with 66 additions and 37 deletions
|
|
@ -3,36 +3,29 @@ class_name ShootComponent extends Node
|
|||
@onready var weapon_component: Node = %WeaponComponent
|
||||
@onready var player: Player = $".."
|
||||
|
||||
#var travel: float = 0
|
||||
#var weapon_spacing: float = 0.1
|
||||
|
||||
|
||||
func shoot():
|
||||
|
||||
var weapon_system = weapon_component.data
|
||||
# Shorten variable for accessing weapon_component for clarity
|
||||
var weapon_system = weapon_component.data
|
||||
|
||||
if player.travel > weapon_system.spacing:
|
||||
print("Travel is greater!")
|
||||
for b in range(weapon_system.projectiles):
|
||||
|
||||
# Instantiate the bullets
|
||||
var bullet = weapon_component.weapon_current.instantiate()
|
||||
get_tree().root.add_child(bullet)
|
||||
# Adjust bullet spacing before firing
|
||||
|
||||
bullet.position = player.position + Vector2((b - (weapon_system.projectiles - 1) / 2.0) * round(round((weapon_system.projectiles + weapon_system.spacing / 2)) / 2), weapon_system.origin)
|
||||
print(b, bullet.position.x)
|
||||
## Get weapon speed and spacing for equidistant calculations - non comp
|
||||
#weapon_rate = bullet.weapon_component.bullet_data.rate
|
||||
#weapon_component.bullet_data.projectile_spacing = bullet.weapon_component.bullet_data.projectile_spacing
|
||||
#weapon_component.bullet_data.speed = bullet.weapon_component.bullet_data.speed
|
||||
|
||||
# Print which weapon is firing
|
||||
prints(bullet.shot_data.shot_name, "weapon fired")
|
||||
|
||||
# Subtract projectile spacing from current Player travel for next
|
||||
player.travel -= weapon_system.spacing
|
||||
|
||||
else: return
|
||||
if player.travel > weapon_system.spacing:
|
||||
|
||||
for b in range(weapon_system.projectiles):
|
||||
|
||||
# Instantiate the bullets
|
||||
var bullet = weapon_component.weapon_current.instantiate()
|
||||
get_tree().root.add_child(bullet)
|
||||
# Adjust bullet spacing before firing
|
||||
|
||||
bullet.position = player.position + Vector2((b - (weapon_system.projectiles - 1) / 2.0) * round(round((weapon_system.projectiles + weapon_system.spacing / 2)) / 2), weapon_system.origin)
|
||||
print(b, bullet.position.x)
|
||||
|
||||
# Print which weapon is firing
|
||||
prints(bullet.shot_data.shot_name, "weapon fired")
|
||||
|
||||
# Subtract projectile spacing from current Player travel for next
|
||||
player.travel -= weapon_system.spacing
|
||||
|
||||
else: return
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue