good weapon switcher
This commit is contained in:
parent
608c4a73c7
commit
caefc9ad94
11 changed files with 237 additions and 14 deletions
|
|
@ -41,7 +41,7 @@ var speed_mul := 1.
|
|||
var gun_index := 0:
|
||||
set(v):
|
||||
gun_index = v % guns.size()
|
||||
%GunLabel.text = gun.name
|
||||
%WeaponUI.active_weapon = gun_index
|
||||
var gun: Gun:
|
||||
get: return guns[gun_index]
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,13 @@
|
|||
[ext_resource type="Script" uid="uid://fe3m1ax0w2lh" path="res://player/player_hud.gd" id="2_g6k8r"]
|
||||
[ext_resource type="Script" uid="uid://cjdxibg3pnans" path="res://player/score_label.gd" id="2_onrkg"]
|
||||
[ext_resource type="Script" uid="uid://fv1n5noqdfg2" path="res://player/guns/basic_gun.gd" id="3_g1dw6"]
|
||||
[ext_resource type="Script" uid="uid://3t2vgdd22w6g" path="res://player/weapon_ui.gd" id="4_c35mf"]
|
||||
[ext_resource type="Texture2D" uid="uid://cxig6u6fiw1dx" path="res://ui/weapons/sharpshooter.png" id="4_e7oew"]
|
||||
[ext_resource type="Script" uid="uid://b87cyvu2m5b1k" path="res://player/guns/mini_gun.gd" id="4_yw30f"]
|
||||
[ext_resource type="AudioStream" uid="uid://djrp7mwg3pbrq" path="res://sfx/freesound_community-meaty-gunshot-101257.mp3" id="5_2ieo8"]
|
||||
[ext_resource type="Texture2D" uid="uid://cl05ee526nm3u" path="res://ui/weapons/minigun.png" id="5_c35mf"]
|
||||
[ext_resource type="Script" uid="uid://ftrngxkkycl1" path="res://player/guns/mortar.gd" id="5_qjkh3"]
|
||||
[ext_resource type="Texture2D" uid="uid://bekqcc0dsvvc7" path="res://ui/weapons/explosion.png" id="6_65viv"]
|
||||
[ext_resource type="Script" uid="uid://urxp3pg8g2mh" path="res://player/health_bar.gd" id="7_boad6"]
|
||||
[ext_resource type="AudioStream" uid="uid://b42aa4bhyfv12" path="res://sfx/mortar_shot.wav" id="8_ebec5"]
|
||||
[ext_resource type="Shader" uid="uid://cf3h3knluytmm" path="res://player/hp_outline.gdshader" id="8_rgyib"]
|
||||
|
|
@ -22,6 +26,17 @@
|
|||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_4flbx"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_x7c3f"]
|
||||
offsets = PackedFloat32Array(0.44044322, 0.4903047, 0.53462607, 0.5734072)
|
||||
colors = PackedColorArray(1, 1, 1, 0.5529412, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_bjvpn"]
|
||||
gradient = SubResource("Gradient_x7c3f")
|
||||
width = 96
|
||||
height = 96
|
||||
fill = 1
|
||||
fill_from = Vector2(0.5, 0.5)
|
||||
|
||||
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_2ieo8"]
|
||||
random_pitch = 1.0594631
|
||||
random_volume_offset_db = 1.0
|
||||
|
|
@ -128,19 +143,6 @@ offset_right = 196.0
|
|||
offset_bottom = -4.0
|
||||
text = "Stamina"
|
||||
|
||||
[node name="GunLabel" type="Label" parent="PlayerHUD" unique_id=220052210]
|
||||
unique_name_in_owner = true
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -23.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "BasicGun"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Score" type="Control" parent="PlayerHUD" unique_id=1241180984]
|
||||
layout_mode = 3
|
||||
anchors_preset = 5
|
||||
|
|
@ -165,6 +167,77 @@ theme_override_font_sizes/font_size = 96
|
|||
text = "14"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="WeaponUI" type="Control" parent="PlayerHUD" unique_id=1846927607]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("4_c35mf")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="PlayerHUD/WeaponUI" unique_id=622800622]
|
||||
self_modulate = Color(1, 0.8333334, 0, 1)
|
||||
position = Vector2(97.78559, 597.8928)
|
||||
scale = Vector2(0.8906935, 0.85193384)
|
||||
texture = SubResource("GradientTexture2D_bjvpn")
|
||||
|
||||
[node name="Sharpshooter" type="Sprite2D" parent="PlayerHUD/WeaponUI/Sprite2D" unique_id=1113290106]
|
||||
position = Vector2(1.045371, -1.3996036)
|
||||
scale = Vector2(0.2772135, 0.28815705)
|
||||
texture = ExtResource("4_e7oew")
|
||||
|
||||
[node name="Label" type="Label" parent="PlayerHUD/WeaponUI/Sprite2D" unique_id=1403203983]
|
||||
offset_left = 19.96259
|
||||
offset_top = 4.274618
|
||||
offset_right = 59.96259
|
||||
offset_bottom = 43.27462
|
||||
scale = Vector2(1.0077233, 1.059216)
|
||||
theme_override_constants/outline_size = 7
|
||||
theme_override_font_sizes/font_size = 28
|
||||
text = "1"
|
||||
|
||||
[node name="Sprite2D2" type="Sprite2D" parent="PlayerHUD/WeaponUI" unique_id=1270801051]
|
||||
self_modulate = Color(0.096800014, 0.88, 0.21427989, 1)
|
||||
position = Vector2(198.7533, 597.8928)
|
||||
scale = Vector2(0.8906935, 0.85193384)
|
||||
texture = SubResource("GradientTexture2D_bjvpn")
|
||||
|
||||
[node name="Minigun" type="Sprite2D" parent="PlayerHUD/WeaponUI/Sprite2D2" unique_id=174416607]
|
||||
position = Vector2(0.9441545, -1.399601)
|
||||
scale = Vector2(0.20828299, 0.20828296)
|
||||
texture = ExtResource("5_c35mf")
|
||||
|
||||
[node name="Label2" type="Label" parent="PlayerHUD/WeaponUI/Sprite2D2" unique_id=2073572324]
|
||||
offset_left = 21.376274
|
||||
offset_top = 4.2746277
|
||||
offset_right = 61.376274
|
||||
offset_bottom = 43.274628
|
||||
scale = Vector2(1.0077233, 1.059216)
|
||||
theme_override_constants/outline_size = 7
|
||||
theme_override_font_sizes/font_size = 28
|
||||
text = "2"
|
||||
|
||||
[node name="Sprite2D3" type="Sprite2D" parent="PlayerHUD/WeaponUI" unique_id=2102311935]
|
||||
self_modulate = Color(1, 0.22000003, 0.22000003, 1)
|
||||
position = Vector2(303.00003, 598.0571)
|
||||
scale = Vector2(0.8906933, 0.8519337)
|
||||
texture = SubResource("GradientTexture2D_bjvpn")
|
||||
|
||||
[node name="Label3" type="Label" parent="PlayerHUD/WeaponUI/Sprite2D3" unique_id=1175081439]
|
||||
offset_left = 22.959694
|
||||
offset_top = 4.138611
|
||||
offset_right = 62.959694
|
||||
offset_bottom = 43.13861
|
||||
scale = Vector2(1.0077233, 1.059216)
|
||||
theme_override_constants/outline_size = 7
|
||||
theme_override_font_sizes/font_size = 28
|
||||
text = "3"
|
||||
|
||||
[node name="Explosion" type="Sprite2D" parent="PlayerHUD/WeaponUI/Sprite2D3" unique_id=1522295851]
|
||||
position = Vector2(-1.4162259, -1.4806914)
|
||||
scale = Vector2(0.2141057, 0.21290459)
|
||||
texture = ExtResource("6_65viv")
|
||||
|
||||
[node name="Guns" type="Node3D" parent="." unique_id=2018109083]
|
||||
|
||||
[node name="Sharpshooter" type="Node3D" parent="Guns" unique_id=1677055720]
|
||||
|
|
|
|||
29
player/weapon_ui.gd
Normal file
29
player/weapon_ui.gd
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
class_name WeaponUI
|
||||
extends Control
|
||||
|
||||
const DIFF = 25
|
||||
const TIME = 0.2
|
||||
|
||||
var active_weapon := 0:
|
||||
set(v):
|
||||
if v == active_weapon: return
|
||||
|
||||
get_child(active_weapon).create_tween() \
|
||||
.set_trans(Tween.TRANS_QUAD) \
|
||||
.set_ease(Tween.EASE_OUT) \
|
||||
.tween_property(get_child(active_weapon), "position", initial_positions[active_weapon], TIME)
|
||||
|
||||
active_weapon = v
|
||||
|
||||
get_child(v).create_tween() \
|
||||
.set_trans(Tween.TRANS_QUAD) \
|
||||
.set_ease(Tween.EASE_OUT) \
|
||||
.tween_property(get_child(v), "position", initial_positions[v] + Vector2.UP * DIFF, TIME)
|
||||
var initial_positions: PackedVector2Array
|
||||
|
||||
func _ready() -> void:
|
||||
for child in get_children():
|
||||
initial_positions.push_back(child.position)
|
||||
|
||||
get_child(active_weapon).position += Vector2.UP * DIFF
|
||||
|
||||
1
player/weapon_ui.gd.uid
Normal file
1
player/weapon_ui.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://3t2vgdd22w6g
|
||||
BIN
ui/weapons/explosion.png
Normal file
BIN
ui/weapons/explosion.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
40
ui/weapons/explosion.png.import
Normal file
40
ui/weapons/explosion.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bekqcc0dsvvc7"
|
||||
path="res://.godot/imported/explosion.png-05e8eb4f65eeb6e2985911aba7164e1b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://ui/weapons/explosion.png"
|
||||
dest_files=["res://.godot/imported/explosion.png-05e8eb4f65eeb6e2985911aba7164e1b.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
ui/weapons/explosion.png~
Normal file
BIN
ui/weapons/explosion.png~
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
ui/weapons/minigun.png
Normal file
BIN
ui/weapons/minigun.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
40
ui/weapons/minigun.png.import
Normal file
40
ui/weapons/minigun.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cl05ee526nm3u"
|
||||
path="res://.godot/imported/minigun.png-08566ee23e498dc24d41b1aac0912057.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://ui/weapons/minigun.png"
|
||||
dest_files=["res://.godot/imported/minigun.png-08566ee23e498dc24d41b1aac0912057.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
ui/weapons/sharpshooter.png
Normal file
BIN
ui/weapons/sharpshooter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
40
ui/weapons/sharpshooter.png.import
Normal file
40
ui/weapons/sharpshooter.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cxig6u6fiw1dx"
|
||||
path="res://.godot/imported/sharpshooter.png-a576cdc8e64e9bc56250ceb063bb1cdb.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://ui/weapons/sharpshooter.png"
|
||||
dest_files=["res://.godot/imported/sharpshooter.png-a576cdc8e64e9bc56250ceb063bb1cdb.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
Loading…
Add table
Add a link
Reference in a new issue