add weapon switcher; todo: ammo
This commit is contained in:
parent
045faf2333
commit
53b8cf6118
5 changed files with 33 additions and 4 deletions
|
|
@ -5,7 +5,7 @@ func fire(aim_angle: float) -> void:
|
|||
var dir := Vector3.RIGHT.rotated(Vector3.UP, aim_angle)
|
||||
var player_projectile: PlayerProjectile = preload("res://player/projectile/player_projectile.tscn").instantiate()
|
||||
player_projectile.init(dir)
|
||||
player_projectile.damage = 5
|
||||
player_projectile.damage = 4
|
||||
player_projectile.can_hit_weak_points = false
|
||||
player_projectile.global_position = global_position + Vector3.UP * 0.5
|
||||
get_tree().current_scene.add_child(player_projectile)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,13 @@ var state := State.NORMAL
|
|||
var dash_direction: Vector2
|
||||
var stamina := 1.0
|
||||
|
||||
@onready var gun: Gun = %Mortar
|
||||
@export var guns: Array[Gun]
|
||||
var gun_index := 0:
|
||||
set(v):
|
||||
gun_index = v % guns.size()
|
||||
%GunLabel.text = gun.name
|
||||
var gun: Gun:
|
||||
get: return guns[gun_index]
|
||||
|
||||
func _init() -> void:
|
||||
instance = self
|
||||
|
|
@ -122,6 +128,9 @@ func _process(delta: float) -> void:
|
|||
|
||||
damage_clock -= delta
|
||||
|
||||
if Input.is_action_just_pressed("swap_weapons"):
|
||||
gun_index += 1
|
||||
|
||||
func damage(damager: Node3D) -> void:
|
||||
if state == State.DASHING:
|
||||
damager.queue_free()
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@ size = Vector3(2, 0.1, 0.1)
|
|||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_4flbx"]
|
||||
|
||||
[node name="Player" type="CharacterBody3D" unique_id=1904432250]
|
||||
[node name="Player" type="CharacterBody3D" unique_id=1904432250 node_paths=PackedStringArray("guns")]
|
||||
collision_layer = 2
|
||||
collision_mask = 13
|
||||
script = ExtResource("1_4flbx")
|
||||
shake_noise = SubResource("FastNoiseLite_onrkg")
|
||||
guns = [NodePath("Guns/BasicGun"), NodePath("Guns/MiniGun"), NodePath("Guns/Mortar")]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=204505475]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
|
|
@ -90,6 +91,19 @@ offset_right = 196.0
|
|||
offset_bottom = -4.0
|
||||
text = "Stamina"
|
||||
|
||||
[node name="GunLabel" type="Label" parent="CanvasLayer" 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="Guns" type="Node3D" parent="." unique_id=2018109083]
|
||||
|
||||
[node name="BasicGun" type="Node3D" parent="Guns" unique_id=1677055720]
|
||||
|
|
@ -104,4 +118,4 @@ fire_rate = 800.0
|
|||
[node name="Mortar" type="Node3D" parent="Guns" unique_id=1321220525]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("5_qjkh3")
|
||||
fire_rate = 250.0
|
||||
fire_rate = 160.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue