added player Finite State Machine
This commit is contained in:
30
PCs/FSM/building_state.gd
Normal file
30
PCs/FSM/building_state.gd
Normal file
@@ -0,0 +1,30 @@
|
||||
class_name BuildingState
|
||||
extends HeroState
|
||||
|
||||
@export var swap_state: HeroState
|
||||
|
||||
|
||||
func enter_state() -> void:
|
||||
hero.edit_tool.enabled = true
|
||||
hero.game_manager.level.enable_non_path_tower_frames()
|
||||
|
||||
|
||||
func exit_state() -> void:
|
||||
hero.edit_tool.interact_key_held = false
|
||||
hero.edit_tool.enabled = false
|
||||
hero.game_manager.level.disable_all_tower_frames()
|
||||
|
||||
|
||||
func process_state(_delta: float) -> void:
|
||||
hero.check_world_button()
|
||||
if Input.is_action_just_pressed("Primary Fire"):
|
||||
hero.edit_tool.interact_key_held = true
|
||||
if Input.is_action_just_released("Primary Fire"):
|
||||
hero.edit_tool.interact_key_held = false
|
||||
if Input.is_action_just_pressed("Swap Weapons"):
|
||||
state_changed.emit(swap_state)
|
||||
if Input.is_action_pressed("Ready"):
|
||||
if hero.ready_state:
|
||||
hero.unready_self()
|
||||
else:
|
||||
hero.ready_self()
|
||||
1
PCs/FSM/building_state.gd.uid
Normal file
1
PCs/FSM/building_state.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b5h7jfwkyokes
|
||||
66
PCs/FSM/carding_state.gd
Normal file
66
PCs/FSM/carding_state.gd
Normal file
@@ -0,0 +1,66 @@
|
||||
class_name CardingState
|
||||
extends HeroState
|
||||
|
||||
@export var swap_state: HeroState
|
||||
|
||||
|
||||
func enter_state() -> void:
|
||||
hero.set_card_elements_visibility(true)
|
||||
hero.left_hand.visible = true
|
||||
hero.carding_tool.enabled = true
|
||||
|
||||
|
||||
func exit_state() -> void:
|
||||
hero.set_card_elements_visibility(false)
|
||||
hero.left_hand.visible = false
|
||||
hero.carding_tool.enabled = false
|
||||
|
||||
|
||||
func process_state(_delta: float) -> void:
|
||||
hero.check_world_button()
|
||||
if Input.is_action_just_pressed("Interact"):
|
||||
hero.carding_tool.interact()
|
||||
if Input.is_action_just_pressed("Primary Fire"):
|
||||
hero.equip_weapon(0)
|
||||
if Input.is_action_just_pressed("Secondary Fire"):
|
||||
hero.equip_weapon(1)
|
||||
if Input.is_action_just_pressed("Select Next Card") and hero.hand.size > 1:
|
||||
hero.increment_selected()
|
||||
hero.swap_card_audio.play()
|
||||
if Input.is_action_just_pressed("Select Previous Card") and hero.hand.size > 1:
|
||||
hero.decrement_selected()
|
||||
hero.swap_card_audio.play()
|
||||
if Input.is_action_just_pressed("Equip 1"):
|
||||
swap_to_slot(1)
|
||||
if Input.is_action_just_pressed("Equip 2"):
|
||||
swap_to_slot(2)
|
||||
if Input.is_action_just_pressed("Equip 3"):
|
||||
swap_to_slot(3)
|
||||
if Input.is_action_just_pressed("Equip 4"):
|
||||
swap_to_slot(4)
|
||||
if Input.is_action_just_pressed("Equip 5"):
|
||||
swap_to_slot(5)
|
||||
if Input.is_action_just_pressed("Equip 6"):
|
||||
swap_to_slot(6)
|
||||
if Input.is_action_just_pressed("Equip 7"):
|
||||
swap_to_slot(7)
|
||||
if Input.is_action_just_pressed("Equip 8"):
|
||||
swap_to_slot(8)
|
||||
if Input.is_action_just_pressed("Equip 9"):
|
||||
swap_to_slot(9)
|
||||
if Input.is_action_just_pressed("Equip 10"):
|
||||
swap_to_slot(10)
|
||||
if Input.is_action_just_pressed("Swap Weapons"):
|
||||
state_changed.emit(swap_state)
|
||||
if Input.is_action_pressed("Ready"):
|
||||
if hero.ready_state:
|
||||
hero.unready_self()
|
||||
else:
|
||||
hero.ready_self()
|
||||
|
||||
|
||||
func swap_to_slot(num: int) -> void:
|
||||
if hero.unique_cards.size() >= num:
|
||||
hero.hand_selected_index = num - 1
|
||||
hero.swap_card_audio.play()
|
||||
hero.update_selected_box()
|
||||
1
PCs/FSM/carding_state.gd.uid
Normal file
1
PCs/FSM/carding_state.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cjdv1onyfej0m
|
||||
57
PCs/FSM/fighting_state.gd
Normal file
57
PCs/FSM/fighting_state.gd
Normal file
@@ -0,0 +1,57 @@
|
||||
class_name FightingState
|
||||
extends HeroState
|
||||
|
||||
|
||||
func enter_state() -> void:
|
||||
if hero.weapons[hero.equipped_weapon]:
|
||||
hero.hud.set_energy_visible(true)
|
||||
var offhand_weapon: Weapon = hero.weapons[0] if hero.equipped_weapon == 1 else hero.weapons[1]
|
||||
if offhand_weapon:
|
||||
offhand_weapon.current_energy = offhand_weapon.max_energy
|
||||
if (!hero.weapons[hero.equipped_weapon] and offhand_weapon) or (hero.weapons[0] and hero.equipped_weapon == 1):
|
||||
hero.swap_weapons()
|
||||
if hero.weapons[hero.equipped_weapon]:
|
||||
hero.weapons[hero.equipped_weapon].current_energy = hero.weapons[hero.equipped_weapon].max_energy
|
||||
#this had to be commented out coz the new energy bar thinks "energy changed" is "energy used"
|
||||
#weapons[equipped_weapon].energy_changed.emit(weapons[equipped_weapon].current_energy)
|
||||
hero.weapon_swap_timer.start()
|
||||
hero.hud.primary_duration.visible = false
|
||||
hero.hud.secondary_duration.visible = false
|
||||
hero.hud.energy_label.visible = false
|
||||
|
||||
|
||||
func exit_state() -> void:
|
||||
if hero.weapons[hero.equipped_weapon]:
|
||||
hero.weapons[hero.equipped_weapon].release_trigger()
|
||||
hero.weapons[hero.equipped_weapon].release_second_trigger()
|
||||
hero.weapons[hero.equipped_weapon].visible = false
|
||||
hero.hud.set_energy_visible(false)
|
||||
hero.hud.grow_wave_start_label()
|
||||
hero.hud.primary_duration.visible = true
|
||||
hero.hud.secondary_duration.visible = true
|
||||
hero.hud.energy_label.visible = true
|
||||
|
||||
|
||||
func process_state(_delta: float) -> void:
|
||||
if hero.weapons[hero.equipped_weapon] and hero.weapons_active:
|
||||
if Input.is_action_just_pressed("Primary Fire"):
|
||||
hero.weapons[hero.equipped_weapon].hold_trigger()
|
||||
if Input.is_action_just_released("Primary Fire"):
|
||||
hero.weapons[hero.equipped_weapon].release_trigger()
|
||||
if Input.is_action_pressed("Secondary Fire"):
|
||||
hero.weapons[hero.equipped_weapon].hold_second_trigger()
|
||||
if Input.is_action_just_released("Secondary Fire"):
|
||||
hero.weapons[hero.equipped_weapon].release_second_trigger()
|
||||
if Input.is_action_pressed("Primary Fire"):
|
||||
hero.movement.can_sprint = false
|
||||
if Input.is_action_pressed("Secondary Fire"):
|
||||
hero.movement.can_sprint = false
|
||||
if Input.is_action_just_pressed("Equip Primary Weapon"):
|
||||
if hero.equipped_weapon == 1 and hero.weapons[0]:
|
||||
hero.swap_weapons()
|
||||
if Input.is_action_just_pressed("Equip Secondary Weapon"):
|
||||
if hero.equipped_weapon == 0 and hero.weapons[1]:
|
||||
hero.swap_weapons()
|
||||
if Input.is_action_just_pressed("Swap Weapons"):
|
||||
if hero.weapons[0] and hero.weapons[1]:
|
||||
hero.swap_weapons()
|
||||
1
PCs/FSM/fighting_state.gd.uid
Normal file
1
PCs/FSM/fighting_state.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cf7m4yyiqhhru
|
||||
20
PCs/FSM/hero_state.gd
Normal file
20
PCs/FSM/hero_state.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
class_name HeroState
|
||||
extends Node
|
||||
|
||||
@warning_ignore("unused_signal")
|
||||
signal state_changed(new_state: HeroState)
|
||||
|
||||
@export var hero: Hero
|
||||
|
||||
|
||||
func enter_state() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func exit_state() -> void:
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func process_state(delta: float) -> void:
|
||||
pass
|
||||
1
PCs/FSM/hero_state.gd.uid
Normal file
1
PCs/FSM/hero_state.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cl8ovljfiagxv
|
||||
@@ -6,13 +6,11 @@ extends Node3D
|
||||
@export var wall_preview: TowerBase
|
||||
@export var progress_bar: TextureProgressBar
|
||||
|
||||
var enabled: bool = true
|
||||
var enabled: bool = false
|
||||
var level: Level
|
||||
var point: FlowNode
|
||||
var obstacle_last_point: int = -1
|
||||
var valid_point: bool = false # a point is valid if the path would still be traversable overall if this point was made untraversable
|
||||
var tower_preview: Tower
|
||||
var tower_preview_card: Card
|
||||
var ray_collider: Object
|
||||
var ray_point: Vector3
|
||||
var last_point: FlowNode
|
||||
@@ -88,17 +86,14 @@ func reset() -> void:
|
||||
if is_instance_valid(ray_collider) and ray_collider is TowerBase and level.walls.has(ray_collider.point):
|
||||
level.walls[ray_collider.point].set_float(1.0)
|
||||
ray_collider = null
|
||||
delete_tower_preview()
|
||||
wall_preview.set_visible(false)
|
||||
clear_previous_point()
|
||||
last_point = null
|
||||
|
||||
|
||||
func process_looking_at_level() -> void:
|
||||
if tower_preview:
|
||||
delete_tower_preview()
|
||||
point = level.flow_field.get_closest_buildable_point(ray_point)
|
||||
if level.walls.has(point) or !point.buildable or hero.energy < Data.wall_cost or !hero.building_mode:
|
||||
if level.walls.has(point) or !point.buildable or hero.energy < Data.wall_cost:
|
||||
wall_preview.set_visible(false)
|
||||
valid_point = false
|
||||
clear_previous_point()
|
||||
@@ -126,40 +121,9 @@ func process_looking_at_tower() -> void:
|
||||
if last_point != point:
|
||||
clear_previous_point()
|
||||
|
||||
if tower_preview:
|
||||
delete_tower_preview()
|
||||
wall_preview.set_visible(false)
|
||||
ray_collider.set_color(Color.RED)
|
||||
ray_collider.set_float(0.0)
|
||||
if hero.hand.size > 0 and !ray_collider.has_card:
|
||||
if ray_collider != last_tower_base or hero.selected_card != tower_preview_card:
|
||||
spawn_tower_preview()
|
||||
|
||||
|
||||
func spawn_tower_preview() -> void:
|
||||
delete_tower_preview()
|
||||
last_tower_base = ray_collider
|
||||
var card: Card = hero.selected_card
|
||||
tower_preview_card = card
|
||||
tower_preview = card.turret_scene.instantiate() as Tower
|
||||
tower_preview.stats = card.tower_stats
|
||||
tower_preview.position = Vector3.UP
|
||||
tower_preview.preview_range(true)
|
||||
ray_collider.add_child(tower_preview)
|
||||
|
||||
|
||||
func delete_tower_preview() -> void:
|
||||
last_tower_base = null
|
||||
if is_instance_valid(tower_preview):
|
||||
tower_preview.queue_free()
|
||||
tower_preview = null
|
||||
tower_preview_card = null
|
||||
|
||||
|
||||
func interact() -> void:
|
||||
if ray_collider is TowerBase:
|
||||
var tower_base: TowerBase = ray_collider as TowerBase
|
||||
put_card_in_tower_base(tower_base)
|
||||
|
||||
|
||||
func build_wall() -> void:
|
||||
@@ -177,27 +141,5 @@ func refund_wall(wall: TowerBase) -> void:
|
||||
level.remove_wall(wall.point)
|
||||
|
||||
|
||||
func put_card_in_tower_base(tower_base: TowerBase) -> void:
|
||||
if hero.hand.size <= 0:
|
||||
return
|
||||
var card: Card = hero.selected_card
|
||||
var energy_cost: int = int(card.rarity) + 1
|
||||
energy_cost *= 2
|
||||
if hero.energy < energy_cost:
|
||||
return
|
||||
if tower_base.has_card:
|
||||
tower_base.remove_card()
|
||||
hero.hand.remove_at(hero.hand.contents.find(card))
|
||||
hero.check_removal()
|
||||
#hero.card_sprites[hero.hand_selected_index].queue_free()
|
||||
#hero.card_sprites.remove_at(hero.hand_selected_index)
|
||||
#if !hero.hand.contents.has(card):
|
||||
#hero.decrement_selected()
|
||||
tower_base.add_card(card, multiplayer.get_unique_id())
|
||||
hero.discard_pile.add(card)
|
||||
hero.place_card_audio.play()
|
||||
hero.energy -= energy_cost
|
||||
|
||||
|
||||
func set_progress_percent(value: float) -> void:
|
||||
progress_bar.value = progress_bar.max_value * value
|
||||
|
||||
305
PCs/hero.gd
305
PCs/hero.gd
@@ -6,14 +6,11 @@ signal ready_state_changed(state: bool)
|
||||
@export var hero_class: HeroClass
|
||||
@export var camera: Camera3D
|
||||
@export var gun_camera: Camera3D
|
||||
@export var left_hand_sprite: Sprite3D
|
||||
@export var left_hand: Node3D
|
||||
@export var right_hand: Node3D
|
||||
#@export var right_hand_animator: AnimationPlayer
|
||||
@export var edit_tool: PathEditTool
|
||||
@export var gauntlet_sprite: Sprite3D
|
||||
@export var carding_tool: CardPlacingTool
|
||||
@export var sprite: EightDirectionSprite3D
|
||||
#@export var hand_sprite: Sprite2D
|
||||
@export var interaction_raycast: RayCast3D
|
||||
@export var draw_pile: Inventory
|
||||
@export var hand: Inventory
|
||||
@@ -27,6 +24,9 @@ signal ready_state_changed(state: bool)
|
||||
@export var weapon_swap_timer: Timer
|
||||
@export var card3d_scene: PackedScene
|
||||
@export var card_select_scene: PackedScene
|
||||
@export var editing_states: Array[HeroState]
|
||||
@export var fighting_state: HeroState
|
||||
@export var default_state: HeroState
|
||||
|
||||
@export_subgroup("Audio")
|
||||
@export var ears: AudioListener3D
|
||||
@@ -39,7 +39,8 @@ signal ready_state_changed(state: bool)
|
||||
@export var swap_off_audio: AudioStreamPlayer
|
||||
@export var swap_on_audio: AudioStreamPlayer
|
||||
|
||||
var building_mode: bool = true
|
||||
var current_state: HeroState
|
||||
var pre_fighting_state: HeroState
|
||||
var selection_boxes: Array[CardSelectionBox] = []
|
||||
var unique_cards: Array[Card] = []
|
||||
var hand_card_scene: PackedScene = preload("res://Scenes/UI/card_hand.tscn")
|
||||
@@ -53,7 +54,6 @@ var weapons: Array[Weapon] = [null, null]
|
||||
var cards: Array[Card] = [null, null]
|
||||
var weapons_active: bool = false
|
||||
var paused: bool = false
|
||||
var editing_mode: bool = true
|
||||
var profile: PlayerProfile
|
||||
var ready_state: bool = false :
|
||||
set(value):
|
||||
@@ -84,13 +84,9 @@ func set_zoom_factor(value: float) -> void:
|
||||
|
||||
func _ready() -> void:
|
||||
if is_multiplayer_authority():
|
||||
#right_hand_animator.play("weapon_sway")
|
||||
#right_hand_animator.speed_scale = 0
|
||||
ears.make_current()
|
||||
camera.make_current()
|
||||
sprite.queue_free()
|
||||
hand.max_size = 5
|
||||
#hand_sprite.texture = hero_class.hand_texture
|
||||
player_name_tag.queue_free()
|
||||
for card: Card in hero_class.deck:
|
||||
draw_pile.add(card)
|
||||
@@ -98,22 +94,66 @@ func _ready() -> void:
|
||||
camera.set_visible(false)
|
||||
gun_camera.set_visible(false)
|
||||
hud.set_visible(false)
|
||||
|
||||
for state: HeroState in editing_states:
|
||||
state.state_changed.connect(update_state)
|
||||
fighting_state.state_changed.connect(update_state)
|
||||
current_state = default_state
|
||||
current_state.enter_state()
|
||||
|
||||
if weapons[equipped_weapon] != null:
|
||||
weapons[equipped_weapon].set_raycast_origin(camera)
|
||||
sprite.texture.atlas = hero_class.texture
|
||||
check_left_hand_valid()
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
|
||||
func update_state(new_state: HeroState) -> void:
|
||||
current_state.exit_state()
|
||||
current_state = new_state
|
||||
current_state.enter_state()
|
||||
|
||||
|
||||
func enter_fighting_state() -> void:
|
||||
pre_fighting_state = current_state
|
||||
update_state(fighting_state)
|
||||
|
||||
|
||||
func exit_fighting_state() -> void:
|
||||
update_state(pre_fighting_state)
|
||||
|
||||
|
||||
func add_selection(card: Card) -> void:
|
||||
if !unique_cards.has(card):
|
||||
unique_cards.append(card)
|
||||
var box: CardSelectionBox = card_select_scene.instantiate()
|
||||
box.set_card(card)
|
||||
box.set_key(unique_cards.size() - 1)
|
||||
selection_boxes.append(box)
|
||||
$HUD/selection_boxes.add_child(box)
|
||||
|
||||
|
||||
func check_removal() -> void:
|
||||
var index: int = -1
|
||||
for card: Card in unique_cards:
|
||||
if !hand.contents.has(card):
|
||||
index = unique_cards.find(card)
|
||||
if index >= 0:
|
||||
unique_cards.remove_at(index)
|
||||
selection_boxes[index].queue_free()
|
||||
selection_boxes.remove_at(index)
|
||||
if selection_boxes.size() > 0:
|
||||
for i: int in selection_boxes.size():
|
||||
var card: Card = unique_cards[i]
|
||||
selection_boxes[i].set_card(card)
|
||||
selection_boxes[i].set_key(i)
|
||||
if hand_selected_index == index:
|
||||
decrement_selected()
|
||||
update_selected_box()
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if !is_multiplayer_authority() or paused:
|
||||
return
|
||||
#if movement.input_vector == Vector2.ZERO:
|
||||
#right_hand_animator.speed_scale = 0
|
||||
#elif movement.sprinting:
|
||||
#right_hand_animator.speed_scale = 1
|
||||
#else:
|
||||
#right_hand_animator.speed_scale = 0.6
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
@@ -124,108 +164,7 @@ func _process(delta: float) -> void:
|
||||
if movement.zoom_factor > 1.0:
|
||||
movement.zoom_factor = 1.0
|
||||
|
||||
if editing_mode:
|
||||
if interaction_raycast.is_colliding() and interaction_raycast.get_collider() is InteractButton:
|
||||
hud.set_hover_text(interaction_raycast.get_collider().hover_text)
|
||||
if !hovering_item or hovering_item != interaction_raycast.get_collider():
|
||||
if hovering_item:
|
||||
hovering_item.disable_hover_effect()
|
||||
hovering_item = interaction_raycast.get_collider()
|
||||
hovering_item.enable_hover_effect()
|
||||
else:
|
||||
hud.unset_hover_text()
|
||||
if hovering_item:
|
||||
hovering_item.disable_hover_effect()
|
||||
hovering_item = null
|
||||
|
||||
if Input.is_action_just_pressed("Interact"):
|
||||
edit_tool.interact()
|
||||
if interaction_raycast.get_collider() is InteractButton:
|
||||
var button: InteractButton = interaction_raycast.get_collider() as InteractButton
|
||||
button.press(self)
|
||||
if interaction_raycast.get_collider() is ItemCard:
|
||||
add_card(interaction_raycast.get_collider().pick_up())
|
||||
if building_mode:
|
||||
if Input.is_action_just_pressed("Primary Fire"):
|
||||
edit_tool.interact_key_held = true
|
||||
if Input.is_action_just_released("Primary Fire"):
|
||||
edit_tool.interact_key_held = false
|
||||
if Input.is_action_just_pressed("Swap Weapons"):
|
||||
edit_tool.interact_key_held = false
|
||||
building_mode = false
|
||||
$FirstPersonViewport/Head2/LeftHand.visible = true
|
||||
$HUD/selection_boxes.visible = true
|
||||
$HUD/PlaceIcon.visible = true
|
||||
$HUD/SwapIcon.visible = true
|
||||
else:
|
||||
if Input.is_action_just_pressed("Primary Fire"):
|
||||
equip_weapon(0)
|
||||
if Input.is_action_just_pressed("Secondary Fire"):
|
||||
equip_weapon(1)
|
||||
if Input.is_action_just_pressed("Select Next Card") and hand.size > 1:
|
||||
increment_selected()
|
||||
swap_card_audio.play()
|
||||
if Input.is_action_just_pressed("Select Previous Card") and hand.size > 1:
|
||||
decrement_selected()
|
||||
swap_card_audio.play()
|
||||
if Input.is_action_just_pressed("Select 1st Card"):
|
||||
if unique_cards.size() >= 1:
|
||||
hand_selected_index = 0
|
||||
swap_card_audio.play()
|
||||
update_selected_box()
|
||||
if Input.is_action_just_pressed("Select 2nd Card"):
|
||||
if unique_cards.size() >= 2:
|
||||
hand_selected_index = 1
|
||||
swap_card_audio.play()
|
||||
update_selected_box()
|
||||
if Input.is_action_just_pressed("Select 3rd Card"):
|
||||
if unique_cards.size() >= 3:
|
||||
hand_selected_index = 2
|
||||
swap_card_audio.play()
|
||||
update_selected_box()
|
||||
if Input.is_action_just_pressed("Select 4th Card"):
|
||||
if unique_cards.size() >= 4:
|
||||
hand_selected_index = 3
|
||||
swap_card_audio.play()
|
||||
update_selected_box()
|
||||
if Input.is_action_just_pressed("Select 5th Card"):
|
||||
if unique_cards.size() >= 5:
|
||||
hand_selected_index = 4
|
||||
swap_card_audio.play()
|
||||
update_selected_box()
|
||||
if Input.is_action_just_pressed("Swap Weapons"):
|
||||
building_mode = true
|
||||
$FirstPersonViewport/Head2/LeftHand.visible = false
|
||||
$HUD/selection_boxes.visible = false
|
||||
$HUD/PlaceIcon.visible = false
|
||||
$HUD/SwapIcon.visible = false
|
||||
|
||||
if weapons[equipped_weapon] != null:
|
||||
weapons[equipped_weapon].release_trigger()
|
||||
weapons[equipped_weapon].release_second_trigger()
|
||||
else:
|
||||
if weapons[equipped_weapon] and weapons_active:
|
||||
if Input.is_action_just_pressed("Primary Fire"):
|
||||
weapons[equipped_weapon].hold_trigger()
|
||||
if Input.is_action_just_released("Primary Fire"):
|
||||
weapons[equipped_weapon].release_trigger()
|
||||
if Input.is_action_pressed("Secondary Fire"):
|
||||
weapons[equipped_weapon].hold_second_trigger()
|
||||
if Input.is_action_just_released("Secondary Fire"):
|
||||
weapons[equipped_weapon].release_second_trigger()
|
||||
if Input.is_action_pressed("Primary Fire"):
|
||||
movement.can_sprint = false
|
||||
if Input.is_action_pressed("Secondary Fire"):
|
||||
movement.can_sprint = false
|
||||
if Input.is_action_just_pressed("Equip Primary Weapon"):
|
||||
if equipped_weapon == 1 and weapons[0]:
|
||||
swap_weapons()
|
||||
if Input.is_action_just_pressed("Equip Secondary Weapon"):
|
||||
if equipped_weapon == 0 and weapons[1]:
|
||||
swap_weapons()
|
||||
if Input.is_action_just_pressed("Swap Weapons"):
|
||||
if weapons[0] and weapons[1]:
|
||||
swap_weapons()
|
||||
current_state.process_state(delta)
|
||||
|
||||
if movement.sprinting:
|
||||
movement.zoom_factor -= sprint_zoom_speed * delta
|
||||
@@ -239,7 +178,28 @@ func _process(delta: float) -> void:
|
||||
if Input.is_action_just_released("View Map"):
|
||||
hud.minimize_minimap()
|
||||
#Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
check_left_hand_valid()
|
||||
|
||||
|
||||
func check_world_button() -> void:
|
||||
if interaction_raycast.is_colliding() and interaction_raycast.get_collider() is InteractButton:
|
||||
hud.set_hover_text(interaction_raycast.get_collider().hover_text)
|
||||
if !hovering_item or hovering_item != interaction_raycast.get_collider():
|
||||
if hovering_item:
|
||||
hovering_item.disable_hover_effect()
|
||||
hovering_item = interaction_raycast.get_collider()
|
||||
hovering_item.enable_hover_effect()
|
||||
else:
|
||||
hud.unset_hover_text()
|
||||
if hovering_item:
|
||||
hovering_item.disable_hover_effect()
|
||||
hovering_item = null
|
||||
|
||||
if Input.is_action_just_pressed("Interact"):
|
||||
if interaction_raycast.get_collider() is InteractButton:
|
||||
var button: InteractButton = interaction_raycast.get_collider() as InteractButton
|
||||
button.press(self)
|
||||
if interaction_raycast.get_collider() is ItemCard:
|
||||
add_card(interaction_raycast.get_collider().pick_up())
|
||||
|
||||
|
||||
func increment_selected() -> void:
|
||||
@@ -259,14 +219,20 @@ func decrement_selected() -> void:
|
||||
update_selected_box()
|
||||
|
||||
|
||||
func set_card_elements_visibility(value: bool) -> void:
|
||||
$FirstPersonViewport/Head2/LeftHand.visible = value
|
||||
$HUD/selection_boxes.visible = value
|
||||
$HUD/PlaceIcon.visible = value
|
||||
$HUD/SwapIcon.visible = value
|
||||
if cards[0]:
|
||||
$HUD/PlaceIcon.visible = false
|
||||
if cards[1]:
|
||||
$HUD/SwapIcon.visible = false
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if !is_multiplayer_authority() or paused:
|
||||
return
|
||||
if editing_mode and event.is_action_pressed("Ready"):
|
||||
if ready_state:
|
||||
unready_self()
|
||||
else:
|
||||
ready_self()
|
||||
if event.is_action_pressed("Pause"):
|
||||
var menu: PauseMenu = pause_menu_scene.instantiate() as PauseMenu
|
||||
pause()
|
||||
@@ -297,9 +263,10 @@ func unready_self() -> void:
|
||||
|
||||
|
||||
func add_card(new_card: Card) -> void:
|
||||
hand.append(new_card)
|
||||
hand.add(new_card)
|
||||
hud.pickup(new_card)
|
||||
place_card_audio.play()
|
||||
add_selection(new_card)
|
||||
|
||||
|
||||
func unpause() -> void:
|
||||
@@ -314,78 +281,6 @@ func pause() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
|
||||
func enter_editing_mode(value: int) -> void:
|
||||
gauntlet_sprite.visible = true
|
||||
weapons_active = false
|
||||
hud.set_wave_count(value + 1)
|
||||
hud.set_energy_visible(false)
|
||||
hud.grow_wave_start_label()
|
||||
$HUD/selection_boxes.visible = true
|
||||
$HUD/EnergyLabel.visible = true
|
||||
$HUD/weapon_duration.visible = true
|
||||
$HUD/weapon_duration2.visible = true
|
||||
editing_mode = true
|
||||
edit_tool.enabled = true
|
||||
left_hand.visible = true
|
||||
if weapons[equipped_weapon]:
|
||||
weapons[equipped_weapon].release_trigger()
|
||||
weapons[equipped_weapon].visible = false
|
||||
|
||||
|
||||
func exit_editing_mode(value: int) -> void:
|
||||
gauntlet_sprite.visible = false
|
||||
$HUD/selection_boxes.visible = false
|
||||
$HUD/EnergyLabel.visible = false
|
||||
$HUD/weapon_duration.visible = false
|
||||
$HUD/weapon_duration2.visible = false
|
||||
weapons_active = false
|
||||
hud.set_wave_count(value)
|
||||
var offhand_weapon: Weapon = weapons[0] if equipped_weapon == 1 else weapons[1]
|
||||
if offhand_weapon:
|
||||
offhand_weapon.current_energy = offhand_weapon.max_energy
|
||||
if (!weapons[equipped_weapon] and offhand_weapon) or (weapons[0] and equipped_weapon == 1):
|
||||
swap_weapons()
|
||||
if weapons[equipped_weapon]:
|
||||
hud.set_energy_visible(true)
|
||||
weapons[equipped_weapon].current_energy = weapons[equipped_weapon].max_energy
|
||||
#this had to be commented out coz the new energy bar thinks "energy changed" is "energy used"
|
||||
#weapons[equipped_weapon].energy_changed.emit(weapons[equipped_weapon].current_energy)
|
||||
edit_tool.enabled = false
|
||||
edit_tool.delete_tower_preview()
|
||||
left_hand.visible = false
|
||||
hud.unset_hover_text()
|
||||
editing_mode = false
|
||||
weapon_swap_timer.start()
|
||||
|
||||
|
||||
func check_left_hand_valid() -> void:
|
||||
if !editing_mode:
|
||||
return
|
||||
if hand.size == 0:
|
||||
left_hand_sprite.visible = false
|
||||
else:
|
||||
left_hand_sprite.visible = true
|
||||
update_selected_box()
|
||||
|
||||
|
||||
func check_removal() -> void:
|
||||
var index: int = -1
|
||||
for card: Card in unique_cards:
|
||||
if !hand.contents.has(card):
|
||||
index = unique_cards.find(card)
|
||||
if index >= 0:
|
||||
unique_cards.remove_at(index)
|
||||
selection_boxes[index].queue_free()
|
||||
selection_boxes.remove_at(index)
|
||||
for i: int in selection_boxes.size():
|
||||
var card: Card = unique_cards[i]
|
||||
selection_boxes[i].set_card(card)
|
||||
selection_boxes[i].set_key(i)
|
||||
if hand_selected_index == index:
|
||||
decrement_selected()
|
||||
update_selected_box()
|
||||
|
||||
|
||||
func iterate_duration() -> void:
|
||||
for slot: int in weapons.size():
|
||||
if weapons[slot] == null:
|
||||
@@ -400,7 +295,8 @@ func iterate_duration() -> void:
|
||||
|
||||
|
||||
func draw_to_hand_size() -> void:
|
||||
while hand.size < hand.max_size:
|
||||
var hand_size: int = 5
|
||||
while hand.size < hand_size:
|
||||
if draw_pile.size == 0 and discard_pile.size == 0:
|
||||
return
|
||||
if draw_pile.size > 0:
|
||||
@@ -444,6 +340,8 @@ func update_selected_box() -> void:
|
||||
|
||||
|
||||
func equip_weapon(slot: int = 0) -> void:
|
||||
if hand.size == 0:
|
||||
return
|
||||
var energy_cost: int = int(hand.item_at(hand_selected_index).rarity) + 1
|
||||
energy_cost *= 2
|
||||
if energy < energy_cost:
|
||||
@@ -481,7 +379,6 @@ func equip_weapon(slot: int = 0) -> void:
|
||||
weapons[slot].visible = false
|
||||
right_hand.add_child(weapons[slot])
|
||||
check_removal()
|
||||
check_left_hand_valid()
|
||||
if slot == 0:
|
||||
weapons[slot].energy_spent.connect(hud.new_energy_bar.use_energy)
|
||||
weapons[slot].energy_recharged.connect(hud.new_energy_bar.gain_energy)
|
||||
@@ -489,7 +386,7 @@ func equip_weapon(slot: int = 0) -> void:
|
||||
if weapons[slot].stats.energy_type == Data.EnergyType.CONTINUOUS:
|
||||
hud.new_energy_bar.enable_progress_bar()
|
||||
if weapons[slot].stats.energy_type == Data.EnergyType.DISCRETE:
|
||||
hud.new_energy_bar.create_discrete_icons(weapons[slot].max_energy)
|
||||
hud.new_energy_bar.create_discrete_icons(int(weapons[slot].max_energy))
|
||||
else:
|
||||
weapons[slot].energy_recharged.connect(hud.new_energy_bar.gain_secondary_energy)
|
||||
hud.new_energy_bar.secondary_max_energy = weapons[slot].max_energy
|
||||
@@ -513,12 +410,12 @@ func show_weapon(slot: int = 0) -> void:
|
||||
weapons[slot].energy_recharged.disconnect(hud.new_energy_bar.gain_secondary_energy)
|
||||
weapons[slot].energy_spent.connect(hud.new_energy_bar.use_energy)
|
||||
weapons[slot].energy_recharged.connect(hud.new_energy_bar.gain_energy)
|
||||
hud.set_weapon_energy(weapons[slot].current_energy, weapons[slot].stats.energy_type)
|
||||
hud.set_weapon_energy(int(weapons[slot].current_energy), weapons[slot].stats.energy_type)
|
||||
hud.new_energy_bar.max_energy = weapons[slot].max_energy
|
||||
if weapons[slot].stats.energy_type == Data.EnergyType.CONTINUOUS:
|
||||
hud.new_energy_bar.enable_progress_bar()
|
||||
if weapons[slot].stats.energy_type == Data.EnergyType.DISCRETE:
|
||||
hud.new_energy_bar.create_discrete_icons(weapons[slot].max_energy)
|
||||
hud.new_energy_bar.create_discrete_icons(int(weapons[slot].max_energy))
|
||||
hud.new_energy_bar.use_energy(weapons[slot].max_energy - weapons[slot].current_energy, weapons[slot].stats.energy_type)
|
||||
var offhand: int = 0 if equipped_weapon == 1 else 1
|
||||
if !weapons[offhand]:
|
||||
@@ -530,7 +427,6 @@ func swap_weapons() -> void:
|
||||
return
|
||||
weapons_active = false
|
||||
swap_off_audio.play()
|
||||
hud.audio_guard = true
|
||||
if weapons[equipped_weapon]:
|
||||
stow_weapon(equipped_weapon)
|
||||
equipped_weapon = 0 if equipped_weapon == 1 else 1
|
||||
@@ -558,7 +454,6 @@ func unequip_weapon(slot: int = 0) -> void:
|
||||
weapons[slot] = null
|
||||
cards[slot] = null
|
||||
place_card_audio.play()
|
||||
check_left_hand_valid()
|
||||
|
||||
|
||||
#MULTIPLAYER NETWORKED FUNCTIONS
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
[gd_scene load_steps=62 format=3 uid="uid://dxgxbtf68lcv5"]
|
||||
[gd_scene load_steps=64 format=3 uid="uid://dxgxbtf68lcv5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://1fqpoegbdm6n" path="res://PCs/hero.gd" id="1_pihpe"]
|
||||
[ext_resource type="Resource" uid="uid://b5pc3frhx467q" path="res://Classes/Engineer/class.tres" id="2_dbyo0"]
|
||||
[ext_resource type="PackedScene" uid="uid://ri8r03wqy80t" path="res://Scenes/8_direction_sprite.tscn" id="2_ib0t5"]
|
||||
[ext_resource type="Texture2D" uid="uid://dkbkam81k355s" path="res://Assets/TextureAtlases/gauntlet.tres" id="3_5myy0"]
|
||||
[ext_resource type="PackedScene" uid="uid://buvgdem68wtev" path="res://Scenes/Menus/PauseMenu/pause_menu.tscn" id="3_avnsx"]
|
||||
[ext_resource type="PackedScene" uid="uid://n8ab1cy7ordc" path="res://card_model/3d_card.tscn" id="4_2mqvj"]
|
||||
[ext_resource type="Script" uid="uid://cij76at0nbs1v" path="res://PCs/view_movement.gd" id="4_mhexa"]
|
||||
@@ -13,6 +12,7 @@
|
||||
[ext_resource type="Script" uid="uid://do24iuot0j7d7" path="res://Scripts/inventory.gd" id="6_cf5ap"]
|
||||
[ext_resource type="Texture2D" uid="uid://cjqxkraykhxxk" path="res://Classes/Engineer/red.png" id="6_yyp8i"]
|
||||
[ext_resource type="Script" uid="uid://3wvxl8jo4uis" path="res://PCs/weapon_movement.gd" id="7_14ugt"]
|
||||
[ext_resource type="PackedScene" uid="uid://bj2q72ch8nkek" path="res://card_placing_tool.tscn" id="8_7d213"]
|
||||
[ext_resource type="Script" uid="uid://b6kjrl7ae1mi0" path="res://PCs/hud.gd" id="8_yl6ka"]
|
||||
[ext_resource type="Script" uid="uid://hy51bq7x0fy8" path="res://Scripts/on_top_camera.gd" id="11_4sdwe"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckl5tw5rmewhp" path="res://left_hand/card_hand_model.glb" id="11_h82f6"]
|
||||
@@ -47,14 +47,14 @@
|
||||
[ext_resource type="AudioStream" uid="uid://datdq1i45080i" path="res://Audio/open_002.wav" id="37_sa2xu"]
|
||||
[ext_resource type="AudioStream" uid="uid://dd1w61ri7ui4i" path="res://Audio/phaserDown3.ogg" id="40_pnv0q"]
|
||||
[ext_resource type="AudioStream" uid="uid://bll3n3pr8s4yy" path="res://Audio/phaserUp3.ogg" id="41_hussy"]
|
||||
[ext_resource type="Script" uid="uid://b5h7jfwkyokes" path="res://PCs/FSM/building_state.gd" id="47_d8pnf"]
|
||||
[ext_resource type="Script" uid="uid://cjdv1onyfej0m" path="res://PCs/FSM/carding_state.gd" id="48_7d213"]
|
||||
[ext_resource type="Script" uid="uid://cf7m4yyiqhhru" path="res://PCs/FSM/fighting_state.gd" id="49_60hic"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_jbu13"]
|
||||
radius = 0.3
|
||||
height = 1.8
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_8f12g"]
|
||||
viewport_path = NodePath("FirstPersonViewport/Head2/LeftHand/SubViewport")
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_v8f6r"]
|
||||
viewport_path = NodePath("FirstPersonViewport/Head2/LeftHand/SubViewport2")
|
||||
|
||||
@@ -113,18 +113,17 @@ stream_0/stream = ExtResource("36_lsvj8")
|
||||
streams_count = 1
|
||||
stream_0/stream = ExtResource("37_kv1mg")
|
||||
|
||||
[node name="Hero" type="CharacterBody3D" node_paths=PackedStringArray("camera", "gun_camera", "left_hand_sprite", "left_hand", "right_hand", "edit_tool", "gauntlet_sprite", "sprite", "interaction_raycast", "draw_pile", "hand", "discard_pile", "gauntlet_cards", "hud", "movement", "player_name_tag", "weapon_swap_timer", "ears", "place_card_audio", "swap_card_audio", "ready_audio", "unready_audio", "fullpower_audio", "zeropower_audio", "swap_off_audio", "swap_on_audio")]
|
||||
[node name="Hero" type="CharacterBody3D" node_paths=PackedStringArray("camera", "gun_camera", "left_hand", "right_hand", "edit_tool", "carding_tool", "sprite", "interaction_raycast", "draw_pile", "hand", "discard_pile", "gauntlet_cards", "hud", "movement", "player_name_tag", "weapon_swap_timer", "editing_states", "fighting_state", "default_state", "ears", "place_card_audio", "swap_card_audio", "ready_audio", "unready_audio", "fullpower_audio", "zeropower_audio", "swap_off_audio", "swap_on_audio")]
|
||||
collision_layer = 2
|
||||
collision_mask = 37
|
||||
script = ExtResource("1_pihpe")
|
||||
hero_class = ExtResource("2_dbyo0")
|
||||
camera = NodePath("ViewMovement/Head")
|
||||
gun_camera = NodePath("FirstPersonViewport/Head2")
|
||||
left_hand_sprite = NodePath("FirstPersonViewport/Head2/LeftHand/Sprite3D")
|
||||
left_hand = NodePath("FirstPersonViewport/Head2/LeftHand")
|
||||
right_hand = NodePath("FirstPersonViewport/Head2/RightHand")
|
||||
edit_tool = NodePath("ViewMovement/Head/EditTool")
|
||||
gauntlet_sprite = NodePath("FirstPersonViewport/Head2/RightHand/Gauntlet")
|
||||
carding_tool = NodePath("ViewMovement/Head/CardPlacingTool")
|
||||
sprite = NodePath("EightDirectionSprite")
|
||||
interaction_raycast = NodePath("ViewMovement/Head/RayCast3D")
|
||||
draw_pile = NodePath("DrawPile")
|
||||
@@ -138,6 +137,9 @@ player_name_tag = NodePath("NametagViewport/Label")
|
||||
weapon_swap_timer = NodePath("WeaponSwapTimer")
|
||||
card3d_scene = ExtResource("4_2mqvj")
|
||||
card_select_scene = ExtResource("5_h82f6")
|
||||
editing_states = [NodePath("BuildingState"), NodePath("CardingState")]
|
||||
fighting_state = NodePath("FightingState")
|
||||
default_state = NodePath("BuildingState")
|
||||
ears = NodePath("AudioListener3D")
|
||||
place_card_audio = NodePath("PlaceCardAudio")
|
||||
swap_card_audio = NodePath("SwapCardAudio")
|
||||
@@ -162,7 +164,7 @@ player = NodePath("..")
|
||||
camera = NodePath("Head")
|
||||
focus_raycast = NodePath("Head/RayCast3D")
|
||||
enable_strafe_tilt = true
|
||||
tilt_amount_x = 0.7
|
||||
tilt_amount_x = 0.8
|
||||
|
||||
[node name="Head" type="Camera3D" parent="ViewMovement"]
|
||||
keep_aspect = 0
|
||||
@@ -176,6 +178,9 @@ hero = NodePath("../../..")
|
||||
target_position = Vector3(0, 0, -2)
|
||||
collision_mask = 24
|
||||
|
||||
[node name="CardPlacingTool" parent="ViewMovement/Head" node_paths=PackedStringArray("hero") instance=ExtResource("8_7d213")]
|
||||
hero = NodePath("../../..")
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="ViewMovement"]
|
||||
target_position = Vector3(0, 0, -100)
|
||||
collision_mask = 65535
|
||||
@@ -200,12 +205,6 @@ tilt_amount_x = 12.0
|
||||
tilt_amount_y = 3.0
|
||||
weapon_rotation_amount = 0.001
|
||||
|
||||
[node name="Gauntlet" type="Sprite3D" parent="FirstPersonViewport/Head2/RightHand"]
|
||||
visible = false
|
||||
layers = 2
|
||||
texture_filter = 0
|
||||
texture = ExtResource("3_5myy0")
|
||||
|
||||
[node name="LeftHand" type="Node3D" parent="FirstPersonViewport/Head2"]
|
||||
transform = Transform3D(0.235, 0, 0, 0, 0.235, 0, 0, 0, 0.235, -0.645, -0.26, -1.04)
|
||||
visible = false
|
||||
@@ -224,21 +223,15 @@ render_target_update_mode = 4
|
||||
[node name="Node2D" parent="FirstPersonViewport/Head2/LeftHand/SubViewport3" instance=ExtResource("4_mwtvp")]
|
||||
visible = false
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="FirstPersonViewport/Head2/LeftHand"]
|
||||
transform = Transform3D(0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 1.56, -0.245, 0)
|
||||
layers = 2
|
||||
texture_filter = 0
|
||||
texture = SubResource("ViewportTexture_8f12g")
|
||||
|
||||
[node name="Sprite3D2" type="Sprite3D" parent="FirstPersonViewport/Head2/LeftHand"]
|
||||
transform = Transform3D(0.35, 0, 0, 0, 0.35, 0, 0, 0, 0.35, 4.74969, -0.0599999, 0.0158834)
|
||||
transform = Transform3D(0.35, 0, 0, 0, 0.35, 0, 0, 0, 0.35, 4.72, -0.145, 1.581)
|
||||
layers = 2
|
||||
sorting_offset = 1.0
|
||||
texture_filter = 0
|
||||
texture = SubResource("ViewportTexture_v8f6r")
|
||||
|
||||
[node name="Sprite3D3" type="Sprite3D" parent="FirstPersonViewport/Head2/LeftHand"]
|
||||
transform = Transform3D(0.35, 0, 0, 0, 0.35, 0, 0, 0, 0.35, 6.03, -0.0599999, 0.0158834)
|
||||
transform = Transform3D(0.35, 0, 0, 0, 0.35, 0, 0, 0, 0.35, 6.01, -0.145, 1.581)
|
||||
layers = 2
|
||||
sorting_offset = 1.0
|
||||
texture_filter = 0
|
||||
@@ -816,6 +809,23 @@ bus = &"SFX"
|
||||
stream = ExtResource("41_hussy")
|
||||
bus = &"SFX"
|
||||
|
||||
[node name="BuildingState" type="Node" parent="." node_paths=PackedStringArray("swap_state", "hero")]
|
||||
script = ExtResource("47_d8pnf")
|
||||
swap_state = NodePath("../CardingState")
|
||||
hero = NodePath("..")
|
||||
metadata/_custom_type_script = "uid://b5h7jfwkyokes"
|
||||
|
||||
[node name="CardingState" type="Node" parent="." node_paths=PackedStringArray("swap_state", "hero")]
|
||||
script = ExtResource("48_7d213")
|
||||
swap_state = NodePath("../BuildingState")
|
||||
hero = NodePath("..")
|
||||
metadata/_custom_type_script = "uid://cjdv1onyfej0m"
|
||||
|
||||
[node name="FightingState" type="Node" parent="." node_paths=PackedStringArray("hero")]
|
||||
script = ExtResource("49_60hic")
|
||||
hero = NodePath("..")
|
||||
metadata/_custom_type_script = "uid://cf7m4yyiqhhru"
|
||||
|
||||
[connection signal="timeout" from="WeaponSwapTimer" to="." method="_on_timer_timeout"]
|
||||
|
||||
[editable path="FirstPersonViewport/Head2/LeftHand/card_hand_model"]
|
||||
|
||||
16
PCs/hud.gd
16
PCs/hud.gd
@@ -29,7 +29,6 @@ extends CanvasLayer
|
||||
var last_lives_count: int = 120
|
||||
var enemy_names: Array[String]
|
||||
var map_anchor: Node3D
|
||||
var audio_guard: bool = false
|
||||
var cards: Array[EnemyCardUI] = []
|
||||
|
||||
|
||||
@@ -162,20 +161,13 @@ func set_energy_amount(value: int) -> void:
|
||||
func set_crosshair_visible(value: bool) -> void:
|
||||
crosshair.set_visible(value)
|
||||
|
||||
#TODO: the fuck is audio_guard for?
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func set_weapon_energy(value: int, energy_type: Data.EnergyType) -> void:
|
||||
#weapon_energy_bar.value = value
|
||||
if player.editing_mode:
|
||||
audio_guard = true
|
||||
if value == 0 and !audio_guard:
|
||||
if value == 0:
|
||||
player.zeropower_audio.play()
|
||||
audio_guard = true
|
||||
if value == 100 and !audio_guard:
|
||||
if value == 100:
|
||||
player.fullpower_audio.play()
|
||||
audio_guard = true
|
||||
if value > 0 and value < 100:
|
||||
audio_guard = false
|
||||
|
||||
|
||||
func maximise_minimap() -> void:
|
||||
@@ -227,6 +219,6 @@ func parse_action_tag(text: String) -> String:
|
||||
output.append("[img=top,50]%s[/img]" % KeyIconMap.keys[str(event.physical_keycode)])
|
||||
if event is InputEventMouseButton:
|
||||
output.append("[img=top,50]%s[/img]" % KeyIconMap.mouse_buttons[str(event.button_index)])
|
||||
string_array[1] = "".join(output)
|
||||
string_array[1] = "".join(output)
|
||||
text = "".join(string_array)
|
||||
return text
|
||||
|
||||
@@ -21,7 +21,7 @@ func _process(delta: float) -> void:
|
||||
if enable_strafe_tilt:
|
||||
tilt = get_strafe_tilt(player.velocity)
|
||||
if enable_mouse_sway:
|
||||
sway = weapon_sway(delta)
|
||||
sway = weapon_sway()
|
||||
rotation = lerp(rotation, tilt + sway, 10 * delta)
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ func get_strafe_tilt(player_velocity: Vector3) -> Vector3:
|
||||
return tilt_vector
|
||||
|
||||
|
||||
func weapon_sway(delta: float) -> Vector3:
|
||||
func weapon_sway() -> Vector3:
|
||||
var vector: Vector3 = Vector3.ZERO
|
||||
vector.x = mouse_input.y * weapon_rotation_amount * (-1 if invert_weapon_sway else 1)
|
||||
vector.y = mouse_input.x * weapon_rotation_amount * (-1 if invert_weapon_sway else 1)
|
||||
|
||||
Reference in New Issue
Block a user