added weapon wheel and model texture creator
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
extends Area3D
|
||||
|
||||
@export var damage :=1
|
||||
@export var damage : float = 1
|
||||
|
||||
var damage_number = preload("res://assets/damage_number.tscn")
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ var cycle_count
|
||||
|
||||
@export_group("Gun Feel")
|
||||
@export var gun_name : String
|
||||
@export var gun_icon : Texture2D
|
||||
@export_enum("Auto", "Single", "Burst") var fire_mode: int
|
||||
@export var fov_zoom_amt = .98
|
||||
@export var ads : bool = false
|
||||
|
||||
@@ -3,6 +3,7 @@ extends Node3D
|
||||
|
||||
@export_group("Gun Feel")
|
||||
@export var gun_name : String
|
||||
@export var gun_icon : Texture2D
|
||||
@export_enum("Auto", "Single", "Burst") var fire_mode: int
|
||||
@export var hitscan_enabled : bool = false
|
||||
@export var fov_zoom_amt = .98
|
||||
|
||||
@@ -141,6 +141,7 @@ var controlled_elsewhere = false
|
||||
@onready var crouch_audio: AudioStreamPlayer3D = $Audio/Crouch
|
||||
@onready var hud: Control = $Head/Recoil/Camera3D/HUD
|
||||
@onready var clock_sound: AudioStreamPlayer = $Audio/ClockSound
|
||||
@onready var weapon_select_menu: Control = $Head/Recoil/Camera3D/WeaponSelect
|
||||
|
||||
|
||||
func _ready():
|
||||
@@ -383,7 +384,24 @@ func _physics_process(delta):
|
||||
|
||||
for i in range(10):
|
||||
if Input.is_action_just_pressed("numb_" + str(i)):
|
||||
weapon_select((i - 1))
|
||||
if gun != null:
|
||||
if !gun.anim_player.is_playing():
|
||||
if i-1 != level_control.current_gun_index and i <= level_control.held_guns.size():
|
||||
weapon_select((i - 1))
|
||||
|
||||
if Input.is_action_just_pressed("weapon_select"):
|
||||
weapon_select_menu.show()
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED_HIDDEN)
|
||||
controlled_elsewhere = true
|
||||
gamespeed_controlled = true
|
||||
Engine.time_scale = .01
|
||||
elif Input.is_action_just_released("weapon_select"):
|
||||
var selection = weapon_select_menu.close()
|
||||
if selection != null:
|
||||
weapon_select(selection)
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
controlled_elsewhere = false
|
||||
gamespeed_controlled = false
|
||||
|
||||
#interact button
|
||||
if Input.is_action_just_pressed("interact"):
|
||||
@@ -539,13 +557,8 @@ func weapon_bob(vel : float, delta):
|
||||
weapon_holder.position.x = lerp(weapon_holder.position.x, def_weapon_holder_pos.x, .1 * delta)
|
||||
|
||||
func weapon_select(gun_id):
|
||||
if gun != null:
|
||||
if !gun.anim_player.is_playing():
|
||||
if level_control.held_guns.size() >= (gun_id + 1) and level_control.current_gun_index != gun_id:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(gun_id)
|
||||
else:
|
||||
level_control.gun_spawn(gun_id)
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(gun_id)
|
||||
|
||||
func enemy_hit():
|
||||
var hitmarker_spawn = hitmarker.instantiate()
|
||||
|
||||
@@ -8,6 +8,7 @@ var cycle_count
|
||||
|
||||
@export_group("Gun Feel")
|
||||
@export var gun_name : String
|
||||
@export var gun_icon : Texture2D
|
||||
@export_enum("Auto", "Single", "Burst") var fire_mode: int
|
||||
@export var fov_zoom_amt = .98
|
||||
@export var ads : bool = false
|
||||
|
||||
@@ -9,6 +9,7 @@ var ads = false
|
||||
|
||||
@export_group("Gun Feel")
|
||||
@export var gun_name : String
|
||||
@export var gun_icon : Texture2D
|
||||
@export_enum("Auto", "Single", "Burst") var fire_mode: int
|
||||
@export var fov_zoom_amt = .98
|
||||
@export var recoil_amount : Vector3 = Vector3(.2,0,0)
|
||||
|
||||
@@ -8,3 +8,4 @@ signal king_killed()
|
||||
signal enemy_count_changed()
|
||||
signal game_loaded()
|
||||
signal player_hit()
|
||||
signal weapon_list_changed()
|
||||
|
||||
22
scripts/texture_catcher.gd
Normal file
22
scripts/texture_catcher.gd
Normal file
@@ -0,0 +1,22 @@
|
||||
@tool
|
||||
extends Node3D
|
||||
|
||||
@onready var sub_viewport: SubViewport = $CAPTURE/SubViewport
|
||||
@onready var snapshot_model: Node3D = $CAPTURE/SubViewport/snapshotModel
|
||||
|
||||
@export var take_snapshot : bool = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if take_snapshot:
|
||||
var snapshot_name = snapshot_model.get_child(0).get_name()
|
||||
await get_tree().create_timer(.5).timeout
|
||||
var img = sub_viewport.get_viewport().get_texture().get_image()
|
||||
var image_path = "assets/Textures/ObjectTextures/%s.png" % snapshot_name
|
||||
img.save_png(image_path)
|
||||
take_snapshot = false
|
||||
@@ -3,6 +3,7 @@ extends Node3D
|
||||
|
||||
@export_group("Gun Feel")
|
||||
@export var gun_name : String
|
||||
@export var gun_icon : Texture2D
|
||||
@export_enum("Auto", "Single", "Burst") var fire_mode: int
|
||||
@export var hitscan_enabled : bool = false
|
||||
@export var ads : bool = false
|
||||
|
||||
@@ -32,6 +32,7 @@ func picked_up():
|
||||
if level_control.player.gun != null:
|
||||
level_control.player.gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(weapon_id)
|
||||
SignalBus.emit_signal("weapon_list_changed")
|
||||
queue_free()
|
||||
|
||||
func save():
|
||||
|
||||
103
scripts/weapon_select.gd
Normal file
103
scripts/weapon_select.gd
Normal file
@@ -0,0 +1,103 @@
|
||||
#@tool
|
||||
extends Control
|
||||
|
||||
@export var outer_radius : int = 256
|
||||
@export var inner_radius : int = 256
|
||||
@export var line_width : int = 4
|
||||
|
||||
var options = []
|
||||
|
||||
@onready var level_control = get_tree().current_scene
|
||||
|
||||
const bkg_color : Color = Color(1, 1, 1, .5)
|
||||
const line_color : Color = Color(1,1,1)
|
||||
const select_color = Color(1, 1, 1, .5)
|
||||
const IMAGE_SIZE = Vector2(512,512)
|
||||
|
||||
|
||||
var selection
|
||||
|
||||
func close():
|
||||
hide()
|
||||
return selection
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
update_weapon_list()
|
||||
SignalBus.weapon_list_changed.connect(update_weapon_list)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
|
||||
var mouse_pos = get_local_mouse_position()
|
||||
var mouse_radius = mouse_pos.length()
|
||||
|
||||
if mouse_radius < inner_radius:
|
||||
selection = null
|
||||
else:
|
||||
var mouse_rads = fposmod(mouse_pos.angle() * -1, TAU)
|
||||
selection = ceil((mouse_rads / TAU) * (len(options)+1))
|
||||
|
||||
|
||||
|
||||
queue_redraw()
|
||||
|
||||
func _draw():
|
||||
var offset = IMAGE_SIZE/ -2
|
||||
|
||||
if selection == null:
|
||||
draw_circle(Vector2.ZERO,inner_radius,select_color)
|
||||
|
||||
|
||||
draw_circle(Vector2.ZERO, outer_radius, bkg_color)
|
||||
draw_arc(Vector2.ZERO,inner_radius,0, TAU, 128,line_color,line_width,true)
|
||||
|
||||
if len(options) >= 1:
|
||||
|
||||
# draw separator lines
|
||||
for i in range(len(options)):
|
||||
var rads = TAU * i / (len(options))
|
||||
var point = Vector2.from_angle(rads)
|
||||
draw_line(
|
||||
point * inner_radius,
|
||||
point * outer_radius,
|
||||
line_color,
|
||||
line_width,
|
||||
true
|
||||
)
|
||||
|
||||
for i in range(0,len(options)):
|
||||
var start_rads = (TAU * (i-1)) / (len(options))
|
||||
var end_rads = (TAU * i) / (len(options))
|
||||
var mid_rads = (start_rads + end_rads)/2.0 * -1
|
||||
var radius_mid = (inner_radius + outer_radius) / 2
|
||||
|
||||
var draw_pos = radius_mid * Vector2.from_angle(mid_rads) + offset
|
||||
|
||||
var object = options[i].instantiate()
|
||||
var texture = object.gun_icon
|
||||
|
||||
if selection == i:
|
||||
var points_per_arc = 32
|
||||
var points_inner = PackedVector2Array()
|
||||
var points_outer = PackedVector2Array()
|
||||
|
||||
for j in range(points_per_arc + 1):
|
||||
var angle = start_rads + j * (end_rads - start_rads) / points_per_arc
|
||||
points_inner.append(inner_radius * Vector2.from_angle(TAU-angle))
|
||||
points_outer.append(outer_radius * Vector2.from_angle(TAU-angle))
|
||||
|
||||
points_outer.reverse()
|
||||
draw_polygon(
|
||||
points_inner + points_outer,
|
||||
PackedColorArray([select_color])
|
||||
)
|
||||
|
||||
draw_texture(
|
||||
texture,
|
||||
Vector2(draw_pos)
|
||||
)
|
||||
|
||||
func update_weapon_list():
|
||||
options = level_control.held_guns
|
||||
Reference in New Issue
Block a user