added stamina and health bar, gold can now be picked up
This commit is contained in:
20
Prefabs/DefaultTheme.tres
Normal file
20
Prefabs/DefaultTheme.tres
Normal file
@@ -0,0 +1,20 @@
|
||||
[gd_resource type="Theme" load_steps=3 format=3 uid="uid://bey4nvrdo2vy"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://peikxwadqo68" path="res://Assets/Fonts/UnifrakturCook-Bold.ttf" id="1_6y4xm"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_70173"]
|
||||
|
||||
[resource]
|
||||
default_font = ExtResource("1_6y4xm")
|
||||
default_font_size = 100
|
||||
Label/colors/font_color = Color(1, 0.769324, 0.396122, 1)
|
||||
Label/colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
Label/colors/font_shadow_color = Color(0, 0, 0, 1)
|
||||
Label/constants/line_spacing = 3
|
||||
Label/constants/outline_size = 0
|
||||
Label/constants/shadow_offset_x = 3
|
||||
Label/constants/shadow_offset_y = 3
|
||||
Label/constants/shadow_outline_size = 10
|
||||
Label/font_sizes/font_size = 100
|
||||
Label/styles/normal = SubResource("StyleBoxEmpty_70173")
|
||||
ProgressBar/font_sizes/font_size = 40
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://bici4k5vkuoos" path="res://Scripts/player_camera.gd" id="1_ocbkm"]
|
||||
[ext_resource type="Script" uid="uid://bnqpqdped5uw2" path="res://Scripts/camera_Look.gd" id="2_8uhk6"]
|
||||
[ext_resource type="FontFile" uid="uid://peikxwadqo68" path="res://Assets/Fonts/UnifrakturCook-Bold.ttf" id="2_70173"]
|
||||
[ext_resource type="Theme" uid="uid://bey4nvrdo2vy" path="res://Prefabs/DefaultTheme.tres" id="3_8uhk6"]
|
||||
|
||||
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_ocbkm"]
|
||||
dof_blur_far_enabled = true
|
||||
@@ -11,20 +11,11 @@ dof_blur_near_enabled = true
|
||||
dof_blur_near_distance = 6.0
|
||||
dof_blur_amount = 0.5
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_70173"]
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_6wc88"]
|
||||
bg_color = Color(0.458824, 0, 0.145098, 1)
|
||||
|
||||
[sub_resource type="Theme" id="Theme_8uhk6"]
|
||||
default_font = ExtResource("2_70173")
|
||||
default_font_size = 100
|
||||
Label/colors/font_color = Color(1, 0.785333, 0.44, 1)
|
||||
Label/colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
Label/colors/font_shadow_color = Color(0, 0, 0, 1)
|
||||
Label/constants/line_spacing = 3
|
||||
Label/constants/outline_size = 0
|
||||
Label/constants/shadow_offset_x = 3
|
||||
Label/constants/shadow_offset_y = 3
|
||||
Label/constants/shadow_outline_size = 10
|
||||
Label/styles/normal = SubResource("StyleBoxEmpty_70173")
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8uhk6"]
|
||||
bg_color = Color(0.457868, 0.677542, 0.145981, 1)
|
||||
|
||||
[node name="CameraFollow" type="Node3D"]
|
||||
script = ExtResource("1_ocbkm")
|
||||
@@ -41,9 +32,34 @@ anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="Label" type="Label" parent="Camera3D/Control"]
|
||||
[node name="BoxContainer" type="BoxContainer" parent="Camera3D/Control"]
|
||||
layout_mode = 1
|
||||
offset_right = 334.0
|
||||
offset_bottom = 153.0
|
||||
theme = SubResource("Theme_8uhk6")
|
||||
offset_right = 3400.0
|
||||
offset_bottom = 1440.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Camera3D/Control/BoxContainer"]
|
||||
custom_minimum_size = Vector2(236.82, 3.065)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="Camera3D/Control/BoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
theme = ExtResource("3_8uhk6")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_6wc88")
|
||||
value = 42.34
|
||||
|
||||
[node name="StaminaBar" type="ProgressBar" parent="Camera3D/Control/BoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 1
|
||||
theme = ExtResource("3_8uhk6")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_8uhk6")
|
||||
value = 42.34
|
||||
|
||||
[node name="GOLD" type="Label" parent="Camera3D/Control/BoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
theme = ExtResource("3_8uhk6")
|
||||
text = "Gold: 35"
|
||||
|
||||
@@ -45,6 +45,7 @@ data = PackedVector3Array(-1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1,
|
||||
transform = Transform3D(-0.222104, -0.488992, 0.843538, -0.308183, 0.856001, 0.415072, -0.925037, -0.167775, -0.34082, -2.70232, 4.11405, 0)
|
||||
light_bake_mode = 1
|
||||
shadow_enabled = true
|
||||
shadow_bias = 0.0
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_vab8d")
|
||||
|
||||
@@ -2,7 +2,7 @@ extends Camera3D
|
||||
|
||||
var height_target = position.y
|
||||
const CHANGE_AMT_ON_SCROLL = 4.0
|
||||
const CAM_CHANGE_SPEED = 2.0
|
||||
const CAM_CHANGE_SPEED = 4.0
|
||||
var MAX_CAM_HEIGHT = position.y + CHANGE_AMT_ON_SCROLL
|
||||
var MIN_CAM_HEIGHT = position.y - (CHANGE_AMT_ON_SCROLL * 2)
|
||||
|
||||
@@ -27,7 +27,7 @@ func camera_height_change(delta):
|
||||
if Input.is_action_just_pressed("scroll_down"):
|
||||
height_target = clamp(height_target + CHANGE_AMT_ON_SCROLL,MIN_CAM_HEIGHT,MAX_CAM_HEIGHT)
|
||||
|
||||
global_position.y = height_target
|
||||
global_position.y = lerp(global_position.y,height_target,delta * CAM_CHANGE_SPEED)
|
||||
#else:
|
||||
#var direction_to_target = global_position.y - height_target
|
||||
#var move_amount = direction_to_target * delta * CAM_CHANGE_SPEED
|
||||
|
||||
@@ -3,15 +3,13 @@ extends Node3D
|
||||
const GOLDCOIN = preload("res://Prefabs/goldcoin.tscn")
|
||||
|
||||
|
||||
|
||||
const MAX_AV = 15
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
var instance_coin = GOLDCOIN.instantiate()
|
||||
var av_x = randf_range(-10,10)
|
||||
var av_y = randf_range(-10,10)
|
||||
var av_z = randf_range(-10,10)
|
||||
|
||||
instance_coin.global_basis = global_basis
|
||||
var av_x = randf_range(-MAX_AV,MAX_AV)
|
||||
var av_y = randf_range(-MAX_AV,MAX_AV)
|
||||
var av_z = randf_range(-MAX_AV,MAX_AV)
|
||||
get_tree().current_scene.add_child(instance_coin)
|
||||
instance_coin.global_position = global_position
|
||||
instance_coin.angular_velocity = Vector3(av_x,av_y,av_z)
|
||||
get_tree().current_scene.add_child(instance_coin)
|
||||
|
||||
@@ -1,2 +1,24 @@
|
||||
extends RigidBody3D
|
||||
class_name Gold
|
||||
|
||||
var amount = 1
|
||||
var follow_target
|
||||
var spawn_out = false
|
||||
const SPAWN_OUT_SIZE = 4.0
|
||||
const SPAWN_OUT_HEIGHT = 14.0
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if follow_target != null:
|
||||
if spawn_out:
|
||||
#if global_position.y < SPAWN_OUT_HEIGHT: REMOVED BECAUSE I DIDN'T LIKE THE LOOK, LEAVING FOR NOW IN CASE I WANT TO MAKE A DIFFERENT EFFECT HAPPEN
|
||||
#linear_velocity = Vector3(0,10,0)
|
||||
#else:
|
||||
follow_target.gold += amount
|
||||
queue_free()
|
||||
else:
|
||||
if global_position.distance_to(follow_target.global_position) < .5:
|
||||
spawn_out = true
|
||||
else:
|
||||
var direction_to_player = global_position.direction_to(follow_target.global_position)
|
||||
var distance_to_player = global_position.distance_to(follow_target.global_position)
|
||||
linear_velocity = direction_to_player * (5 + distance_to_player * 3)
|
||||
|
||||
@@ -7,7 +7,10 @@ var dodge_direction
|
||||
@onready var anim_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
var gold_to_vacuum = []
|
||||
var current_gold
|
||||
var gold = 0
|
||||
|
||||
const MAX_HEALTH : float = 100
|
||||
var health = MAX_HEALTH
|
||||
|
||||
const MAX_STAMINA : float = 100
|
||||
var stamina = MAX_STAMINA
|
||||
@@ -19,26 +22,11 @@ const DODGE_STAMINA_COST = 30.0
|
||||
func _physics_process(delta: float) -> void:
|
||||
stamina_regen(delta)
|
||||
move_and_slide()
|
||||
vacuum_found_gold()
|
||||
|
||||
func stamina_regen(delta):
|
||||
if stamina < MAX_STAMINA:
|
||||
print("STAMINA : ", stamina)
|
||||
stamina = clamp(stamina + delta * STAMINA_REGEN_RATE,0,MAX_STAMINA)
|
||||
|
||||
func vacuum_found_gold():
|
||||
if gold_to_vacuum.size() > 0:
|
||||
for i in range(0,gold_to_vacuum.size()):
|
||||
#var magnet_target
|
||||
#if i == 0:
|
||||
#magnet_target = self.global_position
|
||||
#else:
|
||||
#magnet_target = gold_to_vacuum[i-1].global_position
|
||||
var direction_to_player = gold_to_vacuum[i].global_position.direction_to(self.global_position)
|
||||
var distance_to_player = gold_to_vacuum[i].global_position.distance_to(self.global_position)
|
||||
|
||||
gold_to_vacuum[i].linear_velocity = direction_to_player * (5 + distance_to_player)
|
||||
|
||||
func _on_area_3d_body_entered(body: Node3D) -> void:
|
||||
if body is Gold:
|
||||
gold_to_vacuum.append(body)
|
||||
body.follow_target = self
|
||||
|
||||
@@ -2,11 +2,18 @@ extends Node3D
|
||||
|
||||
@export var player : Player
|
||||
|
||||
@onready var gold_label: Label = $Camera3D/Control/BoxContainer/GOLD
|
||||
@onready var health_bar: ProgressBar = $Camera3D/Control/BoxContainer/VBoxContainer/HealthBar
|
||||
@onready var stamina_bar: ProgressBar = $Camera3D/Control/BoxContainer/VBoxContainer/StaminaBar
|
||||
|
||||
|
||||
const CAM_MOVE_SPEED = 5
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
follow_player(delta)
|
||||
|
||||
gold_label.text = "Gold : " + str(player.gold)
|
||||
stamina_bar.value = player.stamina
|
||||
health_bar.value = player.health
|
||||
|
||||
func follow_player(delta):
|
||||
var player_pos = player.global_position
|
||||
|
||||
@@ -3,7 +3,7 @@ class_name PlayerState
|
||||
|
||||
@export var move_speed = 10.0
|
||||
@export var move_transition_speed = 10.0
|
||||
@export var health_lost_on_fall = 2.0
|
||||
@export var health_lost_on_fall = 20.0
|
||||
|
||||
# respawn after falling
|
||||
const FALL_TIME_TO_RESPAWN : float = 3.0
|
||||
@@ -32,6 +32,7 @@ func respawn_on_fall(delta):
|
||||
else:
|
||||
fall_timer = FALL_TIME_TO_RESPAWN
|
||||
character.global_position = ground_pos_cached[0]
|
||||
character.health -= health_lost_on_fall
|
||||
|
||||
func apply_gravity(delta):
|
||||
if !character.is_on_floor():
|
||||
|
||||
Reference in New Issue
Block a user