initial player resource functions added, passive regeneration added
This commit is contained in:
parent
ec6b012341
commit
a405611b79
@ -1,14 +1,18 @@
|
||||
extends SceneTree
|
||||
|
||||
|
||||
# NOTE: not sure if these are final
|
||||
var exp_coefficient := 50
|
||||
var exp_exponent := 1.7
|
||||
|
||||
func level_eqn(experience):
|
||||
# return log(0.2 * experience + 5) + 1
|
||||
return pow(experience / 50, 0.5) + 1
|
||||
return pow(experience / exp_coefficient, 1/exp_exponent) + 1
|
||||
|
||||
|
||||
func experience_eqn(level):
|
||||
# return 5 * exp(level - 1) - 5
|
||||
return 50 * pow((level - 1), 1.7)
|
||||
return exp_coefficient * pow((level - 1), exp_exponent)
|
||||
|
||||
|
||||
func avg_difficulty():
|
||||
|
@ -185,7 +185,7 @@ nine_patch_stretch = true
|
||||
texture_under = ExtResource("4_ykyyt")
|
||||
texture_progress = ExtResource("5_rdg13")
|
||||
|
||||
[node name="PlayerHealthCurrent" type="Label" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerResourceBar"]
|
||||
[node name="PlayerResourceCurrent" type="Label" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerResourceBar"]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.0216216
|
||||
@ -197,7 +197,7 @@ text = "0"
|
||||
vertical_alignment = 1
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="PlayerHealthPercent" type="HBoxContainer" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerResourceBar"]
|
||||
[node name="PlayerResourcePercent" type="HBoxContainer" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerResourceBar"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
@ -211,19 +211,19 @@ offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PlayerHealthPercentVal" type="Label" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerResourceBar/PlayerHealthPercent"]
|
||||
[node name="PlayerResourcePercentVal" type="Label" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerResourceBar/PlayerResourcePercent"]
|
||||
layout_mode = 2
|
||||
text = "0"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="PlayerHealthPercentSym" type="Label" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerResourceBar/PlayerHealthPercent"]
|
||||
[node name="PlayerResourcePercentSym" type="Label" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerResourceBar/PlayerResourcePercent"]
|
||||
layout_mode = 2
|
||||
text = "%"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="PlayerHealthMax" type="Label" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerResourceBar"]
|
||||
[node name="PlayerResourceMax" type="Label" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerResourceBar"]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.708108
|
||||
@ -244,6 +244,10 @@ theme = ExtResource("5_mpq3w")
|
||||
step = 1.0
|
||||
value = 43.0
|
||||
|
||||
[node name="RegenTimer" type="Timer" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo"]
|
||||
wait_time = 5.0
|
||||
autostart = true
|
||||
|
||||
[node name="UIBottomCenter" type="VBoxContainer" parent="MarginContainer/UIBottom"]
|
||||
custom_minimum_size = Vector2(512, 0)
|
||||
layout_mode = 2
|
||||
@ -261,7 +265,7 @@ alignment = 1
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
attack_range = 9999
|
||||
auto_damage = 1000
|
||||
auto_damage = 400
|
||||
|
||||
[node name="AbilityA2" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("6_8hwtc")]
|
||||
visible = false
|
||||
@ -420,6 +424,7 @@ layout_mode = 2
|
||||
text = "0"
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/UITop/ContinueButton" to="." method="_on_continue_button_pressed"]
|
||||
[connection signal="timeout" from="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/RegenTimer" to="MarginContainer/UIBottom/PlayerContainer/PlayerInfo" method="_on_regen_timer_timeout"]
|
||||
[connection signal="pressed" from="MarginContainer/UIBottom/UIBottomCenter/MenuButtons/DebugMenu/ButtonTest" to="." method="_on_button_test_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/UIBottom/UIBottomCenter/MenuButtons/DebugMenu/ButtonExit" to="." method="_on_button_exit_pressed"]
|
||||
[connection signal="timeout" from="MarginContainer/UIRight/InfoPanel/SystemClock/ClockTimer" to="." method="_on_clock_timer_timeout"]
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
[node name="NPCEnemy" type="CharacterBody2D"]
|
||||
script = ExtResource("1_ec4cy")
|
||||
attack_base = 0
|
||||
npcDifficulty = 1
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionPolygon2D" parent="."]
|
||||
|
@ -117,3 +117,5 @@ func _on_idle_cooldown_timeout() -> void:
|
||||
var enemiesList = _get_enemies()
|
||||
if not enemiesList.is_empty() and self.visible:
|
||||
_deal_idle_damage(enemiesList)
|
||||
|
||||
# TODO: implement active damage with signal to send resources spent to player
|
@ -7,13 +7,18 @@ var area_exp := 0.0
|
||||
var current_health: int
|
||||
var resource_type: String
|
||||
var current_resource: int
|
||||
var max_health
|
||||
var max_resource
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
SignalBus.enemy_died.connect(_on_enemy_died)
|
||||
SignalBus.quest_completed.connect(_on_quest_completed)
|
||||
SignalBus.enemy_damaged_player.connect(_on_enemy_damaged_player)
|
||||
_set_player_display()
|
||||
max_health = PlayerState.max_health
|
||||
max_resource = PlayerState.max_resource
|
||||
_set_player_health_display()
|
||||
_set_player_resource_display()
|
||||
$PlayerExpBar.value = _get_level_progress_percent()
|
||||
$PlayerLabel/PlayerLevel.text = str(floor(PlayerState.level))
|
||||
|
||||
@ -37,15 +42,14 @@ func _on_enemy_died(enemyDifficulty, enemyTier, _enemyFaction) -> void:
|
||||
# Engine.time_scale = 0.0001
|
||||
|
||||
|
||||
func _set_player_display() -> void:
|
||||
var max_health = PlayerState.max_health
|
||||
func _set_player_health_display() -> void:
|
||||
current_health = max_health
|
||||
$PlayerHealthBar/PlayerHealthMax.text = str(max_health)
|
||||
$PlayerHealthBar/PlayerHealthCurrent.text = str(current_health)
|
||||
$PlayerHealthBar.value = current_health
|
||||
|
||||
|
||||
func _set_player_current_health(change: int) -> void:
|
||||
func _update_player_health(change: int) -> void:
|
||||
var prev_health = current_health
|
||||
var new_health = prev_health + change
|
||||
current_health = new_health
|
||||
@ -53,15 +57,42 @@ func _set_player_current_health(change: int) -> void:
|
||||
$PlayerHealthBar/PlayerHealthCurrent.text = str(0)
|
||||
$PlayerHealthBar.value = 0
|
||||
# TODO: change to scene transition after slowing for a couple seconds
|
||||
Engine.time_scale = 0.0001
|
||||
# Engine.time_scale = 0.0001
|
||||
get_tree().paused = true
|
||||
elif current_health >= max_health:
|
||||
$PlayerHealthBar/PlayerHealthCurrent.text = str(max_health)
|
||||
$PlayerHealthBar.value = max_health
|
||||
else:
|
||||
$PlayerHealthBar/PlayerHealthCurrent.text = str(new_health)
|
||||
$PlayerHealthBar.value = new_health
|
||||
|
||||
|
||||
func _set_player_resource_display() -> void:
|
||||
current_resource = max_resource
|
||||
$PlayerResourceBar/PlayerResourceMax.text = str(max_resource)
|
||||
$PlayerResourceBar/PlayerResourceCurrent.text = str(current_resource)
|
||||
$PlayerResourceBar.value = current_resource
|
||||
|
||||
|
||||
func _update_player_resource(change: int) -> void:
|
||||
var prev_resource = current_resource
|
||||
var new_resource = prev_resource + change
|
||||
current_resource = new_resource
|
||||
PlayerState.current_resource = current_resource
|
||||
if current_resource <= 0:
|
||||
$PlayerResourceBar/PlayerResourceCurrent.text = str(0)
|
||||
$PlayerResourceBar.value = 0
|
||||
elif current_resource >= max_resource:
|
||||
$PlayerResourceBar/PlayerResourceCurrent.text = str(max_resource)
|
||||
$PlayerResourceBar.value = max_resource
|
||||
else:
|
||||
$PlayerResourceBar/PlayerResourceCurrent.text = str(new_resource)
|
||||
$PlayerResourceBar.value = new_resource
|
||||
|
||||
|
||||
func _on_enemy_damaged_player(damage: int) -> void:
|
||||
var damage_received = damage
|
||||
_set_player_current_health(-damage_received)
|
||||
_update_player_health(-damage_received)
|
||||
|
||||
|
||||
func _calculate_player_level() -> float:
|
||||
@ -85,3 +116,8 @@ func _on_quest_completed() -> void:
|
||||
# print("XP: ", PlayerState.player_exp)
|
||||
# print("CL: ", _calculate_player_level())
|
||||
# print("LP: ", _get_level_progress_percent())
|
||||
|
||||
|
||||
func _on_regen_timer_timeout() -> void:
|
||||
_update_player_health(1)
|
||||
_update_player_resource(1)
|
||||
|
@ -8,7 +8,6 @@ var constitution := 1
|
||||
var experience := 0.0
|
||||
var level := 1.0
|
||||
var max_health := constitution * 100
|
||||
# TEST: change current health to var on player and use signals to take damage?
|
||||
# var current_health := max_health
|
||||
var max_resource := 100
|
||||
var current_resource := max_resource
|
||||
var weapon_type: Globals.Weapon.WeaponType
|
||||
|
Loading…
Reference in New Issue
Block a user