reticle moves when firing, stunned enemies have stars now
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user