Added stairs (can't climb yet).
This commit is contained in:
@@ -33,7 +33,7 @@ func _physics_process(delta):
|
|||||||
velocity.z = h_velocity.z
|
velocity.z = h_velocity.z
|
||||||
velocity.y = h_velocity.y
|
velocity.y = h_velocity.y
|
||||||
if !get_meta("grabbed") && !in_smart_obj && !disable_gravity:
|
if !get_meta("grabbed") && !in_smart_obj && !disable_gravity:
|
||||||
velocity.y += -9.8 * delta
|
velocity.y += -9.8
|
||||||
velocity = move_and_slide(velocity,Vector3(0,1,0))
|
velocity = move_and_slide(velocity,Vector3(0,1,0))
|
||||||
orientation.origin = Vector3()
|
orientation.origin = Vector3()
|
||||||
fixup.origin = Vector3()
|
fixup.origin = Vector3()
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func _physics_process(delta):
|
|||||||
velocity.z = h_velocity.z
|
velocity.z = h_velocity.z
|
||||||
velocity.y = h_velocity.y
|
velocity.y = h_velocity.y
|
||||||
if !get_meta("grabbed") && !in_smart_obj && !disable_gravity:
|
if !get_meta("grabbed") && !in_smart_obj && !disable_gravity:
|
||||||
velocity.y += -9.8 * delta
|
velocity.y += -9.8
|
||||||
velocity = move_and_slide(velocity,Vector3(0,1,0))
|
velocity = move_and_slide(velocity,Vector3(0,1,0))
|
||||||
orientation.origin = Vector3()
|
orientation.origin = Vector3()
|
||||||
fixup.origin = Vector3()
|
fixup.origin = Vector3()
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ func start_ai():
|
|||||||
$"meta-ai".start()
|
$"meta-ai".start()
|
||||||
|
|
||||||
func spawn_player(spawner):
|
func spawn_player(spawner):
|
||||||
|
print("spawned player")
|
||||||
loading.queue_free()
|
loading.queue_free()
|
||||||
var player_sc = load("res://scenes/characters/male.tscn")
|
var player_sc = load("res://scenes/characters/male.tscn")
|
||||||
var player = player_sc.instance()
|
var player = player_sc.instance()
|
||||||
|
|||||||
@@ -123,12 +123,16 @@ var state = 0
|
|||||||
func _ready():
|
func _ready():
|
||||||
pass
|
pass
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
var furniture_nodes = []
|
||||||
|
var dungeon_ids = []
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
match(state):
|
match(state):
|
||||||
0:
|
0:
|
||||||
global.load_game()
|
global.load_game()
|
||||||
if global.save_data.has("dungeon"):
|
if global.save_data.has("dungeon"):
|
||||||
dungeon_save = global.save_data.dungeon
|
dungeon_save = global.save_data.dungeon
|
||||||
|
state = 1
|
||||||
|
1:
|
||||||
dungeon.resize(floors * size_x * size_y)
|
dungeon.resize(floors * size_x * size_y)
|
||||||
for k in range(floors):
|
for k in range(floors):
|
||||||
for i in range(size_x):
|
for i in range(size_x):
|
||||||
@@ -140,16 +144,25 @@ func _process(_delta):
|
|||||||
ri.translation.z = j * h - size_y / 2 * h
|
ri.translation.z = j * h - size_y / 2 * h
|
||||||
dungeon[k * size_x * size_y + j * size_x + i] = ri
|
dungeon[k * size_x * size_y + j * size_x + i] = ri
|
||||||
if dungeon_save.empty():
|
if dungeon_save.empty():
|
||||||
state = 1
|
state = 20
|
||||||
else:
|
else:
|
||||||
state = 2
|
state = 30
|
||||||
1:
|
20:
|
||||||
build_rooms()
|
build_rooms()
|
||||||
|
state = 21
|
||||||
|
21:
|
||||||
build_special_rooms()
|
build_special_rooms()
|
||||||
|
state = 22
|
||||||
|
22:
|
||||||
for r in dungeon:
|
for r in dungeon:
|
||||||
r.create_rooms()
|
r.create_rooms()
|
||||||
for k in get_tree().get_nodes_in_group("furniture"):
|
state = 23
|
||||||
|
23:
|
||||||
|
furniture_nodes = get_tree().get_nodes_in_group("furniture")
|
||||||
|
state = 24
|
||||||
|
24:
|
||||||
|
if furniture_nodes.size() > 0:
|
||||||
|
var k = furniture_nodes.pop_front()
|
||||||
if k.name.begins_with("fc"):
|
if k.name.begins_with("fc"):
|
||||||
if randf() > 0.5 && !k.get_parent().has_meta("kitchen_room"):
|
if randf() > 0.5 && !k.get_parent().has_meta("kitchen_room"):
|
||||||
var bed_i = bed.instance()
|
var bed_i = bed.instance()
|
||||||
@@ -167,16 +180,22 @@ func _process(_delta):
|
|||||||
closet_i.set_meta("save_path", "res://scenes/furniture/closet.tscn")
|
closet_i.set_meta("save_path", "res://scenes/furniture/closet.tscn")
|
||||||
k.add_child(closet_i)
|
k.add_child(closet_i)
|
||||||
k.rotate_y(randf() * PI / 24.0)
|
k.rotate_y(randf() * PI / 24.0)
|
||||||
|
else:
|
||||||
save()
|
save()
|
||||||
state = 3
|
state = 40
|
||||||
2:
|
30:
|
||||||
for k in range(dungeon.size()):
|
dungeon_ids = range(dungeon.size())
|
||||||
|
state = 31
|
||||||
|
31:
|
||||||
|
if dungeon_ids.size() > 0:
|
||||||
|
var k = dungeon_ids.pop_front()
|
||||||
dungeon[k].save_data = dungeon_save[str(k)]
|
dungeon[k].save_data = dungeon_save[str(k)]
|
||||||
dungeon[k].restore()
|
dungeon[k].restore()
|
||||||
state = 3
|
else:
|
||||||
3:
|
state = 40
|
||||||
|
40:
|
||||||
print("loaded")
|
print("loaded")
|
||||||
state = 4
|
state = 50
|
||||||
prepared = true
|
prepared = true
|
||||||
emit_signal("prepared")
|
emit_signal("prepared")
|
||||||
_:
|
_:
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ var door = preload("res://scenes/maps/door.tscn")
|
|||||||
var jail_door = preload("res://scenes/maps/jail-door.tscn")
|
var jail_door = preload("res://scenes/maps/jail-door.tscn")
|
||||||
var window = preload("res://scenes/maps/window.tscn")
|
var window = preload("res://scenes/maps/window.tscn")
|
||||||
var outside_door = preload("res://scenes/maps/window.tscn")
|
var outside_door = preload("res://scenes/maps/window.tscn")
|
||||||
|
var stairs = preload("res://scenes/maps/stairs.tscn")
|
||||||
var outside_door_placed = false
|
var outside_door_placed = false
|
||||||
var tw2d
|
var tw2d
|
||||||
var te2d
|
var te2d
|
||||||
@@ -230,6 +231,11 @@ func create_rooms():
|
|||||||
master_room()
|
master_room()
|
||||||
elif has_meta("stairs"):
|
elif has_meta("stairs"):
|
||||||
master_room()
|
master_room()
|
||||||
|
var stairs_i = stairs.instance()
|
||||||
|
add_child(stairs_i)
|
||||||
|
for e in get_children():
|
||||||
|
if e.is_in_group("furniture"):
|
||||||
|
e.queue_free()
|
||||||
if get_meta("stairs") > 0:
|
if get_meta("stairs") > 0:
|
||||||
$c_modular/floor.queue_free()
|
$c_modular/floor.queue_free()
|
||||||
elif exits.size() == 1:
|
elif exits.size() == 1:
|
||||||
|
|||||||
697
proto3/godot/scenes/maps/stairs.escn
Normal file
697
proto3/godot/scenes/maps/stairs.escn
Normal file
File diff suppressed because one or more lines are too long
1063
proto3/godot/scenes/maps/stairs.escn.import
Normal file
1063
proto3/godot/scenes/maps/stairs.escn.import
Normal file
File diff suppressed because it is too large
Load Diff
5
proto3/godot/scenes/maps/stairs.tscn
Normal file
5
proto3/godot/scenes/maps/stairs.tscn
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://scenes/maps/stairs.escn" type="PackedScene" id=1]
|
||||||
|
|
||||||
|
[node name="stairs" instance=ExtResource( 1 )]
|
||||||
@@ -2,7 +2,7 @@ extends Node
|
|||||||
signal spawn_player(pos)
|
signal spawn_player(pos)
|
||||||
signal spawn_npc(xform)
|
signal spawn_npc(xform)
|
||||||
|
|
||||||
enum states {STATE_PREINIT, STATE_INIT, STATE_EXECUTE, STATE_SLEEP}
|
enum states {STATE_PREINIT, STATE_INIT, STATE_INIT_ASTAR, STATE_EXECUTE, STATE_SLEEP}
|
||||||
|
|
||||||
var state = states.STATE_PREINIT
|
var state = states.STATE_PREINIT
|
||||||
var astar = null
|
var astar = null
|
||||||
@@ -113,13 +113,20 @@ func spawn_characters():
|
|||||||
print("npc")
|
print("npc")
|
||||||
emit_signal("spawn_npc", e)
|
emit_signal("spawn_npc", e)
|
||||||
|
|
||||||
|
var path_nodes = []
|
||||||
|
var endings = []
|
||||||
|
var connections = {}
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
match state:
|
match state:
|
||||||
states.STATE_INIT:
|
states.STATE_INIT:
|
||||||
print("starting AI")
|
print("starting AI")
|
||||||
var endings = []
|
path_nodes = get_tree().get_nodes_in_group("path")
|
||||||
var connections = {}
|
endings = []
|
||||||
for e in get_tree().get_nodes_in_group("path"):
|
connections = {}
|
||||||
|
state = states.STATE_INIT_ASTAR
|
||||||
|
states.STATE_INIT_ASTAR:
|
||||||
|
if path_nodes.size() > 0:
|
||||||
|
var e = path_nodes.pop_front()
|
||||||
print(e.name)
|
print(e.name)
|
||||||
var new_points = Array(e.curve.get_baked_points())
|
var new_points = Array(e.curve.get_baked_points())
|
||||||
var new_ids = []
|
var new_ids = []
|
||||||
@@ -145,6 +152,7 @@ func _physics_process(delta):
|
|||||||
astar.connect_points(new_ids[s], new_ids[s + 1])
|
astar.connect_points(new_ids[s], new_ids[s + 1])
|
||||||
connections[new_ids[s]] = new_ids[s + 1]
|
connections[new_ids[s]] = new_ids[s + 1]
|
||||||
connections[new_ids[s + 1]] = new_ids[s]
|
connections[new_ids[s + 1]] = new_ids[s]
|
||||||
|
else:
|
||||||
print("path nodes passed")
|
print("path nodes passed")
|
||||||
var space_state = get_parent().get_world().direct_space_state
|
var space_state = get_parent().get_world().direct_space_state
|
||||||
for id1 in endings:
|
for id1 in endings:
|
||||||
@@ -158,21 +166,6 @@ func _physics_process(delta):
|
|||||||
var front_result = space_state.intersect_ray(p0 + Vector3(0, 0.5, 0), p1 + Vector3(0, 0.5, 0), [], 0x1)
|
var front_result = space_state.intersect_ray(p0 + Vector3(0, 0.5, 0), p1 + Vector3(0, 0.5, 0), [], 0x1)
|
||||||
if !front_result.has("collider"):
|
if !front_result.has("collider"):
|
||||||
astar.connect_points(id1, id2)
|
astar.connect_points(id1, id2)
|
||||||
# for pk in connections.keys():
|
|
||||||
# var id1 = pk
|
|
||||||
# var id2 = connections[pk]
|
|
||||||
# if astar.are_points_connected(id1, id2):
|
|
||||||
# var p0 = astar.get_point_position(id1)
|
|
||||||
# var p1 = astar.get_point_position(id2)
|
|
||||||
# var front_result = space_state.intersect_ray(p0 + Vector3(0, 0.8, 0), p1 + Vector3(0, 0.8, 0), [], 0x1)
|
|
||||||
# if front_result.has("collider"):
|
|
||||||
# var collider = front_result.collider
|
|
||||||
# var ok = false
|
|
||||||
# if collider.is_in_group("furniture"):
|
|
||||||
# ok = true
|
|
||||||
# elif collider.is_in_group("door"):
|
|
||||||
# ok = true
|
|
||||||
# astar.disconnect_points(id1, id2)
|
|
||||||
print("astar complete")
|
print("astar complete")
|
||||||
spawn_characters()
|
spawn_characters()
|
||||||
print("characters spawned")
|
print("characters spawned")
|
||||||
@@ -227,7 +220,7 @@ func _physics_process(delta):
|
|||||||
for r in npc_raycasts:
|
for r in npc_raycasts:
|
||||||
if r.has("radius"):
|
if r.has("radius"):
|
||||||
var shape : = SphereShape.new()
|
var shape : = SphereShape.new()
|
||||||
shape.radius
|
shape.radius = r.radius
|
||||||
var query = PhysicsShapeQueryParameters.new()
|
var query = PhysicsShapeQueryParameters.new()
|
||||||
query.set_shape(query)
|
query.set_shape(query)
|
||||||
query.collision_mask = r.mask
|
query.collision_mask = r.mask
|
||||||
|
|||||||
Reference in New Issue
Block a user