67 lines
1.8 KiB
GDScript3
67 lines
1.8 KiB
GDScript3
|
|
class_name World
|
||
|
|
extends Node2D
|
||
|
|
|
||
|
|
@export var line_edit:LineEdit
|
||
|
|
@export var world_ui:WorldState
|
||
|
|
@export var battle_ui:BattleState
|
||
|
|
@export var player:Player
|
||
|
|
@export var texture:ColorRect
|
||
|
|
var is_battle:bool = false
|
||
|
|
func _ready() -> void:
|
||
|
|
line_edit.grab_focus()
|
||
|
|
line_edit.caret_column = 1
|
||
|
|
world_ui.start(self)
|
||
|
|
battle_ui.start(self)
|
||
|
|
|
||
|
|
func start_battle(enemy_list:Array[PackedScene], enemy_name:Array[String]) -> void:
|
||
|
|
is_battle = true
|
||
|
|
battle_ui.start_battle(enemy_list, enemy_name)
|
||
|
|
world_ui.animation_player.play("appear")
|
||
|
|
while(world_ui.size.y > 0):
|
||
|
|
world_ui.size.y -= 10
|
||
|
|
await get_tree().create_timer(0.01).timeout
|
||
|
|
world_ui.animation_player.play("RESET")
|
||
|
|
while(battle_ui.size.y < 540.0):
|
||
|
|
if battle_ui.size.y == 270.0:
|
||
|
|
battle_ui.start_animation()
|
||
|
|
battle_ui.size.y += 10
|
||
|
|
await get_tree().create_timer(0.01).timeout
|
||
|
|
await get_tree().create_timer(2).timeout
|
||
|
|
battle_ui.animation_player.play("RESET")
|
||
|
|
|
||
|
|
battle_ui.size.y = 540.0
|
||
|
|
|
||
|
|
func end_battle() -> void:
|
||
|
|
is_battle = false
|
||
|
|
while(battle_ui.size.y > 0):
|
||
|
|
battle_ui.size.y -= 10
|
||
|
|
await get_tree().create_timer(0.05).timeout
|
||
|
|
battle_ui.animation_player.play("RESET")
|
||
|
|
while(world_ui.size.y < 540):
|
||
|
|
world_ui.size.y += 10
|
||
|
|
await get_tree().create_timer(0.05).timeout
|
||
|
|
world_ui.size.y = 540
|
||
|
|
|
||
|
|
func _on_line_edit_text_submitted(new_text: String) -> void:
|
||
|
|
line_edit.clear()
|
||
|
|
var string_command = new_text.get_slice(" ", 0)
|
||
|
|
var input:String = new_text.replace(string_command + " ", "")
|
||
|
|
if !is_battle:
|
||
|
|
world_ui.do_command(string_command, input)
|
||
|
|
elif is_battle:
|
||
|
|
battle_ui.command(string_command, input)
|
||
|
|
|
||
|
|
|
||
|
|
func _on_line_edit_text_changed(new_text: String) -> void:
|
||
|
|
var caret_pos = line_edit.caret_column
|
||
|
|
line_edit.text = new_text.to_upper()
|
||
|
|
line_edit.caret_column = caret_pos
|
||
|
|
|
||
|
|
func test():
|
||
|
|
if texture.size.y >= 613.0:
|
||
|
|
print("done")
|
||
|
|
return
|
||
|
|
texture.size.y += 10
|
||
|
|
await get_tree().create_timer(0.05).timeout
|
||
|
|
test()
|