fix a lot of map issues

This commit is contained in:
Lucas 2024-08-04 00:35:30 +02:00
parent 753dd4456c
commit 90f690198f
7 changed files with 172 additions and 110 deletions

View file

@ -4,22 +4,25 @@ extends Sprite2D
@export_file("*.tscn") var NextScene:String
@export_enum("LEFT","RIGHT","UP","DOWN") var Travel :int
@export var Spawn_Position:Vector2 = Vector2(0,0) #TODO: Extrapoler la position suivante en fonction de l'enum Travel
var NextSceneLoaded
var NextSceneLoaded:Resource
func _on_area_2d_area_entered(area):
if(area):
if(MapManager and MapManager.player == area.get_parent() and (MapManager.player.Traveling == false) ):
MapManager.player.Traveling = true
print("enter door",area)
NextSceneLoaded = load(NextScene)
if (NextSceneLoaded != null):
MapManager.transition_to_scene(NextSceneLoaded,Spawn_Position,Travel)
else:
printerr("error loading ",NextScene)
if not NextScene.is_empty():
NextSceneLoaded = load(NextScene)
if (NextSceneLoaded != null):
MapManager.transition_to_scene(NextSceneLoaded,Spawn_Position,Travel)
else:
printerr("error loading ",NextScene)
func _ready():
NextSceneLoaded = load(NextScene)
print(NextSceneLoaded)
if not NextScene.is_empty():
NextSceneLoaded = load(NextScene)
print(NextSceneLoaded)

View file

@ -17,6 +17,7 @@ flip_h = true
script = ExtResource("2_8a3ug")
[node name="Area2D" type="Area2D" parent="."]
collision_layer = 4
input_pickable = false
monitorable = false

View file

@ -31,7 +31,7 @@ func transition_to_scene(new_scene: PackedScene, spawn_location: Vector2, spawn_
else:
next_scene.add_child(new_scene.instantiate())
#region Anim Map
if (next_scene.get_child(0) != null):
if (next_scene.get_child_count() > 0 and next_scene.get_child(0) != null):
match spawn_direction:
0:
$AnimationPlayer.play("travel_left",-1,1)
@ -68,7 +68,7 @@ func on_travel_end():
player.Traveling = false
print("end travel")
func _on_animation_player_animation_finished(anim_name):
func _on_animation_player_animation_finished(_anim_name):
print("anim finished")
current_scene.get_child(0).queue_free()
current_scene.position = Vector2(0,0)
@ -76,4 +76,4 @@ func _on_animation_player_animation_finished(anim_name):
next_scene.get_child(0).reparent(current_scene)
scene_clean(next_scene)
print("level unloaded")
await get_tree().create_timer(1).connect("timeout",Callable(self,"on_travel_end"))
get_tree().create_timer(1).connect("timeout",Callable(self,"on_travel_end"))

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=33 format=3 uid="uid://wlqsvbqpcbh"]
[gd_scene load_steps=30 format=3 uid="uid://wlqsvbqpcbh"]
[ext_resource type="Texture2D" uid="uid://cacwy4tka88k1" path="res://maps/map1.tres" id="1_pt5vq"]
[ext_resource type="Texture2D" uid="uid://bm2nsrfle5nsd" path="res://textures/sprites/floor_door_grass_right1.tres" id="2_0jvyl"]
@ -7,7 +7,6 @@
[ext_resource type="Texture2D" uid="uid://dggavne4ueche" path="res://textures/sprites/Tree_Field_01_SPRT.png" id="4_74dki"]
[ext_resource type="Texture2D" uid="uid://b2nhenx3l2uww" path="res://textures/sprites/floor_door_grass_up1.tres" id="4_f0vha"]
[ext_resource type="PackedScene" uid="uid://do65rgg0p2plt" path="res://core/Door.tscn" id="4_lwk0u"]
[ext_resource type="Texture2D" uid="uid://ddajgcwn5ip4c" path="res://textures/sprites/plants_bush1.tres" id="4_m2p3o"]
[ext_resource type="PackedScene" uid="uid://bddcriwo55x8k" path="res://prefab/prefab_woddenbridge.tscn" id="4_okpsn"]
[ext_resource type="Script" path="res://core/stickernode.gd" id="5_ek34p"]
[ext_resource type="Texture2D" uid="uid://ciyh3rnoo4uk" path="res://textures/atlas/SimpleParticles_All_01_SPRT.png" id="6_0dctx"]
@ -17,7 +16,7 @@
[ext_resource type="Texture2D" uid="uid://c6acjgu8jnrkl" path="res://textures/sprites/rocks_rock1.tres" id="8_bhcew"]
[ext_resource type="PackedScene" uid="uid://kvjctagkwivk" path="res://prefab/prefab_bush1.tscn" id="8_tag7x"]
[ext_resource type="Texture2D" uid="uid://dnomlcslicb3k" path="res://textures/sprites/props_fire1.tres" id="10_2ugv3"]
[ext_resource type="Texture2D" uid="uid://qsse8uwt06ns" path="res://textures/sprites/plants_bush2.tres" id="11_dibxq"]
[ext_resource type="PackedScene" uid="uid://cdurdoebbnau7" path="res://prefab/prefab_bush2.tscn" id="11_u6j5q"]
[ext_resource type="Texture2D" uid="uid://51ntd0qmjw5j" path="res://textures/sprites/props_woodbarrer.tres" id="14_n4lnm"]
[ext_resource type="Texture2D" uid="uid://xx3dwpwk467v" path="res://textures/sprites/stickers_fire1.png" id="19_d8hr8"]
@ -29,14 +28,6 @@ resource_name = "TreeShape"
radius = 70.0
height = 512.0
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_lfx7b"]
radius = 80.0
height = 254.0
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_b3366"]
radius = 65.0
height = 184.05
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4cdlc"]
size = Vector2(133.06, 62.73)
@ -102,6 +93,7 @@ script = ExtResource("3_384sx")
Travel = 1
[node name="Area2D" type="Area2D" parent="Floor/Door"]
collision_layer = 4
input_pickable = false
monitorable = false
@ -140,6 +132,7 @@ position = Vector2(78, -148)
scale = Vector2(6.15, 6.15)
[node name="Bush1" parent="." instance=ExtResource("8_tag7x")]
position = Vector2(-2192, 1176)
[node name="Tree2" type="Sprite2D" parent="."]
position = Vector2(-2399, -55)
@ -222,86 +215,8 @@ position = Vector2(0, -253.27)
rotation = 0.01
shape = SubResource("CapsuleShape2D_dqo8w")
[node name="Bush6" type="Sprite2D" parent="."]
position = Vector2(-1556, 293)
scale = Vector2(3.80334, 3.95089)
texture = ExtResource("4_m2p3o")
centered = false
offset = Vector2(-161.055, -179.785)
metadata/tags = ["sticker"]
[node name="Sticker" type="Area2D" parent="Bush6" node_paths=PackedStringArray("WorldSprite")]
collision_layer = 2
collision_mask = 61
script = ExtResource("5_ek34p")
WorldSprite = NodePath("..")
metadata/tags = PackedStringArray("sticker")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bush6/Sticker"]
position = Vector2(-4.46976, -71.6294)
rotation = 1.6
shape = SubResource("CapsuleShape2D_lfx7b")
[node name="Bush7" type="Sprite2D" parent="."]
position = Vector2(712, 293)
scale = Vector2(3.80334, 3.95089)
texture = ExtResource("4_m2p3o")
centered = false
offset = Vector2(-161.055, -179.785)
metadata/tags = ["sticker"]
[node name="Sticker" type="Area2D" parent="Bush7" node_paths=PackedStringArray("WorldSprite")]
collision_layer = 2
collision_mask = 61
script = ExtResource("5_ek34p")
WorldSprite = NodePath("..")
metadata/tags = PackedStringArray("sticker")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bush7/Sticker"]
position = Vector2(-4.46976, -71.6294)
rotation = 1.6
shape = SubResource("CapsuleShape2D_lfx7b")
[node name="Bush11" type="Sprite2D" parent="."]
position = Vector2(2203, 2322)
scale = Vector2(3.80334, 3.95089)
texture = ExtResource("4_m2p3o")
centered = false
offset = Vector2(-161.055, -179.785)
metadata/tags = ["sticker"]
[node name="Sticker" type="Area2D" parent="Bush11" node_paths=PackedStringArray("WorldSprite")]
collision_layer = 2
collision_mask = 61
script = ExtResource("5_ek34p")
WorldSprite = NodePath("..")
metadata/tags = PackedStringArray("sticker")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bush11/Sticker"]
position = Vector2(-4.46976, -71.6294)
rotation = 1.6
shape = SubResource("CapsuleShape2D_lfx7b")
metadata/_edit_lock_ = true
[node name="Bush10" type="Sprite2D" parent="."]
position = Vector2(-2063, -2116)
scale = Vector2(3.80334, 3.95089)
texture = ExtResource("11_dibxq")
offset = Vector2(0, -63.525)
flip_h = true
metadata/tags = ["sticker"]
[node name="Sticker" type="Area2D" parent="Bush10" node_paths=PackedStringArray("WorldSprite")]
collision_layer = 2
collision_mask = 61
script = ExtResource("5_ek34p")
WorldSprite = NodePath("..")
metadata/tags = PackedStringArray("sticker")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bush10/Sticker"]
position = Vector2(0, -48.95)
rotation = 1.5
shape = SubResource("CapsuleShape2D_b3366")
[node name="Bush20" parent="." instance=ExtResource("11_u6j5q")]
position = Vector2(-2169, -2169)
[node name="Rock1" type="Sprite2D" parent="."]
position = Vector2(-1807, 2030)
@ -462,6 +377,16 @@ offset = Vector2(0, -95.355)
position = Vector2(-1449, -1696)
flip_h = true
[node name="Bush4" parent="." instance=ExtResource("8_tag7x")]
position = Vector2(-1561, 296)
flip_h = true
[node name="Bush5" parent="." instance=ExtResource("8_tag7x")]
position = Vector2(687, 304)
[node name="Bush8" parent="." instance=ExtResource("8_tag7x")]
position = Vector2(2207, 2320)
[node name="Bush3" parent="." instance=ExtResource("8_tag7x")]
position = Vector2(1000, -2228)
flip_h = true
@ -470,9 +395,5 @@ flip_h = true
[connection signal="property_list_changed" from="Tree5" to="Tree5" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Tree6" to="Tree6" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Tree4" to="Tree4" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Bush6" to="Bush6" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Bush7" to="Bush7" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Bush11" to="Bush11" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Bush10" to="Bush10" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Rock1" to="Rock1" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Rock2" to="Rock2" method="_on_property_list_changed"]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=3 uid="uid://5tfe84u3gyty"]
[gd_scene load_steps=26 format=3 uid="uid://5tfe84u3gyty"]
[ext_resource type="Texture2D" uid="uid://bnmlngwnibfnj" path="res://extracted/ref_map2.jpg" id="1_cdv75"]
[ext_resource type="Texture2D" uid="uid://cypb81fuw4w44" path="res://textures/atlas/GroundExtensions_All_01_SPRT.png" id="3_54rqc"]
@ -9,6 +9,8 @@
[ext_resource type="Texture2D" uid="uid://chuv25pm2vqen" path="res://textures/atlas/Rocks_All_01_SPRT.png" id="7_pykf8"]
[ext_resource type="Texture2D" uid="uid://b366mcexlko72" path="res://textures/atlas/LogsAndWood_All_01_SPRT.png" id="8_ugxkt"]
[ext_resource type="Script" path="res://core/stickernode.gd" id="9_ap7ts"]
[ext_resource type="PackedScene" uid="uid://kvjctagkwivk" path="res://prefab/prefab_bush1.tscn" id="10_hc0vj"]
[ext_resource type="PackedScene" uid="uid://cdurdoebbnau7" path="res://prefab/prefab_bush2.tscn" id="11_hypxn"]
[sub_resource type="AtlasTexture" id="AtlasTexture_rckkj"]
atlas = ExtResource("3_54rqc")
@ -54,6 +56,13 @@ region = Rect2(544, 1728, 416, 288)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ontns"]
size = Vector2(325.915, 124.47)
[sub_resource type="AtlasTexture" id="AtlasTexture_3kc8y"]
atlas = ExtResource("7_pykf8")
region = Rect2(1728, 1248, 288, 320)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bimlt"]
size = Vector2(258.691, 98.1358)
[node name="Map2" type="Node2D"]
z_as_relative = false
y_sort_enabled = true
@ -65,8 +74,11 @@ texture = ExtResource("3_gbt28")
metadata/_edit_lock_ = true
[node name="StaticBody2D" type="StaticBody2D" parent="Floor"]
collision_layer = 16
collision_mask = 9
[node name="CollisionPolygon2D2" type="CollisionPolygon2D" parent="Floor/StaticBody2D"]
visible = false
position = Vector2(5.32593, -60.2381)
build_mode = 1
polygon = PackedVector2Array(-448, -432.5, -29.5759, -431.73, -29.5681, -475.661, 128.557, -481.354, 134.066, -431.429, 458, -430.833, 451.235, 453.255, -443.154, 454.357, -444.694, 85.548, -509.269, 86.1331, -512.758, -74.563, -445.734, -77.3378)
@ -76,6 +88,8 @@ position = Vector2(-80.2562, 4.59132)
texture = SubResource("AtlasTexture_rckkj")
[node name="StaticBody2D" type="StaticBody2D" parent="Floor/Dock"]
collision_layer = 16
collision_mask = 9
[node name="CollisionPolygon2D2" type="CollisionPolygon2D" parent="Floor/Dock/StaticBody2D"]
polygon = PackedVector2Array(-27.3642, 105.6, -27.9152, 135.719, 220.751, 132.965, 225.158, 140.494, 224.791, 257.481, 219.465, 271.071, -183.653, 270.52, -186.926, 119.417, -187.142, 109.457, -181.082, 109.824, -178.143, 264.46, 217.628, 264.46, 218.179, 139.943, -31.221, 141.78, -31.7719, 105.049)
@ -95,7 +109,6 @@ Travel = 2
Spawn_Position = Vector2(0, 2317)
[node name="RefMap2" type="Sprite2D" parent="."]
visible = false
modulate = Color(1, 1, 1, 0.741176)
z_index = -5
position = Vector2(-123, -696)
@ -135,6 +148,8 @@ offset = Vector2(-78.385, -130.2)
metadata/tags = ["rock"]
[node name="StaticBody2D" type="StaticBody2D" parent="Rock1"]
collision_layer = 16
collision_mask = 9
[node name="CollisionShape2D" type="CollisionShape2D" parent="Rock1/StaticBody2D"]
position = Vector2(7.915, -31.39)
@ -150,6 +165,8 @@ offset = Vector2(-52.525, -167.375)
metadata/tags = ["sticker"]
[node name="StaticBody2D" type="StaticBody2D" parent="Box1"]
collision_layer = 16
collision_mask = 9
[node name="CollisionShape2D" type="CollisionShape2D" parent="Box1/StaticBody2D"]
position = Vector2(0, -49.595)
@ -158,7 +175,7 @@ debug_color = Color(0.996033, 0, 0.194446, 0.42)
[node name="Sticker" type="Area2D" parent="Box1" node_paths=PackedStringArray("WorldSprite")]
collision_layer = 2
collision_mask = 15
collision_mask = 61
script = ExtResource("9_ap7ts")
WorldSprite = NodePath("..")
metadata/tags = PackedStringArray("sticker")
@ -177,6 +194,8 @@ offset = Vector2(-54.04, -167.375)
metadata/tags = ["sticker"]
[node name="StaticBody2D" type="StaticBody2D" parent="Box2"]
collision_layer = 16
collision_mask = 9
[node name="CollisionShape2D" type="CollisionShape2D" parent="Box2/StaticBody2D"]
position = Vector2(0, -49.595)
@ -185,7 +204,7 @@ debug_color = Color(0.996033, 0, 0.194446, 0.42)
[node name="Sticker" type="Area2D" parent="Box2" node_paths=PackedStringArray("WorldSprite")]
collision_layer = 2
collision_mask = 15
collision_mask = 61
script = ExtResource("9_ap7ts")
WorldSprite = NodePath("..")
metadata/tags = PackedStringArray("sticker")
@ -204,6 +223,8 @@ offset = Vector2(-126.11, -220.56)
metadata/tags = ["rock"]
[node name="StaticBody2D" type="StaticBody2D" parent="Rock2"]
collision_layer = 16
collision_mask = 9
[node name="CollisionShape2D" type="CollisionShape2D" parent="Rock2/StaticBody2D"]
position = Vector2(0, -66.02)
@ -219,12 +240,38 @@ offset = Vector2(-208.35, -260.555)
metadata/tags = ["rock"]
[node name="StaticBody2D" type="StaticBody2D" parent="Rock3"]
collision_layer = 16
collision_mask = 9
[node name="CollisionShape2D" type="CollisionShape2D" parent="Rock3/StaticBody2D"]
position = Vector2(0, -65.23)
shape = SubResource("RectangleShape2D_ontns")
debug_color = Color(0.996033, 0, 0.194446, 0.42)
[node name="Rock4" type="Sprite2D" parent="."]
position = Vector2(1403, -2255)
scale = Vector2(4.97891, 4.95232)
texture = SubResource("AtlasTexture_3kc8y")
offset = Vector2(0, -146.15)
metadata/tags = ["rock"]
[node name="StaticBody2D" type="StaticBody2D" parent="Rock4"]
collision_layer = 16
collision_mask = 9
[node name="CollisionShape2D" type="CollisionShape2D" parent="Rock4/StaticBody2D"]
position = Vector2(0, -64.212)
shape = SubResource("RectangleShape2D_bimlt")
debug_color = Color(0.996033, 0, 0.194446, 0.42)
[node name="Bush1" parent="." instance=ExtResource("10_hc0vj")]
position = Vector2(-1686, -1649)
[node name="Bush10" parent="." instance=ExtResource("11_hypxn")]
position = Vector2(2187, -1459)
scale = Vector2(3.9, 4.052)
flip_h = false
[connection signal="property_list_changed" from="Tree1" to="Tree1" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Tree2" to="Tree2" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Tree3" to="Tree3" method="_on_property_list_changed"]
@ -233,3 +280,4 @@ debug_color = Color(0.996033, 0, 0.194446, 0.42)
[connection signal="property_list_changed" from="Box2" to="Box2" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Rock2" to="Rock2" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Rock3" to="Rock3" method="_on_property_list_changed"]
[connection signal="property_list_changed" from="Rock4" to="Rock4" method="_on_property_list_changed"]

46
prefab/prefab_bush1.tscn Normal file
View file

@ -0,0 +1,46 @@
[gd_scene load_steps=5 format=3 uid="uid://kvjctagkwivk"]
[ext_resource type="Texture2D" uid="uid://ddajgcwn5ip4c" path="res://textures/sprites/plants_bush1.tres" id="1_gcxqk"]
[ext_resource type="Script" path="res://core/stickernode.gd" id="2_aj8js"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_lfx7b"]
resource_name = "bush1_sticker_zone"
radius = 80.0
height = 254.0
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ke631"]
resource_name = "bush1_detection_zone"
radius = 15.0
height = 150.0
[node name="Bush1" type="Sprite2D"]
scale = Vector2(3.80334, 3.95089)
texture = ExtResource("1_gcxqk")
centered = false
offset = Vector2(-161.055, -179.785)
metadata/tags = ["sticker"]
[node name="Sticker" type="Area2D" parent="." node_paths=PackedStringArray("WorldSprite", "DetectionArea")]
collision_layer = 2
collision_mask = 61
script = ExtResource("2_aj8js")
WorldSprite = NodePath("..")
DetectionArea = NodePath("DetectionZone")
metadata/tags = PackedStringArray("sticker")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sticker"]
position = Vector2(-4.46973, -71.6294)
rotation = 1.6
shape = SubResource("CapsuleShape2D_lfx7b")
[node name="DetectionZone" type="Area2D" parent="Sticker"]
collision_layer = 4
collision_mask = 61
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sticker/DetectionZone"]
position = Vector2(0, -5.415)
rotation = 1.5708
shape = SubResource("CapsuleShape2D_ke631")
debug_color = Color(1.29953e-06, 0.637445, 0.391979, 0.42)
[connection signal="property_list_changed" from="." to="." method="_on_property_list_changed"]

43
prefab/prefab_bush2.tscn Normal file
View file

@ -0,0 +1,43 @@
[gd_scene load_steps=5 format=3 uid="uid://cdurdoebbnau7"]
[ext_resource type="Texture2D" uid="uid://qsse8uwt06ns" path="res://textures/sprites/plants_bush2.tres" id="1_thd4i"]
[ext_resource type="Script" path="res://core/stickernode.gd" id="2_f0erb"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_b3366"]
radius = 56.13
height = 184.05
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_1mqq3"]
height = 110.0
[node name="Bush10" type="Sprite2D"]
scale = Vector2(3.80334, 3.95089)
texture = ExtResource("1_thd4i")
offset = Vector2(0, -63.525)
flip_h = true
metadata/tags = ["sticker"]
[node name="Sticker" type="Area2D" parent="." node_paths=PackedStringArray("WorldSprite", "DetectionArea")]
collision_layer = 2
collision_mask = 61
script = ExtResource("2_f0erb")
WorldSprite = NodePath("..")
DetectionArea = NodePath("DetectionZone")
metadata/tags = PackedStringArray("sticker")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sticker"]
position = Vector2(0, -55.845)
rotation = 1.5708
shape = SubResource("CapsuleShape2D_b3366")
[node name="DetectionZone" type="Area2D" parent="Sticker"]
collision_layer = 4
collision_mask = 61
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sticker/DetectionZone"]
position = Vector2(0, -10)
rotation = 1.5708
shape = SubResource("CapsuleShape2D_1mqq3")
debug_color = Color(1.29953e-06, 0.637445, 0.391979, 0.42)
[connection signal="property_list_changed" from="." to="." method="_on_property_list_changed"]