initial worldArea instantiation conversion complete
This commit is contained in:
parent
c3f02e855d
commit
b6b609aa20
@ -22,6 +22,7 @@ WorldState="*res://scripts/WorldState.gd"
|
||||
PlayerState="*res://scripts/PlayerState.gd"
|
||||
SignalBus="*res://scripts/SignalBus.gd"
|
||||
Styling="*res://scripts/Styling.gd"
|
||||
WorldZone="*res://scripts/WorldZone.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
@ -1,14 +1,11 @@
|
||||
[gd_scene load_steps=16 format=3 uid="uid://0h3dpe6fuhe8"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://0h3dpe6fuhe8"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/combat_ui_scene.gd" id="1_p88l5"]
|
||||
[ext_resource type="Script" path="res://scripts/WorldArea.gd" id="2_anfgr"]
|
||||
[ext_resource type="Script" path="res://scripts/Player.gd" id="3_w71a3"]
|
||||
[ext_resource type="Theme" uid="uid://clhh3c3gxotjg" path="res://assets/healthbar.tres" id="4_4e8vj"]
|
||||
[ext_resource type="Theme" uid="uid://cp82s71sduhcv" path="res://assets/expbar.tres" id="5_mpq3w"]
|
||||
[ext_resource type="PackedScene" uid="uid://dvwo26vsk46tl" path="res://scenes/ability_player.tscn" id="6_8hwtc"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6qo1s"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_imvmd"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_lpwpb"]
|
||||
@ -45,19 +42,6 @@ size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("1_p88l5")
|
||||
|
||||
[node name="SpawnTimer" type="Timer" parent="."]
|
||||
|
||||
[node name="WorldArea" type="PanelContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_6qo1s")
|
||||
script = ExtResource("2_anfgr")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
@ -71,7 +55,9 @@ theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="UITop" type="VBoxContainer" parent="MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="QuestsContainer" type="HBoxContainer" parent="MarginContainer/UITop"]
|
||||
@ -79,6 +65,15 @@ unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
|
||||
[node name="AutoCheck" type="CheckButton" parent="MarginContainer/UITop"]
|
||||
layout_mode = 2
|
||||
text = "Auto Progress"
|
||||
|
||||
[node name="ContinueButton" type="Button" parent="MarginContainer/UITop"]
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
layout_mode = 2
|
||||
text = "Next Area"
|
||||
|
||||
[node name="UIBottom" type="HBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
@ -200,7 +195,6 @@ alignment = 1
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
attack_range = 9999
|
||||
attack_damage = 10000
|
||||
|
||||
[node name="AbilityA2" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("6_8hwtc")]
|
||||
visible = false
|
||||
@ -208,8 +202,8 @@ custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
target_type = 3
|
||||
attack_range = 200
|
||||
attack_damage = 50
|
||||
attack_range = 200
|
||||
auto_speed = 5.0
|
||||
|
||||
[node name="AbilityA3" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("6_8hwtc")]
|
||||
@ -302,6 +296,5 @@ size_flags_horizontal = 3
|
||||
layout_mode = 2
|
||||
theme = ExtResource("4_4e8vj")
|
||||
|
||||
[connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_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"]
|
||||
|
@ -10,7 +10,7 @@ offset_right = 175.0
|
||||
offset_bottom = 40.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_dv3o6")
|
||||
script = ExtResource("1_o0k38")
|
||||
goalTotal = 200
|
||||
goalTotal = 20
|
||||
|
||||
[node name="QuestProgress" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
18
scenes/world_area.tscn
Normal file
18
scenes/world_area.tscn
Normal file
@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dfdjk8gv5ommt"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/WorldArea.gd" id="1_83d5k"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6qo1s"]
|
||||
|
||||
[node name="WorldArea" type="PanelContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_6qo1s")
|
||||
script = ExtResource("1_83d5k")
|
||||
|
||||
[node name="SpawnTimer" type="Timer" parent="."]
|
||||
|
||||
[connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_timer_timeout"]
|
@ -5,5 +5,5 @@ extends TextureRect
|
||||
|
||||
@export var attack_range := 0
|
||||
@export var damage_type := Globals.Ability.PDamageType.SLICE
|
||||
@export var attack_damage := 200
|
||||
@export var auto_damage := 200
|
||||
@export var auto_speed := 1.0
|
||||
|
@ -20,6 +20,7 @@ enum TargetType {
|
||||
@export var target_type := TargetType.SINGLE
|
||||
@export var target_angle := 2*PI
|
||||
@export var base_cooldown := 0.0
|
||||
@export var attack_damage := 400
|
||||
|
||||
func _ready() -> void:
|
||||
middleX = get_viewport_rect().size.x / 2
|
||||
@ -103,12 +104,12 @@ func _deal_idle_damage(enemiesList) -> void:
|
||||
TargetType.SINGLE:
|
||||
var target = _get_target(enemiesList)
|
||||
if target:
|
||||
target.damageTaken += attack_damage
|
||||
target.damageTaken += auto_damage
|
||||
_:
|
||||
var targets = _get_targets_in_range(enemiesList)
|
||||
if targets:
|
||||
for target in targets:
|
||||
target.damageTaken += attack_damage
|
||||
target.damageTaken += auto_damage
|
||||
|
||||
|
||||
func _on_idle_cooldown_timeout() -> void:
|
||||
|
@ -2,9 +2,6 @@
|
||||
extends Node
|
||||
|
||||
|
||||
@export var debug = true
|
||||
|
||||
|
||||
class World:
|
||||
enum Zone {
|
||||
TUTORIAL,
|
||||
|
@ -9,6 +9,8 @@ var area_exp := 0.0
|
||||
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()
|
||||
$PlayerExpBar.value = _get_level_progress_percent()
|
||||
$PlayerLabel/PlayerLevel.text = str(floor(PlayerState.player_level))
|
||||
|
||||
@ -16,17 +18,38 @@ func _ready() -> void:
|
||||
func _on_enemy_died(enemyDifficulty, enemyTier, _enemyFaction) -> void:
|
||||
var kill_exp = pow(pow(enemyTier + 1, 3), enemyDifficulty)
|
||||
area_exp += kill_exp
|
||||
if Globals.debug:
|
||||
print("T: ", enemyTier, " D: ", enemyDifficulty)
|
||||
print("K: ", kill_exp)
|
||||
print("A: ",area_exp)
|
||||
# if Globals.debug:
|
||||
# print("T: ", enemyTier, " D: ", enemyDifficulty)
|
||||
# print("K: ", kill_exp)
|
||||
# print("A: ",area_exp)
|
||||
# TODO: maybe show earned exp on bar, separate from current
|
||||
# use xp to next level and current level, subtract, figure out percentage per point exp, add to display?
|
||||
|
||||
|
||||
func _get_player_current_health() -> void:
|
||||
var playerCurrHeath = PlayerState.player_currenthealth
|
||||
$PlayerHealthBar/PlayerHealthCurrent.text = str(playerCurrHeath)
|
||||
$PlayerHealthBar.value = playerCurrHeath
|
||||
if playerCurrHeath <= 0:
|
||||
%PlayerInfo/PlayerHealthBar.value = 0
|
||||
Engine.time_scale = 0.0001
|
||||
|
||||
|
||||
func _set_player_display() -> void:
|
||||
var playerMaxHeath = PlayerState.player_maxhealth
|
||||
var playerCurrHeath = PlayerState.player_currenthealth
|
||||
$PlayerHealthBar/PlayerHealthMax.text = str(playerMaxHeath)
|
||||
$PlayerHealthBar/PlayerHealthCurrent.text = str(playerCurrHeath)
|
||||
$PlayerHealthBar.value = playerCurrHeath
|
||||
|
||||
|
||||
func _on_enemy_damaged_player() -> void:
|
||||
_get_player_current_health()
|
||||
|
||||
|
||||
func _calculate_player_level() -> float:
|
||||
var current_exp = PlayerState.player_exp
|
||||
return log((0.2 * current_exp + 5)/5.0) + 1
|
||||
return log((0.2 * current_exp + 5) / 5.0) + 1
|
||||
|
||||
|
||||
func _get_level_progress_percent() -> float:
|
||||
@ -39,10 +62,9 @@ func _on_quest_completed() -> void:
|
||||
PlayerState.player_level = _calculate_player_level()
|
||||
$PlayerExpBar.value = _get_level_progress_percent()
|
||||
$PlayerLabel/PlayerLevel.text = str(floor(PlayerState.player_level))
|
||||
if Globals.debug:
|
||||
print("FA: ", area_exp)
|
||||
print("L: ", PlayerState.player_level)
|
||||
print("XP: ", PlayerState.player_exp)
|
||||
print("CL: ", _calculate_player_level())
|
||||
print("LP: ", _get_level_progress_percent())
|
||||
Engine.time_scale = 0.0001
|
||||
# if Globals.debug:
|
||||
# print("FA: ", area_exp)
|
||||
# print("L: ", PlayerState.player_level)
|
||||
# print("XP: ", PlayerState.player_exp)
|
||||
# print("CL: ", _calculate_player_level())
|
||||
# print("LP: ", _get_level_progress_percent())
|
||||
|
@ -6,4 +6,4 @@ extends Node
|
||||
@export var player_exp := 0.0
|
||||
@export var player_level := 1.0
|
||||
@export var player_maxhealth := player_constitution * player_level * 100
|
||||
@export var player_currenthealth := player_maxhealth
|
||||
@export var player_currenthealth := player_maxhealth
|
||||
|
@ -8,4 +8,5 @@ signal enemy_died(
|
||||
faction: Globals.World.Faction,
|
||||
)
|
||||
signal enemy_damaged_player
|
||||
signal quest_completed
|
||||
signal quest_generated(quest: Quest)
|
||||
signal quest_completed
|
||||
|
@ -3,11 +3,68 @@ class_name WorldArea
|
||||
extends PanelContainer
|
||||
|
||||
|
||||
enum GoalType {KILL, FIND}
|
||||
enum GoalType { KILL, FIND }
|
||||
|
||||
@export var area_type := Globals.World.AreaType.WILDS
|
||||
@export var spawnTimerValue = 10.0
|
||||
|
||||
|
||||
var middleX : float
|
||||
var playerPos : Vector2
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
middleX = get_viewport_rect().size.x / 2
|
||||
playerPos = Vector2(middleX, get_viewport_rect().size.y * (0.75))
|
||||
|
||||
_generate_quest()
|
||||
|
||||
$SpawnTimer.start(spawnTimerValue)
|
||||
_spawn_enemies(randi_range(1, 5))
|
||||
# _spawn_enemies(5)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
playerPos = Vector2(middleX, get_viewport_rect().size.y * (0.75))
|
||||
|
||||
|
||||
# instantiate Quest
|
||||
func _generate_quest() -> void:
|
||||
var quest = load("res://scenes/quest.tscn").instantiate()
|
||||
# quest.goalType = GoalType.FIND
|
||||
SignalBus.quest_generated.emit(quest)
|
||||
|
||||
|
||||
# spawn appropriate enemies
|
||||
func _create_enemy():
|
||||
var enemy = load("res://scenes/enemy.tscn").instantiate()
|
||||
enemy.scale = Vector2.ONE * 0.5
|
||||
enemy.position = Vector2(randf_range(0, get_viewport_rect().size.x), -50.0)
|
||||
enemy.speed *= randf_range(0.67, 1.5)
|
||||
enemy.target = playerPos
|
||||
|
||||
return enemy
|
||||
|
||||
func _get_enemies() -> Array:
|
||||
var enemies := get_tree().get_nodes_in_group("enemies")
|
||||
return enemies
|
||||
|
||||
|
||||
func _get_num_enemies() -> int:
|
||||
var enemies := get_tree().get_nodes_in_group("enemies")
|
||||
return len(enemies)
|
||||
|
||||
|
||||
func _spawn_enemies(numEnemies: int) -> void:
|
||||
#await get_tree().create_timer(time).timeout
|
||||
# var numEnemies = randi_range(1, maxEnemies)
|
||||
for i in range(numEnemies):
|
||||
var enemy = _create_enemy()
|
||||
add_child(enemy)
|
||||
# var randEnemyMoveSpeed := randf_range(0.5, 2.0)*enemyMoveSpeed
|
||||
# create_tween().tween_property(enemy, "position", playerPos, randEnemyMoveSpeed)
|
||||
|
||||
|
||||
func _on_spawn_timer_timeout() -> void:
|
||||
_spawn_enemies(randi_range(1, 5))
|
||||
|
||||
|
@ -3,4 +3,4 @@ extends Node
|
||||
|
||||
|
||||
@export var current_zone: Globals.World.Zone
|
||||
@export var last_played: Dictionary
|
||||
@export var last_played: Dictionary
|
||||
|
@ -1,7 +1,11 @@
|
||||
# zone class defines all parameters for creating areas within itself
|
||||
class_name WorldZone
|
||||
extends PanelContainer
|
||||
# zone class defines all parameters for creating areas
|
||||
extends Node
|
||||
|
||||
# instantiate WorldArea
|
||||
|
||||
@export var num_areas : int
|
||||
@export var factions_present : Array
|
||||
|
||||
# generate parameters for instantiating WorldArea
|
||||
func generate_area():
|
||||
# TODO: add parameters to define area
|
||||
pass
|
||||
|
@ -1,8 +1,8 @@
|
||||
# TODO: convert to just combat UI, instancing appropriate zone/area
|
||||
# BUG: elements not adjusting properly when moving to second monitor
|
||||
extends Control
|
||||
|
||||
|
||||
@export var spawnTimerValue = 10.0
|
||||
|
||||
var deltaCount := 0
|
||||
var enemyMoveSpeed := 5.0
|
||||
@ -14,63 +14,26 @@ var playerPos
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if Globals.debug:
|
||||
if OS.is_debug_build():
|
||||
%DebugMenu.show()
|
||||
Engine.time_scale = 10.0
|
||||
|
||||
SignalBus.quest_generated.connect(_on_quest_generated)
|
||||
SignalBus.quest_completed.connect(_on_quest_completed)
|
||||
SignalBus.enemy_damaged_player.connect(_on_enemy_damaged_player)
|
||||
|
||||
_generate_quest()
|
||||
|
||||
middleX = get_viewport_rect().size.x / 2
|
||||
playerPos = Vector2(middleX, get_viewport_rect().size.y * (0.75))
|
||||
|
||||
_set_player_display()
|
||||
|
||||
$SpawnTimer.start(spawnTimerValue)
|
||||
_spawn_enemies(randi_range(1, 5))
|
||||
# _spawn_enemies(5)
|
||||
_create_area()
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
deltaCount += 1
|
||||
playerPos = Vector2(middleX, get_viewport_rect().size.y * (0.75))
|
||||
|
||||
if canContinue:
|
||||
_continue_show()
|
||||
|
||||
func _generate_quest() -> void:
|
||||
var quest = load("res://scenes/quest.tscn").instantiate()
|
||||
%QuestsContainer.add_child(quest)
|
||||
|
||||
|
||||
func _create_enemy():
|
||||
var enemy = load("res://scenes/enemy.tscn").instantiate()
|
||||
enemy.scale = Vector2.ONE * 0.5
|
||||
enemy.position = Vector2(randi_range(0, get_viewport_rect().size.x), -50)
|
||||
enemy.speed *= randf_range(0.67, 1.5)
|
||||
enemy.target = playerPos
|
||||
|
||||
return enemy
|
||||
|
||||
func _get_enemies() -> Array:
|
||||
var enemies := get_tree().get_nodes_in_group("enemies")
|
||||
return enemies
|
||||
|
||||
|
||||
func _get_num_enemies() -> int:
|
||||
var enemies := get_tree().get_nodes_in_group("enemies")
|
||||
return len(enemies)
|
||||
|
||||
|
||||
func _spawn_enemies(numEnemies: int) -> void:
|
||||
#await get_tree().create_timer(time).timeout
|
||||
# var numEnemies = randi_range(1, maxEnemies)
|
||||
for i in range(numEnemies):
|
||||
var enemy = _create_enemy()
|
||||
%WorldArea.add_child(enemy)
|
||||
# var randEnemyMoveSpeed := randf_range(0.5, 2.0)*enemyMoveSpeed
|
||||
# create_tween().tween_property(enemy, "position", playerPos, randEnemyMoveSpeed)
|
||||
|
||||
func _create_area() -> void:
|
||||
var worldArea = load("res://scenes/world_area.tscn").instantiate()
|
||||
add_child(worldArea)
|
||||
move_child(worldArea, 0)
|
||||
|
||||
func _on_button_test_pressed() -> void:
|
||||
%DebugMenu/ButtonTest.text = "pass"
|
||||
@ -81,35 +44,18 @@ func _on_button_exit_pressed() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func _on_spawn_timer_timeout() -> void:
|
||||
_spawn_enemies(randi_range(1, 5))
|
||||
func _continue_show() -> void:
|
||||
%UITop/ContinueButton.modulate.a += 0.05
|
||||
|
||||
|
||||
func _get_player_current_health() -> void:
|
||||
var playerCurrHeath = PlayerState.player_currenthealth
|
||||
%PlayerInfo/PlayerHealthBar/PlayerHealthCurrent.text = str(playerCurrHeath)
|
||||
%PlayerInfo/PlayerHealthBar.value = playerCurrHeath
|
||||
if playerCurrHeath <= 0:
|
||||
Engine.time_scale = 0.0001
|
||||
|
||||
|
||||
func _set_player_display() -> void:
|
||||
var playerMaxHeath = PlayerState.player_maxhealth
|
||||
var playerCurrHeath = PlayerState.player_currenthealth
|
||||
%PlayerInfo/PlayerHealthBar/PlayerHealthMax.text = str(playerMaxHeath)
|
||||
%PlayerInfo/PlayerHealthBar/PlayerHealthCurrent.text = str(playerCurrHeath)
|
||||
%PlayerInfo/PlayerHealthBar.value = playerCurrHeath
|
||||
func _on_quest_generated(quest) -> void:
|
||||
%QuestsContainer.add_child(quest)
|
||||
|
||||
|
||||
# TODO: move all quest stuff to quest class?
|
||||
func _on_quest_completed() -> void:
|
||||
# $SpawnTimer.stop()
|
||||
# questComplete = true
|
||||
if _get_enemies().is_empty(): # and questComplete:
|
||||
if %UITop/AutoCheck.button_pressed:
|
||||
# TODO: eventually add new area progress trigger
|
||||
pass
|
||||
else:
|
||||
canContinue = true
|
||||
# print("Area Complete!")
|
||||
# get_tree().quit()
|
||||
|
||||
|
||||
func _on_enemy_damaged_player() -> void:
|
||||
_get_player_current_health()
|
||||
|
Loading…
Reference in New Issue
Block a user