instancing start gun and assigned ammo to array
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
var current_weapon = null
|
||||
var weapon_stack = []
|
||||
var weapon_indicator = 0
|
||||
@@ -7,10 +8,38 @@ var next_weapon : String
|
||||
var weapon_list = {}
|
||||
|
||||
@export var weapon_resources : Array[weapon_resource]
|
||||
=======
|
||||
@export var player : Node
|
||||
@export var gun_1 : Resource
|
||||
@export var gun_2 : Resource
|
||||
var held_guns = []
|
||||
var ammo_current = [0,0]
|
||||
var ammo_reserve = [0,0]
|
||||
var guns_dict = {}
|
||||
var current_gun_index
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass
|
||||
held_guns = [gun_1,gun_2]
|
||||
|
||||
var instance_gun = held_guns[0].instantiate()
|
||||
var instance_gun_2 = held_guns[1].instantiate()
|
||||
ammo_current[1] = instance_gun_2.max_ammo
|
||||
ammo_reserve[1] = instance_gun_2.max_ammo * instance_gun_2.start_mags
|
||||
|
||||
ammo_current[0] = instance_gun.max_ammo
|
||||
ammo_reserve[0] = instance_gun.max_ammo * instance_gun.start_mags
|
||||
print(ammo_current)
|
||||
print(ammo_reserve)
|
||||
instance_gun.global_transform.origin = player.weapon_spawner.position
|
||||
player.gun = instance_gun
|
||||
player.def_weapon_holder_pos = player.weapon_holder.position
|
||||
player.ammo = player.gun.max_ammo
|
||||
player.ammo_reserve = player.gun.max_ammo * player.gun.start_mags
|
||||
player.gun_fire_pitch_starting = player.gun.audio_fire.pitch_scale
|
||||
current_gun_index = 0
|
||||
player.weapon_holder.add_child(instance_gun)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
|
||||
@@ -36,13 +36,16 @@ var cycle_count
|
||||
|
||||
@onready var player = $"../../../../"
|
||||
var rng = RandomNumberGenerator.new()
|
||||
var level_control
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
start_position = self.position
|
||||
start_rotation = self.rotation
|
||||
random_spread_start = random_spread_amt
|
||||
|
||||
|
||||
level_control = get_tree().get_root()
|
||||
|
||||
if fire_mode == 0:
|
||||
cycle_count = 1
|
||||
cycle_count_start = 1
|
||||
@@ -103,7 +106,7 @@ func shoot(player,delta):
|
||||
instance_casing.transform.basis = casing_ejector.global_transform.basis
|
||||
get_tree().get_root().add_child(instance_casing)
|
||||
|
||||
if fire_mode == 1 or fire_mode == 2:
|
||||
if fire_mode != 0:
|
||||
cycle_count -= 1
|
||||
|
||||
elif !anim_player.is_playing() and cycle_count != 0:
|
||||
|
||||
@@ -72,17 +72,6 @@ func _ready():
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
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:
|
||||
@@ -269,8 +258,8 @@ func weapon_tilt(input_x, delta):
|
||||
|
||||
func weapon_sway(delta):
|
||||
mouse_input = lerp(mouse_input, Vector2.ZERO, 10 * delta)
|
||||
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, mouse_input.y * weapon_rotation_amount, 1 * delta)
|
||||
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, mouse_input.x * weapon_rotation_amount, 1 * delta)
|
||||
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, mouse_input.y * weapon_rotation_amount, 5 * delta)
|
||||
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, mouse_input.x * weapon_rotation_amount, 5 * delta)
|
||||
|
||||
#crosshair.position.x = lerp(crosshair.position.x, mouse_input.x * 100, 2 * delta)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user