One_Eleven_Android/scripts/backround_scenes_scripts/Panorama.gd
2024-11-10 03:34:28 +03:00

343 lines
10 KiB
GDScript

extends Node2D
const fadingTime = 0.5
onready var arrowCursor = preload("res://resources/cursors/arrow2.webp");
func _ready():
if not get_tree().root.has_node("Root"):
return ;
GallerySingleton.AddBackground("Panorama")
if Dialogic.get_variable("CandlesOn") == "1":
$Candles.visible = true
else :
$Candles.visible = false
if Dialogic.get_variable("LightsOn") == "1":
$Candles / Day.visible = true
$Candles / Night.visible = false
else :
$Candles / Day.visible = false
$Candles / Night.visible = true
$Background.texture = load("res://resources/graphics/backgrounds/panorama/Night/combined.webp");
var chars = ["grayPanorama", "blackPanorama", "redPanorama", "greenPanorama", "pinkPanorama", "blue_mPanorama", "whitePanorama", "purplePanorama"]
for i in chars:
if Dialogic.get_variable(i) == "1":
var string = i.replace("Panorama", "")
AddChar(true, "add_" + string)
var dialogicNode = get_parent().get_parent().get_node("Game").get_child(0).get_child(0)
dialogicNode.connect("dialogic_signal", self, "_lights_listener")
var panoPosition = int(Dialogic.get_variable("PanoramaPosition"))
position.x = panoPosition;
if get_tree().root.get_node("Root/AlternativeChoices").get_child_count() != 0:
var alt = get_tree().root.get_node("Root/AlternativeChoices").get_child(0);
alt.get_node("SpriteButtons").position.x = panoPosition;
alt.get_node("Labels").position.x = panoPosition;
func _lights_listener(string):
match string:
"lights_on":
Dialogic.set_variable("LightsOn", 1)
$Background.texture = load("res://resources/graphics/backgrounds/panorama/Day/combined.webp");
"lights_off":
Dialogic.set_variable("LightsOn", 0)
$Background.texture = load("res://resources/graphics/backgrounds/panorama/Night/combined.webp");
"add_white":
AddChar(s("Is_White_Dead"), string)
"remove_white":
RemoveChar(string)
"add_black":
AddChar(s("Is_Black_Dead"), string)
"remove_black":
RemoveChar(string)
"add_blue_m":
AddChar(s("Is_Blue_M_Dead"), string)
"remove_blue_m":
RemoveChar(string)
"add_gray":
AddChar(s("Is_Gray_Dead"), string)
"remove_gray":
RemoveChar(string)
"add_green":
AddChar(s("Is_Green_Dead"), string)
"remove_green":
RemoveChar(string)
"add_pink":
AddChar(s("Is_Pink_Dead"), string)
"remove_pink":
RemoveChar(string)
"add_purple":
AddChar(s("Is_Purple_Dead"), string)
"remove_purple":
RemoveChar(string)
"add_red":
AddChar(s("Is_Red_Dead"), string)
"remove_red":
RemoveChar(string)
"candles_on":
$Candles.modulate = Color(1, 1, 1, 0)
$Candles.visible = true
Dialogic.set_variable("CandlesOn", 1)
$Tween.interpolate_property($Candles, "modulate", Color(1, 1, 1, 0), Color(1, 1, 1, 1), fadingTime, Tween.TRANS_LINEAR, 0)
$Tween.start()
"candles_off":
$TweenOut.interpolate_property($Candles, "modulate", Color(1, 1, 1, 1), Color(1, 1, 1, 0), fadingTime, Tween.TRANS_LINEAR, 0)
$TweenOut.start()
Dialogic.set_variable("CandlesOn", 0)
"add_all120":
AddChar(s("Is_Red_Dead"), "add_red")
AddChar(s("Is_White_Dead"), "add_white")
AddChar(s("Is_Purple_Dead"), "add_purple")
AddChar(s("Is_Blue_M_Dead"), "add_blue_m")
AddChar(s("Is_Pink_Dead"), "add_pink")
AddChar(s("Is_Green_Dead"), "add_green")
AddChar(s("Is_Black_Dead"), "add_black")
AddChar(s("Is_Gray_Dead"), "add_gray")
"add_all140":
AddChar(s("Is_Red_Dead"), "add_red")
AddChar(s("Is_White_Dead"), "add_white")
"remove_all120":
var chars = []
if Dialogic.get_variable("redPanorama") == "1":
chars.push_back("red")
call_deferred("deferredDialogic", "redPanorama", 0)
if Dialogic.get_variable("whitePanorama") == "1":
chars.push_back("white")
call_deferred("deferredDialogic", "whitePanorama", 0)
if Dialogic.get_variable("purplePanorama") == "1":
chars.push_back("purple")
call_deferred("deferredDialogic", "purplePanorama", 0)
if Dialogic.get_variable("blue_mPanorama") == "1":
chars.push_back("blue_m")
call_deferred("deferredDialogic", "blue_mPanorama", 0)
if Dialogic.get_variable("pinkPanorama") == "1":
chars.push_back("pink")
call_deferred("deferredDialogic", "pinkPanorama", 0)
if Dialogic.get_variable("greenPanorama") == "1":
chars.push_back("green")
call_deferred("deferredDialogic", "greenPanorama", 0)
if Dialogic.get_variable("blackPanorama") == "1":
chars.push_back("black")
call_deferred("deferredDialogic", "blackPanorama", 0)
if Dialogic.get_variable("grayPanorama") == "1":
chars.push_back("gray")
call_deferred("deferredDialogic", "grayPanorama", 0)
for i in chars:
$Timer.set_wait_time(0.05)
$Timer.set_one_shot(true)
$Timer.start()
yield ($Timer, "timeout")
$TweenOut.interpolate_property($removable.get_node(i), "modulate", Color(1, 1, 1, 1), Color(1, 1, 1, 0), fadingTime, Tween.TRANS_LINEAR, 0)
$TweenOut.start()
"remove_all140":
var chars = []
if Dialogic.get_variable("redPanorama") == "1":
chars.push_back("red")
call_deferred("deferredDialogic", "redPanorama", 0)
if Dialogic.get_variable("whitePanorama") == "1":
chars.push_back("white")
call_deferred("deferredDialogic", "whitePanorama", 0)
for i in chars:
$Timer.set_wait_time(0.1)
$Timer.set_one_shot(true)
$Timer.start()
yield ($Timer, "timeout")
$TweenOut.interpolate_property($removable.get_node(i), "modulate", Color(1, 1, 1, 1), Color(1, 1, 1, 0), fadingTime, Tween.TRANS_LINEAR, 0)
$TweenOut.start()
"invisible_all":
for i in $removable.get_children():
i.visible = false
func deferredDialogic(string, value):
Dialogic.set_variable(string, value)
func s(variable:String)->bool:
return Dialogic.get_variable(variable) == "0";
func AddChar(isAlive:bool, string:String):
if not isAlive:
return
var charNode
var string2 = string.replace("add_", "")
var stringForDialogic = string2 + "Panorama"
deferredDialogic(stringForDialogic, 1)
charNode = $removable.get_node(string2)
charNode.modulate = Color(1, 1, 1, 0)
charNode.visible = true
$Tween.interpolate_property(charNode, "modulate", Color(1, 1, 1, 0), Color(1, 1, 1, 1), fadingTime, Tween.TRANS_LINEAR, 0)
$Tween.start()
func RemoveChar(string):
var charNode
var string2 = string.replace("remove_", "")
var stringForDialogic = string2 + "Panorama"
if Dialogic.get_variable(stringForDialogic) == "1":
charNode = $removable.get_node(string2)
$TweenOut.interpolate_property(charNode, "modulate", Color(1, 1, 1, 1), Color(1, 1, 1, 0), fadingTime, Tween.TRANS_LINEAR, 0)
$TweenOut.start()
func _on_TweenOut_tween_completed(object, _key):
object.visible = false
onready var leftFire:AudioStreamPlayer = $LeftFireEffect;
onready var rightRain:AudioStreamPlayer = $RightRainEffect
func UpdateContainerSound(x:int):
leftFire.volume_db = LeftVolume(x);
rightRain.volume_db = RightVolume(x);
func LeftVolume(x:int)->float:
return 0.013 * x - 13;
func RightVolume(x:int)->float:
return - 0.0196 * x - 36;
func _exit_tree():
Input.set_custom_mouse_cursor(arrowCursor)
Dialogic.set_variable("PanoramaPosition", "-460");
var isGallery:bool = false;
func InitForGallery()->Array:
$Background.scale = Vector2(0.5, 0.5)
$Candles.scale = Vector2(0.5, 0.5)
$Clock.scale = Vector2(0.5, 0.5)
$removable.scale = Vector2(0.5, 0.5)
FUCKVisibile();
isGallery = true;
$MovingControls.visible = true;
return ["ui_gallery_light", "ui_gallery_candles", "ui_gallery_people"]
var galleryIsDay = true;
func SetToggleSettings(button):
var text = button.text;
var state = button.pressed;
if text == tr("ui_gallery_light"):
if state == true:
$Background.texture = load("res://resources/graphics/backgrounds/panorama/Night/combined.webp");
galleryIsDay = false;
if $Candles / Day.visible:
$Candles / Night.visible = true;
$Candles / Day.visible = false;
else :
$Background.texture = load("res://resources/graphics/backgrounds/panorama/Day/combined.webp");
galleryIsDay = true;
if $Candles / Night.visible:
$Candles / Night.visible = false;
$Candles / Day.visible = true;
elif text == tr("ui_gallery_candles"):
if state == true:
if galleryIsDay:
$Candles / Day.visible = true;
$Candles / Night.visible = false;
$Candles / Lights.visible = true;
else :
$Candles / Day.visible = false;
$Candles / Night.visible = true;
$Candles / Lights.visible = true;
else :
$Candles / Day.visible = false;
$Candles / Night.visible = false;
$Candles / Lights.visible = false;
elif text == tr("ui_gallery_people"):
for i in $removable.get_children():
i.visible = state;
func FUCKVisibile():
var timer = Timer.new();
add_child(timer);
timer.set_wait_time(0.1);
timer.set_one_shot(true);
timer.start();
timer.connect("timeout", self, "FUCKFUCK", [timer]);
func FUCKFUCK(timer):
$Candles / Lights.call_deferred("set_visible", false)
$Candles.call_deferred("set_visible", true);
$Candles / Day.call_deferred("set_visible", false);
$Candles / Night.call_deferred("set_visible", false);
timer.disconnect("timeout", self, "FUCKFUCK")
remove_child(timer);
var cursorRight = preload("res://resources/cursors/man_right.webp")
var cursorLeft = preload("res://resources/cursors/man_left.webp")
var movingLeft = false;
var movingRight = false;
const movingSpeed = 310;
const edgePosition = - 920;
func _on_LeftMove_mouse_entered():
if position.x < 0:
Input.set_custom_mouse_cursor(cursorLeft)
movingLeft = true
func _on_LeftMove_mouse_exited():
Input.set_custom_mouse_cursor(arrowCursor)
movingLeft = false
func _on_RightMove_mouse_entered():
if position.x > edgePosition:
Input.set_custom_mouse_cursor(cursorRight, 0, Vector2(50, 0))
movingRight = true
func _on_RightMove_mouse_exited():
Input.set_custom_mouse_cursor(arrowCursor)
movingRight = false
func _process(delta):
if not isGallery:
return ;
if position.x == 0:
if $MovingControls / LeftMove.visible:
$MovingControls / LeftMove.visible = false;
_on_LeftMove_mouse_exited();
elif position.x == edgePosition:
if $MovingControls / RightMove.visible:
$MovingControls / RightMove.visible = false;
_on_RightMove_mouse_exited();
else :
if not $MovingControls / LeftMove.visible:
$MovingControls / LeftMove.visible = true
if not $MovingControls / RightMove.visible:
$MovingControls / RightMove.visible = true;
if movingLeft:
var value = delta * movingSpeed;
position.x += value
$MovingControls.position.x -= value
if position.x > 0:
position.x = 0
movingLeft = false
elif movingRight:
var value = delta * movingSpeed;
position.x -= value
$MovingControls.position.x += value
if position.x < edgePosition:
position.x = edgePosition
movingRight = false