About to start work on gun swapper #checkpoint
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
extends Node3D
|
||||
|
||||
@export var player : Node
|
||||
@export var gun_1 : Resource
|
||||
@export var gun_2 : Resource
|
||||
var held_guns = [gun_1,gun_2]
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
var instance_loop_times = held_guns.length()
|
||||
while instance_loop_times > -1:
|
||||
held_guns[instance_loop_times]
|
||||
|
||||
instance_loop_times -= 1
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
|
||||
@@ -60,16 +60,15 @@ func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_gun_anims_animation_finished(anim_name):
|
||||
if anim_name == "reload":
|
||||
if player.ammo_reserve >= max_ammo:
|
||||
player.ammo += max_ammo
|
||||
player.ammo_reserve -= max_ammo
|
||||
player.reloading = false
|
||||
else:
|
||||
player.ammo += player.ammo_reserve
|
||||
player.ammo_reserve -= player.ammo_reserve
|
||||
player.reloading = false
|
||||
func reload_finished():
|
||||
if player.ammo_reserve >= max_ammo:
|
||||
player.ammo += max_ammo
|
||||
player.ammo_reserve -= max_ammo
|
||||
player.reloading = false
|
||||
else:
|
||||
player.ammo += player.ammo_reserve
|
||||
player.ammo_reserve -= player.ammo_reserve
|
||||
player.reloading = false
|
||||
|
||||
func shoot(player,delta):
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ var y_magnet
|
||||
var z_magnet
|
||||
@export var pickupType: String
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
rand_amt = rng.randf_range(10.0,100.0)
|
||||
|
||||
@@ -73,11 +73,16 @@ func _ready():
|
||||
start_sensitivity = SENSITIVITY
|
||||
|
||||
#Set up gun variables
|
||||
var instance_gun = level_control.gun_1.instantiate()
|
||||
instance_gun.global_transform.origin = weapon_spawner.position
|
||||
gun = instance_gun
|
||||
def_weapon_holder_pos = weapon_holder.position
|
||||
ammo = gun.max_ammo
|
||||
ammo_reserve = gun.max_ammo * gun.start_mags
|
||||
bullet_damage = gun.bullet_damage
|
||||
gun_fire_pitch_starting = gun.audio_fire.pitch_scale
|
||||
weapon_holder.add_child(instance_gun)
|
||||
|
||||
|
||||
#turn off audio if unchecked in player
|
||||
if AUDIO == false:
|
||||
@@ -254,6 +259,7 @@ func _on_pick_up_detection_body_entered(body):
|
||||
|
||||
func _on_pick_up_magnet_body_entered(body):
|
||||
if body.is_in_group("pickup"):
|
||||
body.collision_shape.disabled = true
|
||||
var pickup_direction = self.global_position - body.global_position
|
||||
body.linear_velocity += pickup_direction * 5
|
||||
|
||||
|
||||
Reference in New Issue
Block a user