Add dash cooldown to come from player stats
This commit is contained in:
parent
c6cee88ab2
commit
ec05aa73b5
@ -1,5 +1,7 @@
|
|||||||
class_name CharacterStats extends Resource
|
class_name CharacterStats extends Resource
|
||||||
|
|
||||||
|
signal level_up_notification()
|
||||||
|
|
||||||
class Ability:
|
class Ability:
|
||||||
var min_modifier: float
|
var min_modifier: float
|
||||||
var max_modifier: float
|
var max_modifier: float
|
||||||
@ -31,6 +33,9 @@ var xp: int = 0:
|
|||||||
level_up()
|
level_up()
|
||||||
boundary = perc_level_up_boundary()
|
boundary = perc_level_up_boundary()
|
||||||
|
|
||||||
|
const MIN_DASH_COOLDOWN: float = 1.5
|
||||||
|
const MAX_DASH_COOLDOWN: float = 0.5
|
||||||
|
|
||||||
# Damage bonus on attack
|
# Damage bonus on attack
|
||||||
var strength: Ability = Ability.new(2.0, 12.0)
|
var strength: Ability = Ability.new(2.0, 12.0)
|
||||||
# Movement speed meters/second
|
# Movement speed meters/second
|
||||||
@ -40,15 +45,19 @@ var endurance: Ability = Ability.new(5.0, 25.0)
|
|||||||
# Crit chance
|
# Crit chance
|
||||||
var agility: Ability = Ability.new(0.05, 0.25)
|
var agility: Ability = Ability.new(0.05, 0.25)
|
||||||
|
|
||||||
|
func get_max_hp() -> float:
|
||||||
|
return 20 + int(level * endurance.get_modifier())
|
||||||
|
|
||||||
|
func get_dash_cooldown() -> float:
|
||||||
|
return agility.percentile_lerp(MIN_DASH_COOLDOWN, MAX_DASH_COOLDOWN)
|
||||||
|
|
||||||
func level_up() -> void:
|
func level_up() -> void:
|
||||||
level += 1
|
level += 1
|
||||||
strength.inc()
|
strength.inc()
|
||||||
speed.inc()
|
speed.inc()
|
||||||
endurance.inc()
|
endurance.inc()
|
||||||
agility.inc()
|
agility.inc()
|
||||||
print("Leveled up!")
|
level_up_notification.emit()
|
||||||
print(level)
|
|
||||||
printt(strength.score, speed.score, endurance.score, agility.score)
|
|
||||||
|
|
||||||
func perc_level_up_boundary() -> int:
|
func perc_level_up_boundary() -> int:
|
||||||
return int(50 * pow(1.2, level))
|
return int(50 * pow(1.2, level))
|
||||||
|
|||||||
@ -97,6 +97,7 @@ mesh_list = Array[Terrain3DMeshAsset]([SubResource("Terrain3DMeshAsset_856t6")])
|
|||||||
texture_list = Array[Terrain3DTextureAsset]([SubResource("Terrain3DTextureAsset_0slur")])
|
texture_list = Array[Terrain3DTextureAsset]([SubResource("Terrain3DTextureAsset_0slur")])
|
||||||
|
|
||||||
[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_dn2un"]
|
[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_dn2un"]
|
||||||
|
energy_multiplier = 4.0
|
||||||
use_debanding = false
|
use_debanding = false
|
||||||
|
|
||||||
[sub_resource type="Sky" id="Sky_7iny7"]
|
[sub_resource type="Sky" id="Sky_7iny7"]
|
||||||
@ -112,6 +113,7 @@ tonemap_mode = 3
|
|||||||
tonemap_white = 6.0
|
tonemap_white = 6.0
|
||||||
|
|
||||||
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_0slur"]
|
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_0slur"]
|
||||||
|
auto_exposure_scale = 0.2
|
||||||
|
|
||||||
[node name="Level" type="Node3D"]
|
[node name="Level" type="Node3D"]
|
||||||
|
|
||||||
@ -127,6 +129,7 @@ environment = SubResource("Environment_cxs0p")
|
|||||||
camera_attributes = SubResource("CameraAttributesPractical_0slur")
|
camera_attributes = SubResource("CameraAttributesPractical_0slur")
|
||||||
script = ExtResource("1_1jhfv")
|
script = ExtResource("1_1jhfv")
|
||||||
current_time = 11.5
|
current_time = 11.5
|
||||||
|
reflected_energy = 4.0
|
||||||
metadata/_custom_type_script = "uid://bmywk4wvcp0lr"
|
metadata/_custom_type_script = "uid://bmywk4wvcp0lr"
|
||||||
|
|
||||||
[node name="SunLight" type="DirectionalLight3D" parent="Sky3D"]
|
[node name="SunLight" type="DirectionalLight3D" parent="Sky3D"]
|
||||||
@ -220,7 +223,7 @@ clouds_cumulus_thickness = 0.0243
|
|||||||
clouds_cumulus_coverage = 0.55
|
clouds_cumulus_coverage = 0.55
|
||||||
clouds_cumulus_absorption = 2.0
|
clouds_cumulus_absorption = 2.0
|
||||||
clouds_cumulus_noise_freq = 2.7
|
clouds_cumulus_noise_freq = 2.7
|
||||||
clouds_cumulus_intensity = 1.0
|
clouds_cumulus_intensity = 0.9997
|
||||||
clouds_cumulus_mie_intensity = 1.0
|
clouds_cumulus_mie_intensity = 1.0
|
||||||
clouds_cumulus_mie_anisotropy = 0.206
|
clouds_cumulus_mie_anisotropy = 0.206
|
||||||
clouds_cumulus_size = 0.5
|
clouds_cumulus_size = 0.5
|
||||||
|
|||||||
@ -15,7 +15,6 @@ func _physics_process(delta: float) -> void:
|
|||||||
return
|
return
|
||||||
|
|
||||||
player.velocity = direction * player.stats.speed.get_modifier() * speed_multiplier
|
player.velocity = direction * player.stats.speed.get_modifier() * speed_multiplier
|
||||||
print(player.stats.speed.get_modifier())
|
|
||||||
time_remaining -= delta
|
time_remaining -= delta
|
||||||
if time_remaining <= 0:
|
if time_remaining <= 0:
|
||||||
direction = Vector3.ZERO
|
direction = Vector3.ZERO
|
||||||
@ -33,5 +32,5 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
if not direction.is_zero_approx():
|
if not direction.is_zero_approx():
|
||||||
player.rig.playback.travel("Dash")
|
player.rig.playback.travel("Dash")
|
||||||
particles.emitting = true
|
particles.emitting = true
|
||||||
timer.start(1.0)
|
timer.start(player.stats.get_dash_cooldown())
|
||||||
time_remaining = dash_duration
|
time_remaining = dash_duration
|
||||||
|
|||||||
@ -16,6 +16,7 @@ var current_health: float:
|
|||||||
func update_max_health(max_hp_in: float) -> void:
|
func update_max_health(max_hp_in: float) -> void:
|
||||||
max_health = max_hp_in
|
max_health = max_hp_in
|
||||||
current_health = max_health
|
current_health = max_health
|
||||||
|
printt("Health changed", max_health, current_health)
|
||||||
|
|
||||||
func take_damage(damage_in: float, is_critical: bool) -> void:
|
func take_damage(damage_in: float, is_critical: bool) -> void:
|
||||||
var damage = damage_in
|
var damage = damage_in
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
extends CharacterBody3D
|
class_name Player extends CharacterBody3D
|
||||||
class_name Player
|
|
||||||
|
|
||||||
|
|
||||||
const JUMP_VELOCITY: float = 4.5
|
const JUMP_VELOCITY: float = 4.5
|
||||||
const DECAY: float = 8.0
|
const DECAY: float = 8.0
|
||||||
@ -29,7 +27,10 @@ var _attack_direction: Vector3 = Vector3.ZERO
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
health_component.update_max_health(30.0)
|
health_component.update_max_health(stats.get_max_hp())
|
||||||
|
stats.level_up_notification.connect(
|
||||||
|
func(): health_component.update_max_health(stats.get_max_hp())
|
||||||
|
)
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
frame_camera_rotation()
|
frame_camera_rotation()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user