extends Control var currentTimeLine; var currentBackground; var insideScenes = ["Scene2_1", "Scene2_2", "Scene9", "Garaj", "Podval", "Vtoroi_etaj", "Tretii_etaj", "Panorama"]; var outsideScenes = ["Scene2", "Scene6", "Scene7", "Scene9", "Scene12", "Garaj", "Mayak", "Sarai", "Pristan"]; var positions = [ {"background":"Scene2_1", "place":"Map/Inside/Places/Gl-Rest"}, {"background":"Scene2", "place":"Map/Outside/Places/Front"}, {"background":"Scene2_2", "place":"Map/Inside/Places/Kitchen"}, {"background":"Scene9", "place":"Map/Inside/Places/Smoking"}, {"background":"Scene9", "place":"Map/Outside/Places/Smoking"}, {"background":"Scene12", "place":"Map/Outside/Places/Ravine"}, {"background":"Garaj", "place":"Map/Inside/Places/Garage"}, {"background":"Garaj", "place":"Map/Outside/Places/Garage"}, {"background":"Podval", "place":"Map/Inside/Places/Basement"}, {"background":"Vtoroi_etaj", "place":"Map/Inside/Places/2ndFloor"}, {"background":"Tretii_etaj", "place":"Map/Inside/Places/3rdFloor"}, {"background":"Panorama", "place":"Map/Inside/Places/Gl-Rest"}, {"background":"Mayak", "place":"Map/Outside/Places/LightHouse"}, {"background":"Sarai", "place":"Map/Outside/Places/Sarai"}, {"background":"Pristan", "place":"Map/Outside/Places/Pier"}, {"background":"Scene6", "place":"Map/Outside/Places/Parking"}, {"background":"Scene7", "place":"Map/Outside/Places/Bridge"}, ] var routes = [ { "fromTimeline":"Timeline_3_1", "routes":[ {"timeline":"8.1", "place":"Map/Inside/Places/Exit"} ] }, { "fromTimeline":"Timeline_5", "routes":[ {"timeline":"12.1", "place":"Map/Outside/Places/Ravine"}, {"timeline":"12.3", "place":"Map/Outside/Places/Smoking"}, {"timeline":"12.4", "time":">", "place":"Map/Outside/Places/Restaurant"}, {"timeline":"12.sofa", "time":"<", "place":"Map/Outside/Places/Restaurant"}, {"timeline":"walk_garage", "place":"Map/Outside/Places/Garage"}, {"timeline":"walk_sarai", "place":"Map/Outside/Places/Sarai"}, {"timeline":"walk_mayak", "place":"Map/Outside/Places/LightHouse"}, ] }, { "fromTimeline":"Timeline_6", "routes":[ {"timeline":"13.1", "place":"Map/Inside/Places/Exit"} ] }, { "fromTimeline":"Timeline_Sofa", "routes":[ {"timeline":"127.4", "place":"Map/Inside/Places/Exit"} ] }, { "fromTimeline":"Timeline_5_garage", "routes":[ {"timeline":"back", "place":"Map/Outside/Places/Front"}, {"timeline":"smoking", "place":"Map/Outside/Places/Smoking"}, ] }, { "fromTimeline":"Timeline_5_tropinka", "routes":[ {"timeline":"back", "place":"Map/Outside/Places/Front"}, {"timeline":"walk_pristan", "place":"Map/Outside/Places/Pier"}, ] }, { "fromTimeline":"Timeline_5_pristan", "routes":[ {"timeline":"back", "place":"Map/Outside/Places/Sarai"}, ] }, { "fromTimeline":"Timeline_5_lighthouse", "routes":[ {"timeline":"back", "place":"Map/Outside/Places/Front"}, ] }, { "fromTimeline":"Timeline_7_1", "routes":[ {"timeline":"15.2_t", "time":">", "place":"Map/Outside/Places/Restaurant"}, {"timeline":"15.2", "time":"<", "place":"Map/Outside/Places/Restaurant"}, {"timeline":"15.1", "time":"<", "place":"Map/Outside/Places/Ravine"}, {"timeline":"15.3", "time":"<", "place":"Map/Outside/Places/Smoking"}, ] }, { "fromTimeline":"Timeline_8_1", "routes":[ {"timeline":"20.time", "time":">", "place":"Map/Outside/Places/Restaurant"}, {"timeline":"20.1", "time":"<", "place":"Map/Outside/Places/Restaurant"}, ] }, { "fromTimeline":"Timeline_9", "routes":[ {"timeline":"21.2", "place":"Map/Outside/Places/Front"}, {"timeline":"21.garage", "place":"Map/Outside/Places/Garage"}, ] }, { "fromTimeline":"Timeline_10_2", "routes":[ {"timeline":"25.time", "time":">", "place":"Map/Outside/Places/Front"}, {"timeline":"25.2", "time":"<", "place":"Map/Outside/Places/Front"}, {"timeline":"25.garage", "time":"<", "place":"Map/Outside/Places/Garage"}, ] }, { "fromTimeline":"Timeline_32_2", "routes":[ {"timeline":"190.2", "place":"Map/Outside/Places/Smoking"}, {"timeline":"190.3", "place":"Map/Outside/Places/LightHouse"}, {"timeline":"190.5", "place":"Map/Outside/Places/Sarai"}, ] }, { "fromTimeline":"Timeline_120_basement", "routes":[ {"timeline":"back", "place":"Map/Inside/Places/Gl-Rest"}, ] }, { "fromTimeline":"Timeline_120_main", "routes":[ {"timeline":"120_h", "place":"Map/Inside/Places/Garage"}, {"timeline":"120_r", "place":"Map/Inside/Places/Kitchen"}, {"timeline":"120_basement", "place":"Map/Inside/Places/Basement"}, ] }, { "fromTimeline":"Timeline_before_129", "routes":[ {"timeline":"129_back", "place":"Map/Inside/Places/Gl-Rest"}, ] }, { "fromTimeline":"Timeline_before_130", "routes":[ {"timeline":"back", "place":"Map/Inside/Places/Gl-Rest"}, {"timeline":"120_w_front", "place":"Map/Outside/Places/Front"}, {"timeline":"120_w_smoking", "place":"Map/Outside/Places/Smoking"}, ] }, { "fromTimeline":"Timeline_140_main", "routes":[ {"timeline":"141", "place":"Map/Inside/Places/Exit"}, {"timeline":"142_h", "place":"Map/Inside/Places/Garage"}, {"timeline":"2nd_floor", "place":"Map/Inside/Places/2ndFloor"}, {"timeline":"143", "place":"Map/Inside/Places/Basement"}, {"timeline":"149", "place":"Map/Inside/Places/Kitchen"}, ] }, { "fromTimeline":"Timeline_before_141", "routes":[ {"timeline":"141_garage", "place":"Map/Inside/Places/Garage"}, {"timeline":"141_rest", "place":"Map/Outside/Places/Restaurant"}, {"timeline":"141_smoking", "place":"Map/Outside/Places/Smoking"}, {"timeline":"141_lighthouse", "place":"Map/Outside/Places/LightHouse"}, ] }, { "fromTimeline":"Timeline_before_142_h", "routes":[ {"timeline":"142_back", "place":"Map/Inside/Places/Gl-Rest"}, {"timeline":"142_3", "place":"Map/Inside/Places/Smoking"}, ] }, { "fromTimeline":"Timeline_before_143", "routes":[ {"timeline":"143_back", "place":"Map/Inside/Places/Gl-Rest"}, ] }, { "fromTimeline":"Timeline_before_149", "routes":[ {"timeline":"149_back", "place":"Map/Inside/Places/Gl-Rest"}, ] }, { "fromTimeline":"Timeline_before_2nd_floor", "routes":[ {"timeline":"2nd_down", "place":"Map/Inside/Places/Gl-Rest"}, {"timeline":"2nd_up", "place":"Map/Inside/Places/3rdFloor"}, {"timeline":"2nd_1", "floorCheck":"Timeline146,Is_Black_Dead", "place":"Map/Inside/Places/Room1"}, {"timeline":"2nd_2", "floorCheck":"Timeline147,Is_Green_Dead", "place":"Map/Inside/Places/Room2"}, {"timeline":"2nd_office", "place":"Map/Inside/Places/OfficeH"}, ] }, { "fromTimeline":"Timeline_before_3rd_floor", "routes":[ {"timeline":"3rd_down", "place":"Map/Inside/Places/2ndFloor"}, {"timeline":"3rd_3", "floorCheck":"Timeline145,Is_Blue_M_Dead", "place":"Map/Inside/Places/Room3"}, {"timeline":"3rd_4", "ifzero":"Timeline146_a", "place":"Map/Inside/Places/Room4"}, {"timeline":"3rd_5", "floorCheck":"Timeline148,Is_Purple_Dead", "place":"Map/Inside/Places/Room5"}, ] }, ] func _ready(): Localization(); DisableAllPlaces(); func ProcessMapFromMenuButton(): currentTimeLine = Dialogic.get_variable("TimelineSave"); currentBackground = Dialogic.get_variable("CurrentBackground"); ShowMap(); ShowPlayer(); func ProcessMap()->bool: currentTimeLine = Dialogic.get_variable("TimelineSave"); currentBackground = Dialogic.get_variable("CurrentBackground"); DisableAllPlaces(); ShowMap(); ShowPlayer(); return FindPlaces(); func DisableAllPlaces(): for i in $Map / Inside / Places.get_children(): if i is TextureButton: DisablePlace(i); for i in $Map / Outside / Places.get_children(): if i is TextureButton: DisablePlace(i); func EnablePlace(place:TextureButton, timeline:String): place.disabled = false; var _temp = place.connect("pressed", self, "placePressed", [timeline]); _temp = place.connect("mouse_entered", self, "placeMouseOn", [place]); _temp = place.connect("mouse_exited", self, "placeMouseOff", [place]); func DisablePlace(place:TextureButton): place.disabled = true; if place.is_connected("pressed", self, "placePressed"): place.disconnect("pressed", self, "placePressed"); if place.is_connected("mouse_entered", self, "placeMouseOn"): place.disconnect("mouse_entered", self, "placeMouseOn"); if place.is_connected("mouse_exited", self, "placeMouseOff"): place.disconnect("mouse_exited", self, "placeMouseOff"); func ShowMap(): $Map / SwitchButton.visible = false; if currentBackground in insideScenes and currentBackground in outsideScenes: $Map / Outside.visible = true; $Map / Inside.visible = false; $Map / SwitchButton.visible = true; elif currentBackground in insideScenes: $Map / Inside.visible = true; $Map / Outside.visible = false; elif currentBackground in outsideScenes: $Map / Outside.visible = true; $Map / Inside.visible = false; else : pass func ShowPlayer(): for i in positions: if i["background"] == currentBackground: var temp = get_node(i["place"]); if temp.get_parent().get_parent().visible: var pos = temp.rect_global_position + temp.rect_size * temp.rect_scale * 0.5; $Map / PlayerPosition.rect_global_position = pos + Vector2( - 30, - 60); break; func FindPlaces()->bool: var routeObj = {}; var success = false; for i in routes: if i["fromTimeline"] == currentTimeLine: routeObj = i.duplicate(); break for i in routeObj["routes"]: var place = get_node(i["place"]); var timeline = i["timeline"]; if i.has("time"): var time = int(Dialogic.get_variable("Time")); if i["time"] == ">": if time >= 45: EnablePlace(place, timeline); else : if time < 45: EnablePlace(place, timeline); elif i.has("ifzero"): var value = Dialogic.get_variable(i["ifzero"]); if value == "0": EnablePlace(place, timeline); elif i.has("floorCheck"): var array = str(i["floorCheck"]).split(","); var timelineValue = Dialogic.get_variable(array[0]); var deadValue = Dialogic.get_variable(array[1]); if timelineValue == "0" and deadValue == "0": EnablePlace(place, timeline); else : EnablePlace(place, timeline); success = true; return success; func placePressed(timeline:String): get_tree().root.get_node("Root/Game").get_child(0).get_child(0)._on_MapButton_button_down(); yield (get_tree().create_timer(0.1), "timeout"); DisableAllPlaces(); Dialogic.set_variable("PreviousTimelineChoice", timeline); var game = get_tree().root.get_node("Root"); game.removeAlternative(); func placeMouseOn(place:TextureButton): place.self_modulate = Color(0.7, 0.7, 0.7, 1); func placeMouseOff(place:TextureButton): place.self_modulate = Color(1, 1, 1, 1); func _on_SwitchButton_pressed(): if $Map / Inside.visible: $Map / Inside.visible = false; $Map / Outside.visible = true; elif $Map / Outside.visible: $Map / Inside.visible = true; $Map / Outside.visible = false; ShowPlayer(); func Localization(): $Map / SwitchButton.text = tr("ui_switch_map"); var mapLoc = LanguageLocalization.GetMapLocalization(); for i in mapLoc: get_node(i).text = tr(mapLoc[i]); func _on_CloseButton_button_up(): get_tree().root.get_node("Root/Game").get_child(0).get_child(0)._on_MapButton_button_down();