init
This commit is contained in:
66
levels/world/world.gd
Executable file
66
levels/world/world.gd
Executable file
@@ -0,0 +1,66 @@
|
||||
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()
|
||||
1
levels/world/world.gd.uid
Executable file
1
levels/world/world.gd.uid
Executable file
@@ -0,0 +1 @@
|
||||
uid://bu23r23kew8mf
|
||||
95
levels/world/world.tscn
Executable file
95
levels/world/world.tscn
Executable file
@@ -0,0 +1,95 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://dyoi4j0q2kcsu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bu23r23kew8mf" path="res://levels/world/world.gd" id="1_ng6r8"]
|
||||
[ext_resource type="PackedScene" uid="uid://blbbmr2ap77jo" path="res://levels/world_state/control.tscn" id="3_8gvdk"]
|
||||
[ext_resource type="PackedScene" uid="uid://ccynhcgx88bgq" path="res://objects/player/player.tscn" id="3_b8p08"]
|
||||
[ext_resource type="PackedScene" uid="uid://cruod4lfh2xkh" path="res://levels/battle_state/battle_state.tscn" id="3_h0il2"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b8p08"]
|
||||
content_margin_left = 4.0
|
||||
content_margin_top = 4.0
|
||||
content_margin_right = 4.0
|
||||
content_margin_bottom = 4.0
|
||||
bg_color = Color(0, 0, 0, 1)
|
||||
border_width_bottom = 2
|
||||
border_color = Color(0, 0, 0, 0.6)
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
corner_detail = 5
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8gvdk"]
|
||||
content_margin_left = 4.0
|
||||
content_margin_top = 4.0
|
||||
content_margin_right = 4.0
|
||||
content_margin_bottom = 4.0
|
||||
bg_color = Color(0.6, 0.6, 0.6, 0)
|
||||
draw_center = false
|
||||
border_width_top = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
expand_margin_left = 49.0
|
||||
expand_margin_top = 2.0
|
||||
expand_margin_right = 2.0
|
||||
expand_margin_bottom = 2.0
|
||||
|
||||
[node name="World" type="Node2D" node_paths=PackedStringArray("line_edit", "world_ui", "battle_ui", "player")]
|
||||
script = ExtResource("1_ng6r8")
|
||||
line_edit = NodePath("CanvasLayer/Control/LineEdit")
|
||||
world_ui = NodePath("CanvasLayer/WorldState")
|
||||
battle_ui = NodePath("CanvasLayer/BattleState")
|
||||
player = NodePath("Player")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
layer = -1
|
||||
|
||||
[node name="BattleState" parent="CanvasLayer" instance=ExtResource("3_h0il2")]
|
||||
anchors_preset = 15
|
||||
offset_bottom = -540.0
|
||||
|
||||
[node name="WorldState" parent="CanvasLayer" instance=ExtResource("3_8gvdk")]
|
||||
|
||||
[node name="Control" type="Control" parent="CanvasLayer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="CanvasLayer/Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 11.0
|
||||
offset_top = -24.0
|
||||
offset_bottom = 4.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
theme_override_colors/font_placeholder_color = Color(0.8745098, 0.8745098, 0.8745098, 0.6627451)
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_b8p08")
|
||||
theme_override_styles/focus = SubResource("StyleBoxFlat_8gvdk")
|
||||
keep_editing_on_text_submit = true
|
||||
context_menu_enabled = false
|
||||
emoji_menu_enabled = false
|
||||
caret_blink = true
|
||||
|
||||
[node name="Label" type="Label" parent="CanvasLayer/Control"]
|
||||
layout_mode = 0
|
||||
offset_left = 4.0
|
||||
offset_top = 522.0
|
||||
offset_right = 44.0
|
||||
offset_bottom = 538.0
|
||||
text = ">"
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("3_b8p08")]
|
||||
position = Vector2(235, 175)
|
||||
damage = 5
|
||||
|
||||
[connection signal="text_changed" from="CanvasLayer/Control/LineEdit" to="." method="_on_line_edit_text_changed"]
|
||||
[connection signal="text_submitted" from="CanvasLayer/Control/LineEdit" to="." method="_on_line_edit_text_submitted"]
|
||||
Reference in New Issue
Block a user