reticle moves when firing, stunned enemies have stars now

This commit is contained in:
derek
2024-12-13 12:05:52 -06:00
parent b6a9e9a112
commit 9bb5332ba6
30 changed files with 629 additions and 84 deletions

View File

@@ -120,9 +120,7 @@ func refresh_scene():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
#quit game and eventually go to menu
if Input.is_action_just_pressed("escape"):
pause_menu()
pass
@@ -199,20 +197,19 @@ func pickup_spawn():
item_spawn.rand_amt = randi_range(25,100)
return item_spawn
func pause_menu():
if paused:
Engine.time_scale = engine_time_scale_cache
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
player.toggle_hud(true)
player.pause_menu.hide()
else:
engine_time_scale_cache = Engine.time_scale
Engine.time_scale = 0
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
player.toggle_hud(false)
player.pause_menu.show()
paused = !paused
#func pause_menu():
#if paused:
#get_tree().paused = false
#Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
#player.toggle_hud(true)
#player.pause_menu.hide()
#else:
#get_tree().paused = true
#Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
#player.toggle_hud(false)
#player.pause_menu.show()
#
#paused = !paused
func save_quit():
SaveLoad.save_game_data(level_name)

View File

@@ -106,7 +106,7 @@ func fire():
player.recoil.add_recoil(Vector3(0,recoil_amount.y,recoil_amount.z),10,10)
player.recoil.add_gun_recoil(recoil_amount.x)
player.velocity += player.bullet_ray.global_basis * Vector3(0,0, kick_amount)
SaveLoad.shots_fired = SaveLoad.null_data_check(SaveLoad.shots_fired, 1)
SignalBus.emit_signal("shot_fired")
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

@@ -99,7 +99,7 @@ func shoot(delta):
player.recoil.add_recoil(Vector3(0,recoil_amount.y,recoil_amount.z),10,10)
player.recoil.add_gun_recoil(recoil_amount.x)
#player.velocity += player.bullet_ray.global_basis * Vector3(0,0, kick_amount)
SaveLoad.shots_fired = SaveLoad.null_data_check(SaveLoad.shots_fired, 1)
SignalBus.emit_signal("shot_fired")
if fire_mode != 0:
cycle_count -= 1

View File

@@ -2,21 +2,29 @@ extends Control
@export var radial_stamina : bool = false
## VIEWPORT
var viewportWidth
var viewportHeight
var current_stam_bar
var stam_bar_visible : bool = false
var interact_visible : bool = false
var health_bar_start_pos
var money_count : int = 0
var crosshair_target
@onready var level_control = get_tree().current_scene
@onready var player = level_control.player
@onready var stamina_bar: TextureProgressBar = $StaminaBar
@onready var stamina_bar_2: ProgressBar = $StaminaBar2
@onready var health_bar: ProgressBar = $HealthBar
@onready var gun_name: Label = $"MarginContainer/VBoxContainer/Gun Name"
@onready var ammo: Label = $MarginContainer/VBoxContainer/Ammo
@onready var ammo_current: Label = $MarginContainer/VBoxContainer/HBoxContainer/AmmoCurrent
@onready var ammo_reserve: Label = $MarginContainer/VBoxContainer/HBoxContainer/AmmoReserve
@onready var money: Label = $Money
@onready var crosshair: TextureRect = $Crosshair
@onready var crosshair_center: TextureRect = $CrosshairCenter
const FULL_WHITE = Color(1, 1, 1, 1)
const TRANSPARENT = Color(1, 1, 1, 0)
@@ -25,14 +33,24 @@ const ORANGE_COLOR = Color(0.822, 0.318, 0.086)
const GREEN_COLOR = Color(0, 0.608, 0.172)
const STAM_BAR_MAX_OPACITY = 1.0
const CROSSHAIR_SIZE = Vector2(40,40)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# Get Viewport size
viewportWidth = get_viewport().size.x
viewportHeight = get_viewport().size.y
SignalBus.player_hit.connect(player_hit)
SignalBus.shot_fired.connect(crosshair_size_change)
health_bar.max_value = level_control.start_health
health_bar_start_pos = health_bar.position
crosshair_target = CROSSHAIR_SIZE
if radial_stamina:
current_stam_bar = stamina_bar
stamina_bar_2.visible = false
@@ -44,6 +62,14 @@ func _ready() -> void:
func _process(delta: float) -> void:
player = level_control.player
if player != null:
# Crosshair
crosshair_target = lerp(crosshair_target,CROSSHAIR_SIZE,delta * 5)
crosshair.size = lerp(crosshair.size, crosshair_target,delta * 20)
crosshair.position = Vector2(viewportWidth/2,viewportHeight/2) + (crosshair.size/-2)
crosshair_center.position = Vector2(viewportWidth/2,viewportHeight/2) + (crosshair_center.scale * crosshair_center.size/-2)
stamina_bar.scale = (crosshair.size/CROSSHAIR_SIZE) * Vector2(.185,.185)
stamina_bar.position = Vector2(viewportWidth/2,viewportHeight/2) + (stamina_bar.scale * stamina_bar.size/-2)
#HEALTH
health_bar.value = level_control.health
if level_control.health <= 2:
@@ -72,10 +98,13 @@ func _process(delta: float) -> void:
current_stam_bar.value = player.remaining_stamina
if player.gun != null:
ammo.text = str(level_control.ammo_current[level_control.current_gun_index]) +" | " + str(level_control.ammo_reserve[level_control.current_gun_index])
lerp_color(ammo,RED_COLOR,FULL_WHITE,level_control.ammo_current[level_control.current_gun_index],player.gun.max_ammo,.5)
ammo_current.text = str(level_control.ammo_current[level_control.current_gun_index]).pad_zeros(2)
ammo_reserve.text = str(level_control.ammo_reserve[level_control.current_gun_index]).pad_zeros(3)
lerp_color(ammo_current,RED_COLOR,FULL_WHITE,level_control.ammo_current[level_control.current_gun_index],player.gun.max_ammo,.5)
lerp_color(ammo_reserve,RED_COLOR,FULL_WHITE,level_control.ammo_reserve[level_control.current_gun_index],player.gun.max_ammo*2,.5)
else:
fade_in_out(ammo,1,false,10,delta)
fade_in_out(ammo_current,1,false,10,delta)
fade_in_out(ammo_reserve,1,false,10,delta)
fade_in_out(crosshair,1,false,10,delta)
if player.gun != null:
@@ -117,6 +146,11 @@ func _process(delta: float) -> void:
## FADE ELEMENTS IN AND OUT
fade_in_out(current_stam_bar,STAM_BAR_MAX_OPACITY,stam_bar_visible,5,delta)
func crosshair_size_change():
crosshair_target += Vector2(40,40)
func shake_element(amount):
var rand_x = randf_range(-amount,amount)
var rand_y = randf_range(-amount,amount)

View File

@@ -9,6 +9,7 @@ extends RigidBody3D
@onready var blast_radius_area: Area3D = $BlastRadius
@onready var radius_shape: CollisionShape3D = $BlastRadius/CollisionShape3D
@onready var audio_drop: AudioStreamPlayer3D = $audio_drop
@onready var flames: GPUParticles3D = $Flames
var leak_hp = false
var blast_amount
@@ -24,7 +25,7 @@ func _ready() -> void:
func _process(delta: float) -> void:
if leak_hp:
hp -= delta * HP_LEAK_RATE
print("HP - ",hp)
flames.emitting = true
if hp <= 0:
explode()

View File

@@ -1,6 +1,7 @@
extends Control
@onready var level_control = get_tree().current_scene
@onready var player: CharacterBody3D = $"../../../.."
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -13,7 +14,7 @@ func _process(delta: float) -> void:
func _on_resume_pressed() -> void:
level_control.pause_menu()
resume()
func _on_save__quit_pressed() -> void:
@@ -22,3 +23,20 @@ func _on_save__quit_pressed() -> void:
func _on_load_pressed() -> void:
SaveLoad.load_data()
func _unhandled_input(event: InputEvent) -> void:
if Input.is_action_just_pressed("escape"):
pause()
func pause():
get_tree().paused = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
player.toggle_hud(false)
player.pause_menu.show()
func resume():
hide()
get_tree().paused = false
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
player.toggle_hud(true)

View File

@@ -131,7 +131,7 @@ func shoot(delta):
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
audio_fire.play()
anim_player.play("shoot") #actual bullet spawn triggered by animation
SaveLoad.shots_fired = SaveLoad.null_data_check(SaveLoad.shots_fired, 1)
SignalBus.emit_signal("shot_fired")
if fire_mode != 0:
cycle_count -= 1

View File

@@ -97,7 +97,7 @@ func shoot(delta):
instance_bullet.player_position = player.global_position
get_tree().get_root().add_child(instance_bullet)
player.recoil.add_recoil(recoil_amount,10,10)
SaveLoad.shots_fired = SaveLoad.null_data_check(SaveLoad.shots_fired, 1)
SignalBus.emit_signal("shot_fired")
if fire_mode != 0:
cycle_count -= 1

View File

@@ -22,6 +22,8 @@ var reserve_ammo
var persistent_save_path = "user://persistent_data.save"
func _ready() -> void:
SignalBus.shot_fired.connect(shot_fired)
if player_deaths == null:
player_deaths = 0
if enemies_killed == null:
@@ -218,3 +220,6 @@ func load_resource_path(array):
var i_loaded = load(i)
final_array.append(i_loaded)
return final_array
func shot_fired():
null_data_check(shots_fired, 1)

View File

@@ -2,10 +2,13 @@ extends Node
signal switch_changed()
signal switch_timeout()
signal enemy_count_changed()
signal game_loaded()
##PLAYER
signal player_hit()
signal shot_fired()
signal enemy_hit()
signal enemy_killed()
signal king_killed()
signal enemy_count_changed()
signal game_loaded()
signal player_hit()
signal weapon_list_changed()

View File

@@ -48,6 +48,7 @@ const MAX_AV = 10
@onready var turret_look = $TurretLook
@onready var smoke: GPUParticles3D = $TurretLook/Turret/Smoke
@onready var smoke_2: GPUParticles3D = $TurretLook/Turret/Smoke2
@onready var stunned_stars: Node3D = $body/StunnedStars
@onready var outline_meshes = [$TurretLook/Turret/turretoutline,
$body/leg1/foot1/foot1outline,
$body/leg1/leg1outline,
@@ -92,6 +93,7 @@ func _process(delta):
velocity = hive_velocity
if !stunned:
stunned_stars.visible = false
#Sightline
if turret_look_next.is_colliding() and turret_look_next.get_collider().is_in_group("player"):
player_in_view = true
@@ -104,6 +106,7 @@ func _process(delta):
else:
body.rotation.y = lerp(body.rotation.y, body.rotation.y + 10, delta * .1)
turret_look.rotation.y = lerp(turret_look.rotation.y,turret_look.rotation.y - 10,delta * .5)
stunned_stars.visible = true
#apply gravity
if !is_on_floor():

View File

@@ -121,7 +121,7 @@ func fire():
spawn_casing()
player.recoil.add_recoil(Vector3(0,recoil_amount.y,recoil_amount.z),10,10)
player.recoil.add_gun_recoil(recoil_amount.x)
SaveLoad.shots_fired = SaveLoad.null_data_check(SaveLoad.shots_fired, 1)
SignalBus.emit_signal("shot_fired")
if fire_mode != 0:
cycle_count -= 1