mirror of
https://github.com/thelastflapjack/godot_open_target_shooter.git
synced 2026-07-17 16:45:39 +00:00
Better enforecment of style guide. Removed unused files and code.
Style guide: https://docs.godotengine.org/en/3.5/tutorials/scripting/gdscript/gdscript_styleguide.html
This commit is contained in:
parent
6a86cc22f6
commit
454946efa0
31 changed files with 90 additions and 286 deletions
|
|
@ -49,11 +49,6 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://src/ui/main_menu/level_select/level_button/level_button.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": "LevelCamSysStatePosiionData",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/camera_systems/level_camera/state_machine/state_position_data_OLD/state_position_data.gd"
|
||||
}, {
|
||||
"base": "Spatial",
|
||||
"class": "LevelCameraSystem",
|
||||
"language": "GDScript",
|
||||
|
|
@ -153,7 +148,6 @@ _global_script_class_icons={
|
|||
"CameraTraumaDetector": "",
|
||||
"GenUtils": "",
|
||||
"LevelButton": "",
|
||||
"LevelCamSysStatePosiionData": "",
|
||||
"LevelCameraSystem": "",
|
||||
"LevelCameraSystemState": "",
|
||||
"LevelManager": "",
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ signal shooting(spawn_point, bullet_speed, bullet_scene, bullet_damage)
|
|||
|
||||
|
||||
### Public variables ###
|
||||
var velocity := Vector3.ZERO
|
||||
var snap_vector := Vector3.ZERO
|
||||
var velocity: Vector3 = Vector3.ZERO
|
||||
var snap_vector: Vector3 = Vector3.ZERO
|
||||
var camera_system: LevelCameraSystem
|
||||
var input_movement_direction_xz := Vector3.ZERO
|
||||
var floor_max_angle_deg := 45.0
|
||||
var input_movement_direction_xz: Vector3 = Vector3.ZERO
|
||||
var floor_max_angle_deg: float = 45.0
|
||||
|
||||
var current_weapon: Weapon
|
||||
var can_aim: bool = true
|
||||
|
|
@ -56,7 +56,9 @@ func _ready() -> void:
|
|||
_ik_arm_right.set_target_node(current_weapon.grip_right_hand.get_path())
|
||||
_ik_arm_right.start()
|
||||
|
||||
_weapon_slot_secondary.get_child(0).ammo_loaded = _weapon_slot_secondary.get_child(0).magazine_size
|
||||
_weapon_slot_secondary.get_child(0).ammo_loaded = (
|
||||
_weapon_slot_secondary.get_child(0).magazine_size
|
||||
)
|
||||
|
||||
_hud.update_weapon_ammo(current_weapon.ammo_loaded)
|
||||
_hud.update_weapon_icon(current_weapon.icon)
|
||||
|
|
@ -94,7 +96,7 @@ func raise_weapon() -> void:
|
|||
|
||||
|
||||
func _switch_weapon() -> void:
|
||||
if current_weapon.slot_type == Weapon.SLOT_TYPE.PRIMARY:
|
||||
if current_weapon.slot_type == Weapon.SlotType.PRIMARY:
|
||||
_weapon_slot_primary.visible = false
|
||||
_weapon_slot_secondary.visible = true
|
||||
current_weapon = _weapon_slot_secondary.get_child(0)
|
||||
|
|
@ -148,7 +150,9 @@ func _reload_current_weapon() -> void:
|
|||
# Get new magazine
|
||||
var time_hand_to_ammo_bag: float = 0.25
|
||||
var time_hand_in_ammo_bag: float = 0.5
|
||||
var get_mag_tween: SceneTreeTween = create_tween().set_process_mode(Tween.TWEEN_PROCESS_PHYSICS)
|
||||
var get_mag_tween: SceneTreeTween = create_tween().set_process_mode(
|
||||
Tween.TWEEN_PROCESS_PHYSICS
|
||||
)
|
||||
# Reach for new mag
|
||||
var tweener_reach: PropertyTweener = get_mag_tween.tween_property(
|
||||
_ik_arm_left, "interpolation", 0.0, time_hand_to_ammo_bag
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ extends State
|
|||
# Generic state for the player which should be extended to specific states
|
||||
|
||||
### Exported variables ###
|
||||
export(float) var target_speed_xz := 1.0
|
||||
export(float) var acceleration_xz := 1.0
|
||||
export(float) var friction_xz := 1.0
|
||||
export(float) var acceleration_body_rotation := 1.0
|
||||
export(float) var target_speed_xz: float = 1.0
|
||||
export(float) var acceleration_xz: float = 1.0
|
||||
export(float) var friction_xz: float = 1.0
|
||||
export(float) var acceleration_body_rotation: float = 1.0
|
||||
|
||||
### Private variables ###
|
||||
var _player: Player
|
||||
|
|
@ -44,7 +44,7 @@ func physics_update(delta: float) -> void:
|
|||
_update_snap_vector()
|
||||
|
||||
|
||||
func enter(_data := {}) -> void:
|
||||
func enter(_data: Dictionary={}) -> void:
|
||||
_animate()
|
||||
|
||||
|
||||
|
|
@ -63,10 +63,10 @@ func _update_snap_vector() -> void:
|
|||
|
||||
|
||||
func _get_input_movement_direction_xz() -> Vector3:
|
||||
var input_vector := Vector3.ZERO
|
||||
var input_vector: Vector3 = Vector3.ZERO
|
||||
input_vector.z = Input.get_action_strength("player_backward") - Input.get_action_strength("player_forward")
|
||||
input_vector.x = Input.get_action_strength("player_right") - Input.get_action_strength("player_left")
|
||||
var direction = input_vector.normalized().rotated(
|
||||
var direction: Vector3 = input_vector.normalized().rotated(
|
||||
Vector3.UP,
|
||||
_player.camera_system.get_camera_global_transform().basis.get_euler().y
|
||||
)
|
||||
|
|
@ -75,11 +75,13 @@ func _get_input_movement_direction_xz() -> Vector3:
|
|||
|
||||
func _apply_xz_movement(delta: float, direction_xz: Vector3) -> void:
|
||||
if direction_xz != Vector3.ZERO:
|
||||
var velocity_target_xz := direction_xz * target_speed_xz
|
||||
var velocity_target_xz: Vector3 = direction_xz * target_speed_xz
|
||||
_player.velocity.x = _player.velocity.move_toward(velocity_target_xz, acceleration_xz * delta).x
|
||||
_player.velocity.z = _player.velocity.move_toward(velocity_target_xz, acceleration_xz * delta).z
|
||||
else:
|
||||
var frictioned_velocity_xz := _player.velocity.move_toward(Vector3.ZERO, friction_xz * delta)
|
||||
var frictioned_velocity_xz: Vector3 = _player.velocity.move_toward(
|
||||
Vector3.ZERO, friction_xz * delta
|
||||
)
|
||||
_player.velocity.x = frictioned_velocity_xz.x
|
||||
_player.velocity.z = frictioned_velocity_xz.z
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ extends PlayerState
|
|||
|
||||
var _strafe_dir_target: Vector2
|
||||
var _strafe_dir: Vector2
|
||||
var _strafe_dir_accel: float = 3
|
||||
var _neck_bone_number := 7
|
||||
var _strafe_dir_accel: float = 3.0
|
||||
var _neck_bone_number: int = 7
|
||||
var _neck_bone_neutral_pose: Transform
|
||||
|
||||
############################
|
||||
|
|
@ -22,7 +22,7 @@ func handle_input(event: InputEvent) -> void:
|
|||
func physics_update(delta: float) -> void:
|
||||
.physics_update(delta)
|
||||
|
||||
var movement_direction_xz := _get_input_movement_direction_xz()
|
||||
var movement_direction_xz: Vector3 = _get_input_movement_direction_xz()
|
||||
_strafe_dir = _strafe_dir.move_toward(_strafe_dir_target, _strafe_dir_accel * delta)
|
||||
_player._anim_tree.set("parameters/aim/BlendSpace2D/blend_position", _strafe_dir)
|
||||
_apply_xz_movement(delta, movement_direction_xz)
|
||||
|
|
@ -47,7 +47,7 @@ func physics_update(delta: float) -> void:
|
|||
)
|
||||
|
||||
|
||||
func enter(_data := {}) -> void:
|
||||
func enter(_data: Dictionary={}) -> void:
|
||||
_animate()
|
||||
_neck_bone_neutral_pose = _player.skeleton.get_bone_pose(_neck_bone_number)
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ func exit() -> void:
|
|||
############################
|
||||
|
||||
func _get_input_movement_direction_xz() -> Vector3:
|
||||
var input_vector := Vector3.ZERO
|
||||
var input_vector: Vector3 = Vector3.ZERO
|
||||
input_vector.z = Input.get_action_strength("player_backward") - Input.get_action_strength("player_forward")
|
||||
input_vector.x = Input.get_action_strength("player_right") - Input.get_action_strength("player_left")
|
||||
var input_vectorm_norm: Vector3 = input_vector.normalized()
|
||||
|
|
@ -70,7 +70,7 @@ func _get_input_movement_direction_xz() -> Vector3:
|
|||
-round(input_vectorm_norm.z)
|
||||
)
|
||||
|
||||
var direction = input_vector.normalized().rotated(
|
||||
var direction: Vector3 = input_vector.normalized().rotated(
|
||||
Vector3.UP,
|
||||
_player.camera_system.get_camera_global_transform().basis.get_euler().y
|
||||
)
|
||||
|
|
@ -83,7 +83,7 @@ func _animate() -> void:
|
|||
|
||||
|
||||
func _update_state() -> void:
|
||||
var target_state_id := name
|
||||
var target_state_id: String = name
|
||||
if not _player.can_aim:
|
||||
if _get_input_movement_direction_xz() == Vector3.ZERO:
|
||||
target_state_id = "Idle"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func physics_update(delta: float) -> void:
|
|||
)
|
||||
|
||||
|
||||
func enter(_data := {}) -> void:
|
||||
func enter(_data: Dictionary={}) -> void:
|
||||
_animate()
|
||||
_player.weapons_anchor.rotation_degrees = Vector3(0, -180, 0)
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ func _animate() -> void:
|
|||
|
||||
|
||||
func _update_state() -> void:
|
||||
var target_state_id := name
|
||||
var target_state_id: String = name
|
||||
if _get_input_movement_direction_xz() != Vector3.ZERO:
|
||||
target_state_id = "Walking"
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ func handle_input(event: InputEvent) -> void:
|
|||
func physics_update(delta: float) -> void:
|
||||
.physics_update(delta)
|
||||
|
||||
var movement_direction_xz := _get_input_movement_direction_xz()
|
||||
var movement_direction_xz: Vector3 = _get_input_movement_direction_xz()
|
||||
_apply_xz_movement(delta, movement_direction_xz)
|
||||
if movement_direction_xz != Vector3.ZERO:
|
||||
_rotate_body(delta, movement_direction_xz)
|
||||
|
|
@ -33,7 +33,7 @@ func physics_update(delta: float) -> void:
|
|||
)
|
||||
|
||||
|
||||
func enter(_data := {}) -> void:
|
||||
func enter(_data: Dictionary={}) -> void:
|
||||
_animate()
|
||||
_player.weapons_anchor.rotation_degrees = Vector3(0, -180, 0)
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ func _animate() -> void:
|
|||
|
||||
|
||||
func _update_state() -> void:
|
||||
var target_state_id := name
|
||||
var target_state_id: String = name
|
||||
if _get_input_movement_direction_xz() == Vector3.ZERO:
|
||||
target_state_id = "Idle"
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ func handle_input(event: InputEvent) -> void:
|
|||
func physics_update(delta: float) -> void:
|
||||
.physics_update(delta)
|
||||
|
||||
var movement_direction_xz := _get_input_movement_direction_xz()
|
||||
var movement_direction_xz: Vector3 = _get_input_movement_direction_xz()
|
||||
_apply_xz_movement(delta, movement_direction_xz)
|
||||
if movement_direction_xz != Vector3.ZERO:
|
||||
_rotate_body(delta, movement_direction_xz)
|
||||
|
|
@ -30,7 +30,7 @@ func physics_update(delta: float) -> void:
|
|||
)
|
||||
|
||||
|
||||
func enter(_data := {}) -> void:
|
||||
func enter(_data: Dictionary={}) -> void:
|
||||
_animate()
|
||||
_player.weapons_anchor.rotation_degrees = Vector3(0, -180, 0)
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ func _animate() -> void:
|
|||
|
||||
|
||||
func _update_state() -> void:
|
||||
var target_state_id := name
|
||||
var target_state_id: String = name
|
||||
if _get_input_movement_direction_xz() == Vector3.ZERO:
|
||||
target_state_id = "Idle"
|
||||
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@ extends Node
|
|||
|
||||
### Enums ###
|
||||
enum AudioBuses {
|
||||
Master = 0,
|
||||
Sfx = 1,
|
||||
Music = 2,
|
||||
Ui = 3,
|
||||
MASTER = 0,
|
||||
SFX = 1,
|
||||
MUSIC = 2,
|
||||
UI = 3,
|
||||
}
|
||||
|
||||
|
||||
### Public variables ###
|
||||
var audio_vol: Dictionary = {
|
||||
AudioBuses.Master: 0.5,
|
||||
AudioBuses.Sfx: 0.5,
|
||||
AudioBuses.Music: 0.5,
|
||||
AudioBuses.Ui: 0.5,
|
||||
AudioBuses.MASTER: 0.5,
|
||||
AudioBuses.SFX: 0.5,
|
||||
AudioBuses.MUSIC: 0.5,
|
||||
AudioBuses.UI: 0.5,
|
||||
}
|
||||
|
||||
var mouse_sensitivity: float = 0.5 setget set_mouse_sensitivity
|
||||
|
|
@ -88,10 +88,10 @@ func save() -> void:
|
|||
var prefs_cfg: ConfigFile = ConfigFile.new()
|
||||
var err: int = prefs_cfg.load("user://user_prefs.cfg")
|
||||
if err == OK:
|
||||
prefs_cfg.set_value("user_prefs", "audio_vol_master", audio_vol[AudioBuses.Master])
|
||||
prefs_cfg.set_value("user_prefs", "audio_vol_music", audio_vol[AudioBuses.Music])
|
||||
prefs_cfg.set_value("user_prefs", "audio_vol_sfx", audio_vol[AudioBuses.Sfx])
|
||||
prefs_cfg.set_value("user_prefs", "audio_vol_ui", audio_vol[AudioBuses.Ui])
|
||||
prefs_cfg.set_value("user_prefs", "audio_vol_master", audio_vol[AudioBuses.MASTER])
|
||||
prefs_cfg.set_value("user_prefs", "audio_vol_music", audio_vol[AudioBuses.MUSIC])
|
||||
prefs_cfg.set_value("user_prefs", "audio_vol_sfx", audio_vol[AudioBuses.SFX])
|
||||
prefs_cfg.set_value("user_prefs", "audio_vol_ui", audio_vol[AudioBuses.UI])
|
||||
|
||||
prefs_cfg.set_value("user_prefs", "mouse_sensitivity", mouse_sensitivity)
|
||||
prefs_cfg.set_value("user_prefs", "toggle_sprint", toggle_sprint)
|
||||
|
|
@ -125,10 +125,10 @@ func _load() -> void:
|
|||
if err == OK:
|
||||
# Using set funcs for most so preferences are applied when this autoload
|
||||
# enters the sceen tree as the game program starts.
|
||||
set_audio_vol(AudioBuses.Master,prefs_cfg.get_value("user_prefs", "audio_vol_master"))
|
||||
set_audio_vol(AudioBuses.Music,prefs_cfg.get_value("user_prefs", "audio_vol_music"))
|
||||
set_audio_vol(AudioBuses.Sfx,prefs_cfg.get_value("user_prefs", "audio_vol_sfx"))
|
||||
set_audio_vol(AudioBuses.Ui,prefs_cfg.get_value("user_prefs", "audio_vol_ui"))
|
||||
set_audio_vol(AudioBuses.MASTER, prefs_cfg.get_value("user_prefs", "audio_vol_master"))
|
||||
set_audio_vol(AudioBuses.MUSIC, prefs_cfg.get_value("user_prefs", "audio_vol_music"))
|
||||
set_audio_vol(AudioBuses.SFX, prefs_cfg.get_value("user_prefs", "audio_vol_sfx"))
|
||||
set_audio_vol(AudioBuses.UI, prefs_cfg.get_value("user_prefs", "audio_vol_ui"))
|
||||
|
||||
set_mouse_sensitivity(prefs_cfg.get_value("user_prefs", "mouse_sensitivity"))
|
||||
toggle_sprint = prefs_cfg.get_value("user_prefs", "toggle_sprint")
|
||||
|
|
|
|||
|
|
@ -24,27 +24,14 @@ func _on_area_entered(area: Area) -> void:
|
|||
causer, "activated", self,
|
||||
"_on_overlapping_causer_activated"
|
||||
)
|
||||
# GenUtils.connect_signal_assert_ok(
|
||||
# causer, "deactivated", self,
|
||||
# "_on_overlapping_causer_deactivated"
|
||||
# )
|
||||
|
||||
|
||||
func _on_area_exited(area: Area) -> void:
|
||||
assert(area is CameraTraumaCauser)
|
||||
var causer: CameraTraumaCauser = area
|
||||
causer.disconnect("activated", self, "_on_overlapping_causer_activated")
|
||||
#causer.disconnect("deactivated", self, "_on_overlapping_causer_deactivated")
|
||||
|
||||
|
||||
func _on_overlapping_causer_activated(causer: CameraTraumaCauser) -> void:
|
||||
_camera.add_trauma_causer(causer)
|
||||
|
||||
|
||||
#func _on_overlapping_causer_deactivated(causer: CameraTraumaCauser) -> void:
|
||||
# _camera.remove_trauma_causer(causer)
|
||||
|
||||
|
||||
############################
|
||||
# Private Methods #
|
||||
############################
|
||||
|
|
|
|||
|
|
@ -56,9 +56,7 @@ func raycast_collision_point() -> Vector3:
|
|||
|
||||
func update_camera_local_transform(anchor_offset: Vector3, camera_offset: Vector3) -> void:
|
||||
var tween: SceneTreeTween = create_tween().set_process_mode(Tween.TWEEN_PROCESS_PHYSICS)
|
||||
tween = tween.set_ease(Tween.EASE_IN)
|
||||
tween = tween.set_trans(Tween.TRANS_LINEAR)
|
||||
tween = tween.set_parallel(true)
|
||||
tween = tween.set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_LINEAR).set_parallel(true)
|
||||
var duration: float = 0.15
|
||||
|
||||
var _anchor_y_pos_tweener: PropertyTweener = tween.tween_property(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export(Vector3) var _anchor_offset: Vector3
|
|||
# Position relative to anchor_offset where the camera will be..
|
||||
export(Vector3) var _camera_offset: Vector3
|
||||
export(Vector2) var _pitch_limits: Vector2
|
||||
export(float, 0, 1) var _follow_smoothing: float
|
||||
export(float, 0.0, 1.0) var _follow_smoothing: float
|
||||
|
||||
|
||||
### Private variables ###
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
[gd_resource type="Resource" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/camera_systems/level_camera/state_machine/state_position_data_OLD/state_position_data.gd" type="Script" id=1]
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
anchor_offset = Vector3( 0.3, 1.6, 0 )
|
||||
anchor_rotation = Vector3( 0, 180, 0 )
|
||||
camera_offset = Vector3( 0, 0, 0.6 )
|
||||
pitch_limits = Vector2( -0.95, 0.7 )
|
||||
look_target_initial = Vector3( -0.3, 1.6, -100 )
|
||||
follow_smoothing = 0.5
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
[gd_resource type="Resource" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/camera_systems/level_camera/state_machine/state_position_data_OLD/state_position_data.gd" type="Script" id=1]
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
anchor_offset = Vector3( 0.5, 1.6, 0 )
|
||||
anchor_rotation = Vector3( 0, 180, 0 )
|
||||
camera_offset = Vector3( 0, 0, 1.7 )
|
||||
pitch_limits = Vector2( -0.95, 0.7 )
|
||||
look_target_initial = Vector3( -0.5, 1.6, -100 )
|
||||
follow_smoothing = 1.0
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
tool
|
||||
class_name LevelCamSysStatePosiionData
|
||||
extends Resource
|
||||
# Docstring
|
||||
|
||||
signal transform_value_changed()
|
||||
|
||||
# Position relative to the target origin which the camera system will use as its origin
|
||||
export(Vector3) var anchor_offset: Vector3 setget set_anchor_offset
|
||||
export(Vector3) var anchor_rotation: Vector3 setget set_anchor_rotation
|
||||
# Position relative to anchor_offset where the camera will be..
|
||||
export(Vector3) var camera_offset: Vector3 setget set_camera_offset
|
||||
export(Vector2) var pitch_limits: Vector2
|
||||
# Relative to target + anchor_offset
|
||||
export(Vector3) var look_target_initial: Vector3 setget set_look_target_initial
|
||||
export(float, 0, 1) var follow_smoothing: float
|
||||
|
||||
|
||||
func set_anchor_offset(val: Vector3) -> void:
|
||||
anchor_offset = val
|
||||
emit_signal("transform_value_changed")
|
||||
|
||||
|
||||
func set_anchor_rotation(val: Vector3) -> void:
|
||||
anchor_rotation = val
|
||||
emit_signal("transform_value_changed")
|
||||
|
||||
|
||||
func set_camera_offset(val: Vector3) -> void:
|
||||
camera_offset = val
|
||||
emit_signal("transform_value_changed")
|
||||
|
||||
|
||||
func set_look_target_initial(val: Vector3) -> void:
|
||||
look_target_initial = val
|
||||
emit_signal("transform_value_changed")
|
||||
|
|
@ -15,10 +15,6 @@ func handle_input(event: InputEvent) -> void:
|
|||
_handle_input_mouse_motion(event)
|
||||
|
||||
|
||||
func update(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func physics_update(_delta: float) -> void:
|
||||
_camera_sys.anchor_y.rotation = lerp(
|
||||
_camera_sys.anchor_y.rotation, _camera_sys.anchor_y_rotation_target,
|
||||
|
|
@ -27,7 +23,7 @@ func physics_update(_delta: float) -> void:
|
|||
_follow_follow_target()
|
||||
|
||||
|
||||
func enter(_data := {}) -> void:
|
||||
func enter(_data: Dictionary={}) -> void:
|
||||
_camera_sys.update_camera_local_transform(
|
||||
_anchor_offset, _camera_offset
|
||||
)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ func physics_update(_delta: float) -> void:
|
|||
_follow_follow_target()
|
||||
|
||||
|
||||
func enter(_data := {}) -> void:
|
||||
func enter(_data: Dictionary={}) -> void:
|
||||
_camera_sys.update_camera_local_transform(
|
||||
_anchor_offset, _camera_offset
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
#class_name
|
||||
extends LevelCameraSystemState
|
||||
# Docstring
|
||||
|
||||
|
||||
### Signals ###
|
||||
|
||||
### Enums ###
|
||||
|
||||
### Constants ###
|
||||
|
||||
### Exported variables ###
|
||||
|
||||
### Public variables ###
|
||||
|
||||
### Private variables ###
|
||||
|
||||
### Onready variables ###
|
||||
|
||||
|
||||
############################
|
||||
# Engine Callback Methods #
|
||||
############################
|
||||
|
||||
|
||||
############################
|
||||
# Public Methods #
|
||||
############################
|
||||
func handle_input(event: InputEvent) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func update(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func physics_update(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func enter(_data := {}) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func exit() -> void:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
############################
|
||||
# Signal Connected Methods #
|
||||
############################
|
||||
|
||||
|
||||
|
||||
############################
|
||||
# Private Methods #
|
||||
############################
|
||||
|
|
@ -30,7 +30,7 @@ func physics_update(delta: float) -> void:
|
|||
|
||||
# Virtual function. Called by the state machine upon changing the active state.
|
||||
# _data is a dictionary with arbitrary data the state can use to initialize.
|
||||
func enter(_data := {}) -> void:
|
||||
func enter(_data: Dictionary={}) -> void:
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ func get_current_state() -> State:
|
|||
return _current_state
|
||||
|
||||
|
||||
func transition_to(target_state_id: String, data: Dictionary = {}) -> void:
|
||||
func transition_to(target_state_id: String, data: Dictionary={}) -> void:
|
||||
assert(_states.has(target_state_id))
|
||||
_current_state.disconnect("change_state_request", self, "_on_change_state_request")
|
||||
_current_state.exit()
|
||||
|
|
@ -66,7 +66,7 @@ func return_to_initial_state() -> void:
|
|||
############################
|
||||
# Signal Connected Methods #
|
||||
############################
|
||||
func _on_change_state_request(state_id: String, data := {}) -> void:
|
||||
func _on_change_state_request(state_id: String, data: Dictionary={}) -> void:
|
||||
transition_to(state_id, data)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,6 @@ extends Node
|
|||
### Signals ###
|
||||
signal badge_earned(badge)
|
||||
|
||||
### Enums ###
|
||||
|
||||
### Constants ###
|
||||
|
||||
### Exported variables ###
|
||||
|
||||
### Public variables ###
|
||||
|
||||
### Private variables ###
|
||||
var _multikill_window: int = 2
|
||||
|
|
@ -50,7 +43,7 @@ func get_run_badges() -> Dictionary:
|
|||
return _run_badges.duplicate()
|
||||
|
||||
|
||||
func evaluate_end_of_run_stats(all_enemies_hit: bool, no_frendlies_hit, accuracy: float) -> void:
|
||||
func evaluate_end_of_run_stats(all_enemies_hit: bool, no_frendlies_hit: bool, accuracy: float) -> void:
|
||||
if all_enemies_hit and no_frendlies_hit:
|
||||
_badge_earned(_badges["clean_sweep"])
|
||||
if accuracy == 1:
|
||||
|
|
@ -58,7 +51,7 @@ func evaluate_end_of_run_stats(all_enemies_hit: bool, no_frendlies_hit, accuracy
|
|||
|
||||
|
||||
func get_run_badge_time() -> float:
|
||||
var run_badge_time: float = 0
|
||||
var run_badge_time: float = 0.0
|
||||
for badge in _run_badges:
|
||||
run_badge_time -= badge.time_value * _run_badges[badge]
|
||||
|
||||
|
|
|
|||
|
|
@ -64,8 +64,3 @@ func _on_bullet_collided(bullet: Bullet, collider: Spatial) -> void:
|
|||
collider.hurt(bullet.damage)
|
||||
bullet.destroy()
|
||||
|
||||
|
||||
############################
|
||||
# Private Methods #
|
||||
############################
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ var _down_targets_friendly: Array
|
|||
# Engine Callback Methods #
|
||||
############################
|
||||
func _ready() -> void:
|
||||
var i := 0
|
||||
var i: int = 0
|
||||
var target: PopupTarget
|
||||
while i < get_child_count():
|
||||
target = get_child(i)
|
||||
|
|
@ -87,7 +87,3 @@ func _on_target_hit(target: PopupTarget) -> void:
|
|||
_down_targets_friendly.append(target)
|
||||
emit_signal("friendly_target_hit")
|
||||
|
||||
|
||||
############################
|
||||
# Private Methods #
|
||||
############################
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#class_name
|
||||
extends Spatial
|
||||
# Docstring
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ extends Spatial
|
|||
signal hit(target)
|
||||
|
||||
### Exported variables ###
|
||||
export(float) var _move_distance: float = 0 setget _set_move_distance
|
||||
export(float, 0.1, 5) var _move_speed: float = 1
|
||||
export(float) var _end_wait: float = 1
|
||||
export(float) var _move_distance: float = 0.0 setget _set_move_distance
|
||||
export(float, 0.1, 5.0) var _move_speed: float = 1.0
|
||||
export(float) var _end_wait: float = 1.0
|
||||
export(bool) var is_enemy: bool = true setget _set_is_enemy
|
||||
|
||||
### Private variables ###
|
||||
|
|
@ -118,21 +118,15 @@ func _set_is_enemy(val: bool) -> void:
|
|||
func _tween_popup_target_setup() -> void:
|
||||
var step_duration: float = abs(_move_distance) / _move_speed
|
||||
_tween = create_tween().set_process_mode(Tween.TWEEN_PROCESS_PHYSICS)
|
||||
var tweener_step_1: PropertyTweener = _tween.tween_property(
|
||||
var _tweener_step_1: PropertyTweener = _tween.tween_property(
|
||||
_popup_target, "translation",
|
||||
Vector3(_move_distance, 0, 0), step_duration
|
||||
)
|
||||
tweener_step_1 = tweener_step_1.set_ease(Tween.EASE_OUT_IN)
|
||||
tweener_step_1 = tweener_step_1.set_trans(Tween.TRANS_LINEAR)
|
||||
tweener_step_1 = tweener_step_1.set_delay(_end_wait)
|
||||
).set_ease(Tween.EASE_OUT_IN).set_trans(Tween.TRANS_LINEAR).set_delay(_end_wait)
|
||||
|
||||
var tweener_step_2: PropertyTweener = _tween.tween_property(
|
||||
var _tweener_step_2: PropertyTweener = _tween.tween_property(
|
||||
_popup_target, "translation",
|
||||
Vector3(0, 0, 0), step_duration
|
||||
)
|
||||
tweener_step_2 = tweener_step_2.set_ease(Tween.EASE_OUT_IN)
|
||||
tweener_step_2 = tweener_step_2.set_trans(Tween.TRANS_LINEAR)
|
||||
tweener_step_2 = tweener_step_2.set_delay(_end_wait)
|
||||
).set_ease(Tween.EASE_OUT_IN).set_trans(Tween.TRANS_LINEAR).set_delay(_end_wait)
|
||||
|
||||
_tween = _tween.set_loops()
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ func _ready() -> void:
|
|||
_loader_poll_timer.wait_time = _poll_time
|
||||
|
||||
#make sure root is ready to take new child
|
||||
yield(get_tree().root,"ready")
|
||||
yield(get_tree().root, "ready")
|
||||
_set_current_scene(_initial_scene.instance())
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ extends MultiPageUIPage
|
|||
# Script controlling the level select menu screen
|
||||
|
||||
|
||||
### Signals ###
|
||||
|
||||
### Exported variables ###
|
||||
export(String) var _level_directory_path: String
|
||||
|
||||
|
|
@ -56,9 +54,9 @@ func _on_start_level_button_pressed() -> void:
|
|||
|
||||
|
||||
func _update_selected_level_stats(button: LevelButton) -> void:
|
||||
var level_name := button.get_text().to_lower().replace(" ", "_")
|
||||
var level_time_par := SaveLoad.load_level_par_time(level_name)
|
||||
var level_time_best := SaveLoad.load_level_best_time(level_name)
|
||||
var level_name: String = button.get_text().to_lower().replace(" ", "_")
|
||||
var level_time_par: float = SaveLoad.load_level_par_time(level_name)
|
||||
var level_time_best: float = SaveLoad.load_level_best_time(level_name)
|
||||
|
||||
_label_level_name.set_text(button.get_text())
|
||||
_label_level_time_par.set_text("%5.2f" % level_time_par)
|
||||
|
|
@ -78,11 +76,11 @@ func _update_selected_level_stats(button: LevelButton) -> void:
|
|||
############################
|
||||
func _find_level_file_names() -> PoolStringArray:
|
||||
var result: PoolStringArray = []
|
||||
var dir := Directory.new()
|
||||
var err := dir.open(_level_directory_path)
|
||||
var dir: Directory = Directory.new()
|
||||
var err: int = dir.open(_level_directory_path)
|
||||
if err == OK:
|
||||
var regex := RegEx.new()
|
||||
var match_string = "level_\\d+.tscn"
|
||||
var regex: RegEx = RegEx.new()
|
||||
var match_string: String = "level_\\d+.tscn"
|
||||
err = regex.compile(match_string)
|
||||
if err == OK:
|
||||
# warning-ignore:return_value_discarded
|
||||
|
|
@ -103,11 +101,11 @@ func _find_level_file_names() -> PoolStringArray:
|
|||
func _add_level_buttons(level_file_names: PoolStringArray) -> void:
|
||||
for i in range(level_file_names.size()):
|
||||
var file_name: String = level_file_names[i]
|
||||
var new_button = _level_button_res.instance()
|
||||
var new_button: LevelButton = _level_button_res.instance()
|
||||
_level_button_grid.add_child(new_button)
|
||||
new_button.set_v_size_flags(SIZE_EXPAND_FILL)
|
||||
new_button.set_custom_minimum_size(Vector2(200, 0))
|
||||
var text := file_name.get_basename().capitalize()
|
||||
var text: String = file_name.get_basename().capitalize()
|
||||
new_button.set_text(text)
|
||||
new_button.set_name("Button%s" % text.replace(" ", ""))
|
||||
|
||||
|
|
|
|||
|
|
@ -99,13 +99,10 @@ func _change_current_page(new_page_name: String) -> void:
|
|||
target_page.visible = true
|
||||
|
||||
var tween: SceneTreeTween = create_tween()
|
||||
var page_rect_pos_tweener: PropertyTweener = tween.tween_property(
|
||||
var _page_rect_pos_tweener: PropertyTweener = tween.tween_property(
|
||||
_page_container, "rect_position",
|
||||
position_change, 1
|
||||
)
|
||||
page_rect_pos_tweener = page_rect_pos_tweener.as_relative()
|
||||
page_rect_pos_tweener = page_rect_pos_tweener.set_ease(Tween.EASE_IN_OUT)
|
||||
page_rect_pos_tweener = page_rect_pos_tweener.set_trans(Tween.TRANS_QUAD)
|
||||
).as_relative().set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_QUAD)
|
||||
tween.play()
|
||||
yield(tween, "finished")
|
||||
|
||||
|
|
|
|||
|
|
@ -3,33 +3,12 @@ extends Control
|
|||
# Docstring
|
||||
|
||||
|
||||
### Signals ###
|
||||
|
||||
### Enums ###
|
||||
|
||||
### Constants ###
|
||||
|
||||
### Exported variables ###
|
||||
|
||||
### Public variables ###
|
||||
|
||||
### Private variables ###
|
||||
|
||||
### Onready variables ###
|
||||
onready var _weapon_ammo_label: Label = $WeaponInfo/VBoxContainer/LabelAmmo
|
||||
onready var _weapon_tex_rect: TextureRect = $WeaponInfo/VBoxContainer/WeaponIcon
|
||||
onready var _label_reload: Label = $ReloadLabel
|
||||
onready var _animation_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
|
||||
############################
|
||||
# Engine Callback Methods #
|
||||
############################
|
||||
|
||||
|
||||
############################
|
||||
# Public Methods #
|
||||
############################
|
||||
func update_weapon_ammo(remaining: int) -> void:
|
||||
_weapon_ammo_label.text = "%02d / INF" % remaining
|
||||
if remaining <= 0:
|
||||
|
|
@ -43,13 +22,3 @@ func update_weapon_ammo(remaining: int) -> void:
|
|||
func update_weapon_icon(icon: Texture) -> void:
|
||||
_weapon_tex_rect.texture = icon
|
||||
|
||||
|
||||
############################
|
||||
# Signal Connected Methods #
|
||||
############################
|
||||
|
||||
|
||||
|
||||
############################
|
||||
# Private Methods #
|
||||
############################
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ onready var _option_btn_msaa: OptionButton = find_node("MSAAOptionButton")
|
|||
# Engine Callback Methods #
|
||||
############################
|
||||
func _ready() -> void:
|
||||
_slider_audio_master.value = UserPreferences.audio_vol[UserPreferences.AudioBuses.Master]
|
||||
_slider_audio_sfx.value = UserPreferences.audio_vol[UserPreferences.AudioBuses.Sfx]
|
||||
_slider_audio_music.value = UserPreferences.audio_vol[UserPreferences.AudioBuses.Music]
|
||||
_slider_audio_ui.value = UserPreferences.audio_vol[UserPreferences.AudioBuses.Ui]
|
||||
_slider_audio_master.value = UserPreferences.audio_vol[UserPreferences.AudioBuses.MASTER]
|
||||
_slider_audio_sfx.value = UserPreferences.audio_vol[UserPreferences.AudioBuses.SFX]
|
||||
_slider_audio_music.value = UserPreferences.audio_vol[UserPreferences.AudioBuses.MUSIC]
|
||||
_slider_audio_ui.value = UserPreferences.audio_vol[UserPreferences.AudioBuses.UI]
|
||||
|
||||
_slider_mouse_sensitivity.value = UserPreferences.mouse_sensitivity
|
||||
_check_btn_toggle_sprint.pressed = UserPreferences.toggle_sprint
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ var distance_vector: Vector3
|
|||
var _collider: Spatial
|
||||
|
||||
### Onready variables ###
|
||||
onready var _max_range_squared: int = pow(max_range, 2)
|
||||
onready var _max_range_squared: float = pow(max_range, 2)
|
||||
onready var _mesh_inst: MeshInstance = $MeshInstance
|
||||
onready var _collision_shape: CollisionShape = $CollisionShape
|
||||
onready var _particles: Particles = $Particles
|
||||
|
|
|
|||
|
|
@ -15,14 +15,14 @@ signal reload_unload_anim_done()
|
|||
signal reload_load_anim_done()
|
||||
|
||||
### Enums ###
|
||||
enum SLOT_TYPE{PRIMARY, SECONDARY}
|
||||
enum SlotType{PRIMARY, SECONDARY}
|
||||
|
||||
### Exported variables ###
|
||||
export(SLOT_TYPE) var slot_type: int
|
||||
export(SlotType) var slot_type: int
|
||||
|
||||
export(Texture) var icon: Texture
|
||||
export(PackedScene) var bullet_packed_scene: PackedScene
|
||||
export(float) var bullet_speed: float = 50
|
||||
export(float) var bullet_speed: float = 50.0
|
||||
export(int) var bullet_damage: int = 10
|
||||
export(int) var max_range: int = 60
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue