Implemented simple quest system

This commit is contained in:
Segey Lapin
2020-04-15 12:16:14 +03:00
parent 078cc47b91
commit 32c5212209
14 changed files with 366 additions and 202 deletions

View File

@@ -1,5 +1,11 @@
extends Spatial
var loading
func new_quest(q):
var title = q.get_title()
var desc = q.get_description()
print("title: ", title)
print("desc: ", desc)
func _ready():
loading = preload("res://ui/loading.tscn").instance()
get_tree().get_root().add_child(loading)
@@ -12,6 +18,8 @@ func _ready():
global.set_save_slot(0)
e = $dungeon.connect("prepared", self, "start_ai")
assert(e == OK)
e = quests.connect("new_quest", self, "new_quest")
assert(e == OK)
var default_meta = {
"grabbing": false,
@@ -32,6 +40,12 @@ func start_ai():
print("prepared")
$"meta-ai".start()
func save():
global.save_characters()
$dungeon.save()
quests.save()
global.save_game()
func spawn_player(spawner):
print("spawned player")
loading.queue_free()
@@ -50,6 +64,7 @@ func spawn_player(spawner):
player.set_meta("spawner", spawner)
player.add_to_group("player")
$cam_target/cam_rot/offset/Camera.current = true
global.start_time()
func spawn_npc(spawner):
var npc
var g
@@ -221,3 +236,5 @@ func _process(delta):
$cam_target.rotate_y(-angle * delta)
else:
cam_fixup_cooldown -= delta
if Input.is_action_just_pressed("save_game"):
save()

View File

@@ -23,12 +23,10 @@ var dungeon_save = {}
var spawn_save = {}
var prepared = false
func save():
global.save_characters()
for k in range(dungeon.size()):
dungeon[k].save()
dungeon_save[str(k)] = dungeon[k].save_data
global.save_data.dungeon = dungeon_save
global.save_game()
var window_rooms = []
func build_rooms():
print("build_rooms")
@@ -214,6 +212,3 @@ func _process(_delta):
state = 50
prepared = true
emit_signal("prepared")
_:
if Input.is_action_just_pressed("save_game"):
save()

View File

@@ -1,10 +1,22 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://scenes/maps/stairs.escn" type="PackedScene" id=1]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 1.13086, 0.0458848, 0.64188 )
[sub_resource type="Curve3D" id=2]
_data = {
"points": PoolVector3Array( 0, 0, 0, 0, 0, 0, -3.40015, 0.239252, 1.85913, 0, 0, 0, 0, 0, 0, -1.97383, 0.257656, 1.88403, 0, 0, 0, 0, 0, 0, -1.45852, 0.423293, 1.90918, 0, 0, 0, 0, 0, 0, -0.13343, 1.49073, 1.93433, 0, 0, 0, 0, 0, 0, 0.24645, 1.77444, 1.93433, 0, 0, 0, 0, 0, 0, 1.75415, 1.76855, 1.87302, 0, 0, 0, 0, 0, 0, 1.66716, 1.85563, 0.244141, 0, 0, 0, 0, 0, 0, 1.66137, 1.75269, -0.562487, 0, 0, 0, 0, 0, 0, 1.65557, 1.76514, -1.72805, 0, 0, 0, 0, 0, 0, 0.974322, 1.71509, -1.75141, 0, 0, 0, 0, 0, 0, 0.287957, 2.12817, -1.72775, 0, 0, 0, 0, 0, 0, -0.201176, 2.55396, -1.71986, 0, 0, 0, 0, 0, 0, -0.666642, 3.04525, -1.72119, 0, 0, 0, 0, 0, 0, -1.27411, 3.41605, -1.72168, 0, 0, 0, 0, 0, 0, -2.65473, 3.40816, -1.73389 ),
"tilts": PoolRealArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
}
[sub_resource type="Curve3D" id=3]
_data = {
"points": PoolVector3Array( 0, 0, 0, 0, 0, 0, -4.5026, 0.332731, -0.0107422, 0, 0, 0, 0, 0, 0, -3.99813, 0.375664, -0.0107422, 0, 0, 0, 0, 0, 0, -4.07327, 0.375664, -1.81396, 0, 0, 0, 0, 0, 0, -4.084, 0.36493, -2.81201, 0, 0, 0, 0, 0, 0, -3.81567, 0.375664, -3.27344, 0, 0, 0, 0, 0, 0, -1.64755, 0.343464, -3.28418, 0, 0, 0, 0, 0, 0, -0.520562, 0.407863, -3.32715, 0, 0, 0, 0, 0, 0, 0.101966, 0.482996, -3.68164, 0, 0, 0, 0, 0, 0, 0.917692, 0.440063, -3.30566, 0, 0, 0, 0, 0, 0, 1.86222, 0.504463, -3.27344, 0, 0, 0, 0, 0, 0, 3.33267, 0.547396, -3.30566, 0, 0, 0, 0, 0, 0, 3.7298, 0.504463, -3.31641, 0, 0, 0, 0, 0, 0, 3.62247, 0.515196, -2.55469, 0, 0, 0, 0, 0, 0, 3.65467, 0.568862, -1.3418, 0, 0, 0, 0, 0, 0, 3.93373, 0.622528, -0.665527, 0, 0, 0, 0, 0, 0, 4.245, 0.547396, -0.236328, 0, 0, 0, 0, 0, 0, 4.55626, 0.547396, -0.0429688, 0, 0, 0, 0, 0, 0, 4.406, 0.558129, 0.0751953, 0, 0, 0, 0, 0, 0, 4.0518, 0.525929, 1.0625, 0, 0, 0, 0, 0, 0, 3.8586, 0.504463, 2.66187, 0, 0, 0, 0, 0, 0, 3.5688, 0.504463, 3.14478, 0, 0, 0, 0, 0, 0, 2.17348, 0.515196, 3.06982, 0, 0, 0, 0, 0, 0, 0.552762, 0.407863, 3.00537, 0, 0, 0, 0, 0, 0, 0.316631, 0.42933, 3.55273, 0, 0, 0, 0, 0, 0, -0.252232, 0.42933, 2.94092, 0, 0, 0, 0, 0, 0, -1.29336, 0.375664, 2.9624, 0, 0, 0, 0, 0, 0, -3.28974, 0.386397, 3.01611, 0, 0, 0, 0, 0, 0, -3.9552, 0.418597, 2.95166, 0, 0, 0, 0, 0, 0, -4.16987, 0.354197, 2.52222, 0, 0, 0, 0, 0, 0, -4.3416, 0.375664, 1.42749, 0, 0, 0, 0, 0, 0, -4.2128, 0.289798, 0.493652 ),
"tilts": PoolRealArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
}
[node name="stairs" instance=ExtResource( 1 )]
[node name="StaticBody" type="StaticBody" parent="." index="4"]
@@ -16,3 +28,18 @@ shape = SubResource( 1 )
[node name="CollisionShape2" type="CollisionShape" parent="StaticBody" index="1"]
transform = Transform( -0.768529, 0.639815, -3.25444e-07, 0.639815, 0.768529, 1.60706e-08, 2.60396e-07, -1.95874e-07, -1, -0.0615042, 2.2555, -1.95211 )
shape = SubResource( 1 )
[node name="Path" type="Path" parent="." index="5" groups=[
"path",
]]
curve = SubResource( 2 )
[node name="Path2" type="Path" parent="." index="6" groups=[
"path",
]]
curve = SubResource( 3 )
[node name="Path3" type="Path" parent="." index="7" groups=[
"path",
]]
curve = SubResource( 3 )

View File

@@ -15,6 +15,7 @@ func start():
func _ready():
astar = AStar.new()
global.astar = astar
func calc_visible_lists():
for g in get_tree().get_nodes_in_group("npc"):