tweaks to controller and savegames are stored by level

This commit is contained in:
Derek
2024-12-09 22:49:44 -06:00
parent 7ed9d2a774
commit 0ec82d84aa
10 changed files with 73 additions and 25 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -1,8 +1,7 @@
[gd_scene load_steps=48 format=4 uid="uid://ddyfy6iosbgsj"]
[gd_scene load_steps=47 format=4 uid="uid://ddyfy6iosbgsj"]
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_jjeos"]
[ext_resource type="PackedScene" uid="uid://b5eclfg0cmmal" path="res://assets/revolver_1.tscn" id="2_7dd4i"]
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="3_i5y5k"]
[ext_resource type="LightmapGIData" uid="uid://boq5kgy4vhxxw" path="res://levels/blockout_3.lmbake" id="4_hwpk3"]
[ext_resource type="Material" uid="uid://b6hhomp4kcjvb" path="res://assets/materials/prototype/tadaoando.tres" id="4_oo277"]
[ext_resource type="Material" uid="uid://isd7ca2ymvs8" path="res://assets/materials/prototype/CeilingLight.tres" id="5_76d5c"]
@@ -346,7 +345,6 @@ size = Vector3(5.505, 7.07, 1.35)
script = ExtResource("1_jjeos")
player = NodePath("Player")
gun_1 = ExtResource("2_7dd4i")
gun_2 = ExtResource("3_i5y5k")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_ro14g")
@@ -354,7 +352,6 @@ camera_attributes = SubResource("CameraAttributesPractical_23vvh")
[node name="Player" parent="." instance=ExtResource("6_m8xxf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.281984, 28.8469, 30.8246)
AUDIO = false
[node name="LightmapGI" type="LightmapGI" parent="."]
quality = 3
@@ -511,7 +508,16 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.38419e-07, -1.90735e-06)
shape = SubResource("BoxShape3D_4andu")
[node name="Tree1" parent="." instance=ExtResource("20_2qgoy")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -0.668062, -0.93, 0.265823)
transform = Transform3D(5, 0, 0, 0, 5, 0, 0, 0, 5, -0.668062, -0.93, 0.265823)
[node name="SpotLight3D" type="SpotLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -2.7933, 45.8303, 4.27025)
light_energy = 11.83
light_bake_mode = 1
shadow_enabled = true
spot_range = 54.245
spot_attenuation = 0.2
spot_angle = 27.1
[connection signal="switch_hit" from="Door1/switch/StaticBody3D" to="Door1/switch" method="_on_static_body_3d_switch_hit"]
[connection signal="switch_hit" from="Door1/switch2/StaticBody3D" to="Door1/switch2" method="_on_static_body_3d_switch_hit"]

View File

@@ -11,7 +11,7 @@ config_version=5
[application]
config/name="First Person Test"
run/main_scene="res://scenes/asset_checker.tscn"
run/main_scene="res://assets/blockout_2.tscn"
config/features=PackedStringArray("4.3", "Forward Plus")
config/icon="res://icon.svg"
@@ -59,25 +59,21 @@ persist=""
move_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
move_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
move_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
jump={
@@ -113,6 +109,7 @@ reload={
inspect={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":73,"key_label":0,"unicode":105,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":true,"script":null)
]
}
scroll_up={
@@ -135,16 +132,19 @@ escape={
interact={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":true,"script":null)
]
}
flashlight={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":true,"script":null)
]
}
kick={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":true,"script":null)
]
}
numb_1={

View File

@@ -309,6 +309,7 @@ shadow_mesh = SubResource("ArrayMesh_7g1e1")
[node name="AssetChecker" type="Node3D" node_paths=PackedStringArray("player")]
script = ExtResource("1_saj4q")
load_save = false
player = NodePath("Player")
gun_1 = ExtResource("2_ntm2q")

View File

@@ -22,6 +22,7 @@ var dead_player = preload("res://assets/dead_cam.tscn")
const CLEARED_ANNOUNCE = preload("res://assets/cleared_announce.tscn")
const DEAD_ANNOUNCE = preload("res://assets/dead_announce.tscn")
var level_name
var paused = false
var health = start_health
var pickups = []
@@ -43,6 +44,8 @@ var engine_time_scale_cache : float = 1.0
# Called when the node enters the scene tree for the first time.
func _ready():
level_name = self.get_name()
print("LEVEL NAME ",level_name)
#connect to signals
SignalBus.enemy_count_changed.connect(enemy_count)
@@ -54,7 +57,10 @@ func _ready():
GameGlobals.game_loaded = true
SignalBus.emit_signal("game_loaded")
else:
SaveLoad.load_save_game_data()
if SaveLoad.check_save_game_exists(level_name):
SaveLoad.load_save_game_data(level_name)
else:
refresh_scene()
#Spawn Crown
if SaveLoad.last_hit_path:
@@ -209,5 +215,5 @@ func pause_menu():
paused = !paused
func save_quit():
SaveLoad.save_game_data()
SaveLoad.save_game_data(level_name)
get_tree().quit()

View File

@@ -44,6 +44,7 @@ func _physics_process(delta):
func picked_up():
player.pickup_sound.pitch_scale = 1 + randf_range(-.3,.3)
player.pickup_sound.play()
Input.start_joy_vibration(0,.1,.1,.1)
match pickupType:
# Ammo
0:

View File

@@ -23,7 +23,9 @@ const ADS_POS = Vector3(0,-.05,-.45)
#JOYSTICK SETTINGS
const JOYSTICK_SENSITIVITY = .06
var adj_sensitivity = JOYSTICK_SENSITIVITY
const JOYSTICK_DEADZONE = 0.05
const R_JOYSTICK_DEADZONE = 0.05
const L_JOYSTICK_DEADZONE = .2
const L_JOYSTICK_SENSITIVITY = .1
var speed
var double_jump = true
@@ -208,9 +210,18 @@ func _physics_process(delta):
velocity.y += JUMP_VELOCITY
double_jump = false
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
## HANDLE MOVEMENT DIRECTION
var input_dir
var direction
#GetKB Input
input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
#Get Joy Input
input_dir += joypad_walk()
if abs(Input.get_joy_axis(0,JOY_AXIS_LEFT_X)) > L_JOYSTICK_SENSITIVITY or abs(Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)) > L_JOYSTICK_SENSITIVITY:
direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y))
else:
direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
# Handle Sprint
if Input.is_action_just_pressed("sprint") and !is_on_floor():
if air_dash > 0:
@@ -287,6 +298,7 @@ func _physics_process(delta):
var recoil_amount = Vector3(-.3,0,0)
land_sound.volume_db = land_volume
land_sound.play()
Input.start_joy_vibration(0,.1,.1,.1)
recoil.add_recoil(recoil_amount,10,10)
moving_fast_top_speed = 0.0
moving_fast = false
@@ -414,15 +426,28 @@ func _physics_process(delta):
weapon_sway(delta)
weapon_bob(velocity.length(), delta)
func joypad_walk():
# Joypad right stick look control
var dir_out = Vector2(0,0)
var xAxis = Input.get_joy_axis(0,JOY_AXIS_LEFT_X)
var yAxis = Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
if abs(xAxis) > L_JOYSTICK_DEADZONE:
dir_out.x = xAxis
if abs(yAxis) > L_JOYSTICK_DEADZONE:
dir_out.y = yAxis
return dir_out
func joypad_look(delta):
# Joypad right stick look control
var xAxis = Input.get_joy_axis(0,JOY_AXIS_RIGHT_X)
var yAxis = Input.get_joy_axis(0,JOY_AXIS_RIGHT_Y)
var aim_assist
if abs(xAxis) > JOYSTICK_DEADZONE:
if abs(xAxis) > R_JOYSTICK_DEADZONE:
self.rotate_y(-xAxis * JOYSTICK_SENSITIVITY * 1)
if abs(yAxis) > JOYSTICK_DEADZONE:
if abs(yAxis) > R_JOYSTICK_DEADZONE:
head.rotate_x(-yAxis * JOYSTICK_SENSITIVITY * 1)
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
@@ -471,7 +496,6 @@ func _on_pick_up_detection_body_entered(body):
if body.is_in_group("pickup"):
if body.pickupable:
body.picked_up()
Input.start_joy_vibration(0,.1,.1,.1)
if body.is_in_group("weapon_pickup"):
weapon_pickup_audio.play()
Input.start_joy_vibration(0,.1,.1,.1)
@@ -496,9 +520,11 @@ func weapon_tilt(input_x, delta):
func weapon_sway(delta):
if !ads:
var joy_input = Vector2(Input.get_joy_axis(0,JOY_AXIS_RIGHT_X)*5,Input.get_joy_axis(0,JOY_AXIS_RIGHT_Y)*5)
mouse_input = lerp(mouse_input, Vector2.ZERO, 10 * delta)
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, mouse_input.y * weapon_sway_amount, 5 * delta)
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, mouse_input.x * weapon_sway_amount, 5 * delta)
joy_input = lerp(joy_input,Vector2.ZERO,10 * delta)
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, (mouse_input.y + joy_input.y) * weapon_sway_amount, 5 * delta)
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, (mouse_input.x + joy_input.x) * weapon_sway_amount, 5 * delta)
func weapon_bob(vel : float, delta):
if weapon_holder:

View File

@@ -158,6 +158,7 @@ func fire(delta):
player.recoil.add_recoil(Vector3(0,recoil_amount.y,recoil_amount.z),10,recoil_speed_change)
player.recoil.add_gun_recoil(recoil_amount.x)
chamber.rotate_object_local(Vector3(0,-1,0),deg_to_rad(60))
Input.start_joy_vibration(0,.5,.9,.2)
func reload():
if level_control.ammo_current[gun_index] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and level_control.ammo_reserve[gun_index] > 0:

View File

@@ -20,7 +20,6 @@ var reserve_ammo
## SAVE DATA PATHS
var persistent_save_path = "user://persistent_data.save"
var game_save_path = "user://gamesave.save"
func _ready() -> void:
if player_deaths == null:
@@ -59,9 +58,10 @@ func load_persistent_data():
enemies_killed = null
func save_game_data():
func save_game_data(level_name):
var level_control = get_tree().current_scene
var player = level_control.player
var game_save_path = str("user://",level_name,"_gamesave.save")
var file = FileAccess.open(game_save_path, FileAccess.WRITE)
#ASSIGN DATA TO VARIABLES
@@ -115,10 +115,17 @@ func clear_persistent_data():
print("PERSISTENT DATA CLEARED")
file.close()
func load_save_game_data():
func check_save_game_exists(level_name):
var game_save_path = str("user://",level_name,"_gamesave.save")
if FileAccess.file_exists(game_save_path):
return true
else:
return false
func load_save_game_data(level_name):
var level_control = get_tree().current_scene
var player = level_control.player
var game_save_path = str("user://",level_name,"_gamesave.save")
if FileAccess.file_exists(game_save_path):
var file = FileAccess.open(game_save_path, FileAccess.READ)