1006 lines
27 KiB
GDScript
1006 lines
27 KiB
GDScript
extends Node2D
|
||
var windowSize
|
||
|
||
var DialogicNode;
|
||
|
||
var allowToDisplayMenu;
|
||
|
||
var thread;
|
||
|
||
|
||
var isShaking = false
|
||
var trauma = 0.0
|
||
onready var noise = OpenSimplexNoise.new()
|
||
var noise_y = 0
|
||
|
||
signal alt_choice_completed
|
||
|
||
signal backgroundLoaded;
|
||
|
||
func _ready():
|
||
get_node("/root/BgmScene").StopMenuMusic()
|
||
windowSize = SettingsSingleton.GetCurrectScreenResolutionVector2()
|
||
|
||
|
||
RunDialogic();
|
||
|
||
$GameText.SetNames()
|
||
|
||
if not SceneLoader.is_connected("on_scene_loaded", self, "async_scene_loaded"):
|
||
var _temp = SceneLoader.connect("on_scene_loaded", self, "async_scene_loaded")
|
||
|
||
func RunDialogic():
|
||
thread = Thread.new();
|
||
thread.start(self, "InitDialogic")
|
||
|
||
func InitDialogic():
|
||
var timeline = Dialogic.get_variable("TimelineSave");
|
||
var dialogic = Dialogic.start(timeline);
|
||
call_deferred("DialogicReady", dialogic);
|
||
|
||
func DialogicReady(dialogic):
|
||
Dialogic.set_variable("NeedCharacter", 1)
|
||
|
||
$Game.add_child(dialogic);
|
||
DialogicNode = dialogic;
|
||
|
||
yield (get_tree().create_timer(0.1), "timeout");
|
||
get_tree().root.get_node("Loading").visible = false;
|
||
|
||
var _temp = setBackground(Dialogic.get_variable("CurrentBackground"), true);
|
||
SetBGM(Dialogic.get_variable("CurrentBGM"));
|
||
|
||
CheckDLC();
|
||
|
||
|
||
var _r = thread.wait_to_finish();
|
||
|
||
func CheckDLC():
|
||
if SettingsSingleton.GetUseDlc():
|
||
Dialogic.set_variable("DLC", "1");
|
||
# Steam.set_achievement("DLC_OnRun");
|
||
else :
|
||
Dialogic.set_variable("DLC", "0");
|
||
|
||
|
||
|
||
var backgroundLoadingScene = "";
|
||
func setBackground(sceneName, ignoreFade = false, fadeTime = 1.75)->bool:
|
||
$Darkening.interpolateTime = float(fadeTime);
|
||
fadeTime = float(fadeTime)
|
||
var backs = $"Background";
|
||
|
||
if Dialogic.get_variable("CurrentBackground") == sceneName:
|
||
var shouldCreate = true;
|
||
|
||
for i in backs.get_children():
|
||
if i.name == sceneName:
|
||
shouldCreate = false;
|
||
if not shouldCreate:
|
||
return false;
|
||
|
||
Dialogic.set_variable("CurrentBackground", sceneName)
|
||
|
||
var scenePath = "res://scenes/BackgroundScenes/" + sceneName + ".tscn";
|
||
|
||
if not ResourceLoader.exists(scenePath):
|
||
scenePath = "res://scenes/BackgroundScenes/Chernii_ekran.tscn";
|
||
|
||
if not SettingsSingleton.GetAsyncBackgroundLoading():
|
||
SyncBackgroundLoading(sceneName);
|
||
return true;
|
||
|
||
backgroundLoadingScene = scenePath;
|
||
SceneLoader.load_scene(scenePath);
|
||
|
||
if not ignoreFade:
|
||
BackgroundFade(true);
|
||
|
||
return true;
|
||
|
||
func async_scene_loaded(obj):
|
||
if obj.path != backgroundLoadingScene:
|
||
return ;
|
||
if $Darkening.IsPlaying() and $Darkening.state:
|
||
yield ($Darkening, "completed");
|
||
|
||
var backs = $"Background";
|
||
|
||
var scene = obj.instance;
|
||
|
||
|
||
|
||
|
||
if scene == null:
|
||
print("SCENE LOADED SYNC")
|
||
var lol = load(obj.path);
|
||
scene = lol.instance();
|
||
|
||
|
||
for i in backs.get_children():
|
||
backs.remove_child(i);
|
||
i.queue_free();
|
||
|
||
|
||
|
||
|
||
$Timer.set_wait_time(0.05)
|
||
$Timer.set_one_shot(true)
|
||
$Timer.start()
|
||
yield ($Timer, "timeout")
|
||
|
||
TurnOffSfxFromPreviousScene();
|
||
|
||
backs.add_child(scene);
|
||
|
||
|
||
var backgroundsSize = Vector2(3840, 2160);
|
||
var scaleX = 1 / float(backgroundsSize.x / windowSize.x);
|
||
var scaleY = 1 / float(backgroundsSize.y / windowSize.y);
|
||
|
||
var controlsToIgnore = ["Label", "Tween", "TextureButton", "AudioStreamPlayer", "Timer"];
|
||
for i in scene.get_children():
|
||
if i.get_class() in controlsToIgnore:
|
||
continue;
|
||
|
||
if i.name == "Camera":
|
||
var camPosition = int(Dialogic.get_variable("cameraPosition"))
|
||
call_deferred("SetCamera", camPosition);
|
||
else :
|
||
(i as Node2D).scale = Vector2(scaleX, scaleY);
|
||
|
||
BackgroundFade(false);
|
||
|
||
emit_signal("backgroundLoaded");
|
||
|
||
yield ($Darkening, "completed");
|
||
|
||
if DialogicNode == null:
|
||
return ;
|
||
|
||
if $Game.get_child_count() == 0:
|
||
return
|
||
var dialogNode = $Game.get_child(0).get_node("DialogNode")
|
||
|
||
|
||
var sceneName = obj.path;
|
||
if sceneName == "res://scenes/BackgroundScenes/Train_video.tscn":
|
||
dialogNode.get_node("TextBubble").visible = false
|
||
|
||
allowToDisplayMenu = true;
|
||
if (sceneName == "res://scenes/BackgroundScenes/Scene0.tscn"):
|
||
allowToDisplayMenu = false
|
||
|
||
|
||
dialogNode.CheckMap();
|
||
|
||
func SyncBackgroundLoading(sceneName:String, fadeTime = 1.75):
|
||
$Darkening.interpolateTime = float(fadeTime);
|
||
|
||
BackgroundFade(true);
|
||
yield ($Darkening, "completed");
|
||
|
||
var scenePath = "res://scenes/BackgroundScenes/" + sceneName + ".tscn";
|
||
var lol = load(scenePath);
|
||
var scene = lol.instance();
|
||
|
||
Dialogic.set_variable("CurrentBackground", sceneName)
|
||
|
||
var backs = $"Background";
|
||
|
||
for i in backs.get_children():
|
||
backs.remove_child(i);
|
||
i.queue_free();
|
||
|
||
TurnOffSfxFromPreviousScene();
|
||
|
||
backs.add_child(scene);
|
||
|
||
|
||
var backgroundsSize = Vector2(3840, 2160);
|
||
var scaleX = 1 / float(backgroundsSize.x / windowSize.x);
|
||
var scaleY = 1 / float(backgroundsSize.y / windowSize.y);
|
||
|
||
var controlsToIgnore = ["Label", "Tween", "TextureButton", "AudioStreamPlayer", "Timer"];
|
||
for i in scene.get_children():
|
||
if i.get_class() in controlsToIgnore:
|
||
continue;
|
||
|
||
if i.name == "Camera":
|
||
var camPosition = int(Dialogic.get_variable("cameraPosition"))
|
||
call_deferred("SetCamera", camPosition);
|
||
else :
|
||
(i as Node2D).scale = Vector2(scaleX, scaleY);
|
||
|
||
BackgroundFade(false);
|
||
|
||
emit_signal("backgroundLoaded");
|
||
|
||
yield ($Darkening, "completed");
|
||
|
||
if DialogicNode == null:
|
||
return ;
|
||
|
||
var dialogNode = $Game.get_child(0).get_node("DialogNode")
|
||
|
||
if scenePath == "res://scenes/BackgroundScenes/Train_video.tscn":
|
||
dialogNode.get_node("TextBubble").visible = false
|
||
|
||
allowToDisplayMenu = true;
|
||
if (scenePath == "res://scenes/BackgroundScenes/Scene0.tscn"):
|
||
allowToDisplayMenu = false
|
||
|
||
|
||
dialogNode.CheckMap();
|
||
|
||
|
||
func FreeSceneCache(sceneName:String):
|
||
SceneLoader.free_scene_cache(sceneName);
|
||
|
||
func BackgroundFade(value):
|
||
$Darkening.Fade(value);
|
||
|
||
func BackgroundFadeDialogic(value:String):
|
||
var valueB = value == "true";
|
||
$Darkening.Fade(valueB);
|
||
yield ($Darkening, "completed");
|
||
|
||
var backsWithSfx = [
|
||
"Green_Death_1",
|
||
"Black_Death_1",
|
||
"Mayak",
|
||
"Garaj",
|
||
"Pristan",
|
||
"Purple_Death_1",
|
||
"Roman_black",
|
||
"Scene2",
|
||
"Scene4",
|
||
"Scene6",
|
||
"Scene7",
|
||
"Scene9",
|
||
"Scene12",
|
||
"Kamin",
|
||
"Pistol",
|
||
"Stol",
|
||
]
|
||
|
||
func TurnOffSfxFromPreviousScene():
|
||
if not Dialogic.get_variable("CurrentBackground") in backsWithSfx:
|
||
StopSFX();
|
||
|
||
func DisconnectBackground():
|
||
SceneLoader.disconnect("on_scene_loaded", self, "async_scene_loaded");
|
||
|
||
|
||
|
||
var karmaArray = [
|
||
"Pink_Karma",
|
||
"Purple_Karma",
|
||
"Green_Karma",
|
||
"Black_Karma",
|
||
"Blue_F_Karma",
|
||
]
|
||
|
||
|
||
|
||
var fivePlusKarmas = [];
|
||
|
||
|
||
|
||
func CalculateDate():
|
||
var amountOf5Karma = 0;
|
||
|
||
var oneGirl = "";
|
||
var twoGirlsNames = [];
|
||
|
||
var karmaIndex = 0;
|
||
|
||
var girlNames = LanguageLocalization.GetGirlNames();
|
||
|
||
for i in karmaArray:
|
||
var karmaValue = int(Dialogic.get_variable(karmaArray[karmaIndex]))
|
||
karmaIndex += 1;
|
||
if karmaValue >= 5:
|
||
oneGirl = karmaArray[karmaIndex - 1];
|
||
fivePlusKarmas.push_back(karmaArray[karmaIndex - 1]);
|
||
amountOf5Karma += 1;
|
||
var girlName = tr(girlNames[i]);
|
||
twoGirlsNames.push_front(girlName);
|
||
|
||
if amountOf5Karma == 1:
|
||
Dialogic.set_variable("TwoGirls", 1)
|
||
|
||
Dialogic.set_variable("Chosen_Girl", oneGirl.replace("_Karma", ""))
|
||
|
||
if Dialogic.get_variable("Chosen_Girl") == "Blue_F":
|
||
Dialogic.set_variable("Chosen_Girl", "Blue");
|
||
|
||
Dialogic.set_variable("Chosen_Girl_Name", twoGirlsNames[0])
|
||
|
||
if amountOf5Karma >= 2:
|
||
Dialogic.set_variable("TwoGirls", 2)
|
||
var temp = "";
|
||
var count = twoGirlsNames.size();
|
||
for i in count:
|
||
if i == 0:
|
||
temp += twoGirlsNames[i];
|
||
else :
|
||
var andSymb = tr("text_dating_and");
|
||
if i == count - 1:
|
||
temp += andSymb + twoGirlsNames[i];
|
||
else :
|
||
temp += ", " + twoGirlsNames[i];
|
||
|
||
Dialogic.set_variable("TwoGirlNames", temp);
|
||
|
||
func CalculateGirlChoice():
|
||
var isTwoGirls = int(Dialogic.get_variable("TwoGirls"));
|
||
|
||
var choiceValue = Dialogic.get_variable("Chosen_Girl");
|
||
if choiceValue == "Loser":
|
||
var newKarma = float(Dialogic.get_variable("Chosen_Girl")) - 1.0
|
||
Dialogic.set_variable("Chosen_Karma", newKarma);
|
||
|
||
if isTwoGirls == 1:
|
||
for i in fivePlusKarmas:
|
||
newKarma = float(Dialogic.get_variable(i)) - 1.0
|
||
Dialogic.set_variable(i, newKarma);
|
||
|
||
if isTwoGirls == 2:
|
||
for i in fivePlusKarmas:
|
||
newKarma = float(Dialogic.get_variable(i)) - 1.0
|
||
Dialogic.set_variable(i, newKarma);
|
||
|
||
else :
|
||
var girlNames = LanguageLocalization.GetGirlNames();
|
||
|
||
for i in karmaArray:
|
||
if choiceValue in i:
|
||
var girlValue = int(Dialogic.get_variable(i));
|
||
Dialogic.set_variable("Chosen_Karma", girlValue);
|
||
Dialogic.set_variable("Chosen_Girl_Name", tr(girlNames[i]));
|
||
|
||
if isTwoGirls == 1:
|
||
for girlKarma in fivePlusKarmas:
|
||
if choiceValue in girlKarma:
|
||
continue
|
||
var newKarma = float(Dialogic.get_variable(girlKarma)) - 1.0
|
||
Dialogic.set_variable(girlKarma, newKarma);
|
||
|
||
if isTwoGirls == 2:
|
||
for girlKarma in fivePlusKarmas:
|
||
if not choiceValue in girlKarma:
|
||
var newKarma = float(Dialogic.get_variable(girlKarma)) - 1.0
|
||
Dialogic.set_variable(girlKarma, newKarma);
|
||
|
||
func CalculateChosenKarma():
|
||
var choiceValue = Dialogic.get_variable("Chosen_Girl");
|
||
for i in karmaArray:
|
||
if choiceValue in i:
|
||
var girlValue = int(Dialogic.get_variable(i));
|
||
Dialogic.set_variable("Chosen_Karma", girlValue);
|
||
|
||
func KillGirl():
|
||
var chosen = Dialogic.get_variable("Chosen_Girl")
|
||
var killArray
|
||
var killedGirl
|
||
if (chosen != "Green" and chosen != "Black" and chosen != "Purple"):
|
||
killArray = ["Green", "Black", "Purple"]
|
||
elif chosen == "Green":
|
||
killArray = ["Black", "Purple"]
|
||
elif chosen == "Black":
|
||
killArray = ["Green", "Purple"]
|
||
else :
|
||
killArray = ["Green", "Black"]
|
||
|
||
var rng = RandomNumberGenerator.new()
|
||
rng.randomize()
|
||
var randomInt = rng.randi_range(0, killArray.size() - 1)
|
||
killedGirl = killArray[randomInt]
|
||
|
||
if killedGirl == "Green":
|
||
Dialogic.set_variable("Is_Green_Dead", 1)
|
||
Dialogic.set_variable("1_Death_Knife", "Green")
|
||
if killedGirl == "Black":
|
||
Dialogic.set_variable("Is_Black_Dead", 1)
|
||
Dialogic.set_variable("1_Death_Knife", "Black")
|
||
if killedGirl == "Purple":
|
||
Dialogic.set_variable("Is_Purple_Dead", 1)
|
||
Dialogic.set_variable("1_Death_Knife", "Purple")
|
||
|
||
var girlNames = LanguageLocalization.GetGirlNames();
|
||
var resKillGirl = killedGirl + "_Karma"
|
||
Dialogic.set_variable("Dead_Girl", resKillGirl);
|
||
var deadName = tr(girlNames[resKillGirl]);
|
||
Dialogic.set_variable("Dead_Girl_Name", deadName);
|
||
|
||
|
||
func CalculateTimeline_30Boys():
|
||
var RedKarma = int(Dialogic.get_variable("Red_Karma"));
|
||
var BlueKarma = int(Dialogic.get_variable("Blue_M_Karma"));
|
||
var GrayKarma = int(Dialogic.get_variable("Gray_Karma"));
|
||
var WhiteKarma = int(Dialogic.get_variable("White_Karma"));
|
||
if RedKarma >= 3 or BlueKarma >= 3:
|
||
Dialogic.set_variable("Timeline_30_Red_Blue_Boys", 1);
|
||
|
||
if GrayKarma >= 3 or WhiteKarma >= 3:
|
||
Dialogic.set_variable("Timeline_30_Gray_White_Boys", 1);
|
||
|
||
func IsEnoughBoyKarmaTimeline30():
|
||
var RedKarma = int(Dialogic.get_variable("Red_Karma"));
|
||
var BlueKarma = int(Dialogic.get_variable("Blue_M_Karma"));
|
||
var GrayKarma = int(Dialogic.get_variable("Gray_Karma"));
|
||
var WhiteKarma = int(Dialogic.get_variable("White_Karma"));
|
||
if ((RedKarma > 2) or (BlueKarma > 2) or (WhiteKarma > 2) or (GrayKarma > 2)):
|
||
Dialogic.set_variable("Timeline30EnoughBoyKarma", 1)
|
||
|
||
|
||
func CalculateTimeline_44Boys():
|
||
var blueChosen = Dialogic.get_variable("Chosen_Girl");
|
||
|
||
if blueChosen == "Blue":
|
||
Dialogic.set_variable("Timeline_44_Boy_Sofa", 0);
|
||
pass;
|
||
|
||
var RedKarma = int(Dialogic.get_variable("Red_Karma"));
|
||
var BlueKarma = int(Dialogic.get_variable("Blue_M_Karma"));
|
||
var GrayKarma = int(Dialogic.get_variable("Gray_Karma"));
|
||
var WhiteKarma = int(Dialogic.get_variable("White_Karma"));
|
||
|
||
var boysToRandom = [];
|
||
|
||
if RedKarma > 2:
|
||
boysToRandom.push_back("Red_Karma");
|
||
if BlueKarma > 2:
|
||
boysToRandom.push_back("Blue_M_Karma");
|
||
if GrayKarma > 2:
|
||
boysToRandom.push_back("Gray_Karma");
|
||
if WhiteKarma > 2:
|
||
boysToRandom.push_back("White_Karma");
|
||
|
||
if boysToRandom.size() > 0:
|
||
var rnd = RandomNumberGenerator.new()
|
||
rnd.randomize()
|
||
var boysNames = LanguageLocalization.GetBoysNames();
|
||
var randomName = tr(boysNames[boysToRandom[rnd.randi_range(0, boysToRandom.size() - 1)]]);
|
||
Dialogic.set_variable("Timeline_44_Boy_Sofa_Name", randomName);
|
||
Dialogic.set_variable("Timeline_44_Boy_Sofa", 1);
|
||
|
||
func CalculateTimeline_28_Another_Girl():
|
||
var anotherOption = ["Purple_Karma", "Green_Karma", "Black_Karma"];
|
||
|
||
|
||
var valueChosen = Dialogic.get_variable("Chosen_Girl") + "_Karma";
|
||
var valueDead = Dialogic.get_variable("Dead_Girl");
|
||
|
||
anotherOption.remove(anotherOption.find(valueChosen));
|
||
anotherOption.remove(anotherOption.find(valueDead));
|
||
|
||
var girlNames = LanguageLocalization.GetGirlNames();
|
||
|
||
var name = tr(girlNames[anotherOption[0]]);
|
||
|
||
Dialogic.set_variable("Timeline_28_Another_Girl", anotherOption[0]);
|
||
Dialogic.set_variable("Timeline_28_Another_Girl_Name", name);
|
||
|
||
func CalculateTimeline_22_isRedBlue():
|
||
var bluredKarma = Dialogic.get_variable("Blue_M_Karma") + Dialogic.get_variable("Red_Karma");
|
||
var whitegrayKarma = Dialogic.get_variable("White_Karma") + Dialogic.get_variable("Gray_Karma");
|
||
if (bluredKarma >= whitegrayKarma):
|
||
Dialogic.set_variable("Timeline_22_isRedBlue", 1);
|
||
else :
|
||
Dialogic.set_variable("Timeline_22_isRedBlue", 0);
|
||
|
||
var karmaArrayFull = [
|
||
"DLC",
|
||
"Killer",
|
||
"Is_Purple_Dead",
|
||
"Is_Green_Dead",
|
||
"Is_Black_Dead",
|
||
"Is_Red_Dead",
|
||
"Is_White_Dead",
|
||
"Is_Blue_M_Dead",
|
||
"Is_Gray_Dead",
|
||
"Is_Yellow_Dead",
|
||
"Is_Orange_Dead",
|
||
"Is_Pink_Dead",
|
||
"Is_Blue_F_Dead",
|
||
"TimelineSave",
|
||
"DialogIndex",
|
||
"CurrentBackground",
|
||
"CurrentBGM",
|
||
"Drunk",
|
||
"Time",
|
||
"Chosen_Girl",
|
||
"1_Death_Knife",
|
||
"2_Death_Missing",
|
||
"3_Death_Electricity",
|
||
"4_Death_Fire",
|
||
"5_Wounded_Fire",
|
||
"6_Death_Poison",
|
||
"7_Death_Stairs",
|
||
"9_Death_Pistol",
|
||
"numberOfActions",
|
||
"Knife",
|
||
"Footprint",
|
||
"Bottle",
|
||
"Tea",
|
||
"NonProfessional",
|
||
"AbsentPerson1",
|
||
"AbsentPerson2",
|
||
];
|
||
|
||
|
||
|
||
var karmaDebugVisible = false;
|
||
|
||
var isSaveLoadVisible:bool = false;
|
||
|
||
var isMenuVisible:bool = false;
|
||
|
||
func ToggleMenu():
|
||
isMenuVisible = not isMenuVisible;
|
||
$Game.get_child(0).get_child(0).get_node("BackButton").visible = not isMenuVisible
|
||
|
||
var back = $Background;
|
||
if back.get_child_count() > 0:
|
||
for i in back.get_child(0).get_children():
|
||
if i is Light2D:
|
||
i.visible = not isMenuVisible
|
||
|
||
if is_instance_valid(DialogicNode):
|
||
if DialogicNode.get_child_count() > 0:
|
||
DialogicNode.get_child(0).ToggleMenu(isMenuVisible);
|
||
|
||
func ToggleKarmaMenu():
|
||
isMenuVisible = not isMenuVisible;
|
||
|
||
var back = $Background;
|
||
if back.get_child_count() > 0:
|
||
for i in back.get_child(0).get_children():
|
||
if i is Light2D:
|
||
i.visible = not isMenuVisible
|
||
|
||
if is_instance_valid(DialogicNode):
|
||
if DialogicNode.get_child_count() > 0:
|
||
DialogicNode.get_child(0).ToggleKarmaMenu(isMenuVisible);
|
||
|
||
func _input(ev):
|
||
if ev is InputEventKey and ev.scancode == KEY_ESCAPE and ev.pressed == false and allowToDisplayMenu:
|
||
var DiaNode = $Game.get_child(0).get_child(0);
|
||
if DiaNode.get_node("Map").visible == true:
|
||
DiaNode._on_MapButton_button_down();
|
||
return ;
|
||
if DiaNode.get_node("Karma").visible == true:
|
||
ToggleKarmaMenu()
|
||
return ;
|
||
|
||
|
||
if DiaNode.get_node("LoadSaveMenu").visible == false:
|
||
ToggleMenu();
|
||
if DiaNode.get_node("LoadSaveMenu").visible == true:
|
||
Dialogic.load("AutosaveCasual")
|
||
DiaNode.BackFromSaveLoad()
|
||
|
||
|
||
|
||
|
||
|
||
|
||
func DrawKarma():
|
||
for i in $Karma / Karmas.get_children():
|
||
if i is Label:
|
||
$Karma / Karmas.remove_child(i);
|
||
|
||
if not karmaDebugVisible:
|
||
$Karma / Sprite.visible = false;
|
||
DialogicNode.get_child(0).get_node("Portraits").visible = true;
|
||
return ;
|
||
|
||
var dynamic_font = DynamicFont.new()
|
||
dynamic_font.font_data = load("res://resources/fonts/TimesNewerRoman-Regular.otf")
|
||
dynamic_font.size = 25
|
||
dynamic_font.outline_color = Color(255, 255, 255, 1)
|
||
dynamic_font.use_filter = true
|
||
|
||
$Karma / Sprite.visible = true;
|
||
DialogicNode.get_child(0).get_node("Portraits").visible = false;
|
||
|
||
var karmaIndex = 0;
|
||
var row = 0;
|
||
var colummn = 0;
|
||
for i in karmaArrayFull:
|
||
var label = Label.new();
|
||
var value = Dialogic.get_variable(i);
|
||
label.add_font_override("font", dynamic_font);
|
||
label.text = str(i, ": ", value);
|
||
label.rect_scale = Vector2(1, 1);
|
||
label.rect_position = Vector2(10 + colummn * 300, 10 + row * 25);
|
||
$Karma / Karmas.add_child(label);
|
||
karmaIndex += 1;
|
||
|
||
if karmaIndex % 30 == 0:
|
||
colummn += 1;
|
||
row = 0;
|
||
else :
|
||
row += 1;
|
||
|
||
|
||
func BackToMenu():
|
||
|
||
SetBGM("99")
|
||
StopSFX();
|
||
get_node("/root/BgmScene").StartMenuMusic()
|
||
|
||
if not SceneLoader.is_connected("on_scene_loaded", self, "MenuLoaded"):
|
||
var _temp = SceneLoader.connect("on_scene_loaded", self, "MenuLoaded");
|
||
SceneLoader.load_scene("res://scenes/MainMenu.tscn")
|
||
|
||
func MenuLoaded(obj):
|
||
if obj.path != "res://scenes/MainMenu.tscn":
|
||
return ;
|
||
|
||
if obj.instance != null:
|
||
get_tree().root.add_child(obj.instance);
|
||
|
||
for i in get_tree().root.get_children():
|
||
if i.name == "Root":
|
||
get_tree().root.remove_child(i);
|
||
break;
|
||
|
||
SceneLoader.disconnect("on_scene_loaded", self, "MenuLoaded");
|
||
|
||
|
||
func AlternativeChoices(param):
|
||
var dialogNode = $Game.get_child(0).get_node("DialogNode")
|
||
dialogNode.get_node("TextBubble").update_text(" ", false);
|
||
dialogNode.get_node("TextBubble").visible = false
|
||
dialogNode.alternativeChoicesOn = true
|
||
dialogNode.ToggleSpriteChoice(true);
|
||
|
||
var sceneName = "res://scenes/AlternativeChoices/AlternativeChoice" + param + ".tscn"
|
||
|
||
var scene = load(sceneName).instance();
|
||
scene.connect("endOfChoice", self, "removeAlternative");
|
||
$AlternativeChoices.add_child(scene);
|
||
|
||
func removeAlternative():
|
||
var dialogNode = $Game.get_child(0).get_node("DialogNode")
|
||
dialogNode.alternativeChoicesOn = false
|
||
var altScene = $AlternativeChoices.get_child(0);
|
||
$AlternativeChoices.remove_child(altScene)
|
||
emit_signal("alt_choice_completed")
|
||
|
||
|
||
|
||
|
||
|
||
func removeAlternative2():
|
||
var dialogNode = $Game.get_child(0).get_node("DialogNode")
|
||
dialogNode.alternativeChoicesOn = false
|
||
var altScene = $AlternativeChoices.get_child(0);
|
||
if (altScene):
|
||
$AlternativeChoices.remove_child(altScene)
|
||
dialogNode.ToggleSpriteChoice(false);
|
||
|
||
func Investigation(param):
|
||
var dialogNode = $Game.get_child(0).get_node("DialogNode")
|
||
dialogNode.get_node("TextBubble").update_text(" ", false);
|
||
dialogNode.get_node("TextBubble").visible = false
|
||
dialogNode.investigationOn = true
|
||
dialogNode.ToggleSpriteChoice(true);
|
||
|
||
var sceneName = "res://scenes/Investigations/" + param + ".tscn"
|
||
var scene = load(sceneName).instance();
|
||
scene.connect("endOfInvestigation", self, "removeInvestigation");
|
||
$AlternativeChoices.add_child(scene);
|
||
|
||
func removeInvestigation():
|
||
var altScene = $AlternativeChoices.get_child(0);
|
||
if (altScene):
|
||
$AlternativeChoices.remove_child(altScene)
|
||
var dialogNode = $Game.get_child(0).get_node("DialogNode")
|
||
dialogNode.ToggleSpriteChoice(false);
|
||
dialogNode.investigationOn = false
|
||
emit_signal("alt_choice_completed")
|
||
|
||
func ClearInvestigationCluesArray():
|
||
InvestigationSingleton.ClearCluesArray();
|
||
|
||
func CheckMap():
|
||
var mapNode = $Game.get_child(0).get_node("DialogNode/Map")
|
||
var highlightMapIcon = mapNode.ProcessMap();
|
||
|
||
if highlightMapIcon:
|
||
var mapButton = $Game.get_child(0).get_node("DialogNode/BackButton/MapButton")
|
||
mapButton.StartBlinking();
|
||
|
||
func ResetTimeline():
|
||
var timeLine = Dialogic.get_variable("TimelineSave");
|
||
var background = Dialogic.get_variable("CurrentBackground");
|
||
var _temp = setBackground(str(background));
|
||
Dialogic.change_timeline(timeLine);
|
||
|
||
|
||
func SetCamera(positionIndex):
|
||
var index = int(positionIndex)
|
||
var backgroundsSize = Vector2(3840, 2160);
|
||
var scaleX = 1 / float(backgroundsSize.x / windowSize.x);
|
||
var scaleY = 1 / float(backgroundsSize.y / windowSize.y);
|
||
$"Background".get_child(0).get_node("Camera").SetPosition(index, scaleX, scaleY);
|
||
|
||
|
||
func ZoomCamera(positionIndex, zoomTime = 1.5):
|
||
var index = int(positionIndex)
|
||
var backgroundsSize = Vector2(3840, 2160);
|
||
var scaleX = 1 / float(backgroundsSize.x / windowSize.x);
|
||
var scaleY = 1 / float(backgroundsSize.y / windowSize.y);
|
||
|
||
|
||
if $Background.get_child_count() == 0:
|
||
yield (self, "backgroundLoaded");
|
||
|
||
$"Background".get_child(0).get_node("Camera").ZoomToPosition(index, scaleX, scaleY, float(zoomTime));
|
||
var dialogNode = $Game.get_child(0).get_node("DialogNode")
|
||
dialogNode.get_node("TextBubble").update_text(" ", false)
|
||
|
||
|
||
func SetBGM(bgmIndex):
|
||
get_node("/root/BgmScene").SetBGM(bgmIndex);
|
||
|
||
|
||
func SetSFXforBGM(sfxPath):
|
||
get_node("/root/BgmScene").SetSFXforBGM(sfxPath);
|
||
|
||
func SetSFXforBGMNoFade(sfxPath):
|
||
get_node("/root/BgmScene").SetSFXforBGMNoFade(sfxPath);
|
||
|
||
func StopSFX():
|
||
get_node("/root/BgmScene").StopSFX();
|
||
|
||
func SetTriptychBGM(bgmName):
|
||
get_node("/root/BgmScene").SetTriptych(bgmName);
|
||
|
||
func Who175_1_Timeline31():
|
||
var isGreenDead = Dialogic.get_variable("Is_Green_Dead")
|
||
var choice = Dialogic.get_variable("PreviousTimelineChoice")
|
||
var chosenGirl = Dialogic.get_variable("Chosen_Girl")
|
||
var who175 = "somebody"
|
||
if (isGreenDead == "0" and chosenGirl != "Green"):
|
||
who175 = "Agatha"
|
||
if (isGreenDead == "1" or chosenGirl == "Green"):
|
||
who175 = "Renata"
|
||
if (isGreenDead == "1" and choice == "37"):
|
||
who175 = "Amanda"
|
||
|
||
Dialogic.set_variable("Who_175.1", who175)
|
||
|
||
func setAchievement(achName):
|
||
|
||
var da = 1;
|
||
# Steam.set_achievement(achName)
|
||
|
||
func SetDeathAchievement(achName):
|
||
ProgressAchievementsSingleton.AddDeathAchievement(achName);
|
||
|
||
func SetSexAchievement(achName):
|
||
ProgressAchievementsSingleton.AddSexAchievement(achName);
|
||
|
||
func SetWinAchievement():
|
||
if Dialogic.get_variable("EasyMode") == "0":
|
||
var easy_mode = 0;
|
||
# Steam.set_achievement("Win_game");
|
||
|
||
func SetYellowDeathAchievement(achName):
|
||
ProgressAchievementsSingleton.AddYellowDeathAchievement(achName);
|
||
|
||
func SetNumberDeathAchievement(death):
|
||
if death == "3_Death_Electricity":
|
||
var value:String = Dialogic.get_variable("3_Death_Electricity");
|
||
ProgressAchievementsSingleton.AddNumberDeathAchievement(death, value);
|
||
elif death == "4_Death_Fire":
|
||
var value:String = Dialogic.get_variable("3_Death_Electricity");
|
||
ProgressAchievementsSingleton.AddNumberDeathAchievement(death, value);
|
||
|
||
func ChosenGirlToDat():
|
||
var herName = Dialogic.get_variable("Chosen_Girl_Name");
|
||
if herName.ends_with("я"):
|
||
herName = herName.trim_suffix("я")
|
||
herName += "и"
|
||
else :
|
||
herName = herName.trim_suffix("а")
|
||
herName += "е"
|
||
Dialogic.set_variable("Chosen_Girl_Name_Dat", herName);
|
||
|
||
func DeadGirlToTvorit():
|
||
var herName = Dialogic.get_variable("Dead_Girl_Name");
|
||
if herName.ends_with("я"):
|
||
herName = herName.trim_suffix("я")
|
||
herName += "ей"
|
||
else :
|
||
herName = herName.trim_suffix("а")
|
||
herName += "ой"
|
||
Dialogic.set_variable("Dead_Girl_Name_Tvorit", herName);
|
||
|
||
func EndDemo():
|
||
|
||
var ingameMenu = $Game.get_child(0).get_node("DialogNode/BackButton");
|
||
ingameMenu.visible = false;
|
||
ingameMenu.rect_global_position = Vector2(0, 1000);
|
||
|
||
var endLabel;
|
||
if TranslationServer.get_locale() == "en":
|
||
endLabel = $"Background".get_child(0).get_node("End").get_node("eng")
|
||
else :
|
||
endLabel = $"Background".get_child(0).get_node("End").get_node("ru")
|
||
endLabel.modulate = Color(1, 1, 1, 0)
|
||
endLabel.visible = true;
|
||
var tween = $"Background".get_child(0).get_node("End").get_node("Tween")
|
||
tween.interpolate_property(endLabel, "modulate", Color(1, 1, 1, 0), Color(1, 1, 1, 1), 4, Tween.TRANS_LINEAR, 0)
|
||
tween.start()
|
||
|
||
func UnendDemo():
|
||
var endLabel;
|
||
if $"Background".get_child(0).get_node("End") != null:
|
||
if TranslationServer.get_locale() == "en":
|
||
endLabel = $"Background".get_child(0).get_node("End").get_node("eng")
|
||
else :
|
||
endLabel = $"Background".get_child(0).get_node("End").get_node("ru")
|
||
endLabel.visible = false;
|
||
|
||
func VisibleHistory():
|
||
if $Game.get_child_count() == 0:
|
||
return
|
||
if Dialogic.get_variable("CurrentBackground") != "Scene0":
|
||
$Game.get_child(0).get_node("DialogNode").get_node("BackButton").visible = true;
|
||
|
||
|
||
|
||
|
||
func InvisibleHistory():
|
||
$Game.get_child(0).get_node("DialogNode").get_node("BackButton").visible = false
|
||
|
||
func MouseVisible():
|
||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||
|
||
func Alert():
|
||
OS.alert("blablabla " + Dialogic.get_variable("CurrentLabel"))
|
||
|
||
|
||
func Alert1():
|
||
OS.alert("thisIsStart " + Dialogic.get_variable("CurrentLabel"))
|
||
OS.alert("needChar=" + Dialogic.get_variable("NeedCharacter"))
|
||
|
||
func LoadAtIndex():
|
||
var index = int(Dialogic.get_variable("DialogIndex"))
|
||
if index == NAN:
|
||
index = 0
|
||
$Game.get_child(0).get_node("DialogNode")._load_event_at_index(index + 1)
|
||
|
||
func SeenCharacter(string):
|
||
ProgressAchievementsSingleton.AddSeenCharacter(string)
|
||
|
||
func ProfileText(string):
|
||
ProgressAchievementsSingleton.AddProfileText(string)
|
||
|
||
func LoadFromGame(slotName:String):
|
||
isSaveLoadVisible = false;
|
||
Dialogic.load(slotName)
|
||
|
||
|
||
get_tree().root.get_node("Loading").visible = true;
|
||
var dialogicNode = $Game.get_child(0);
|
||
$Game.call_deferred("remove_child", dialogicNode);
|
||
dialogicNode.queue_free();
|
||
|
||
|
||
|
||
for i in $AlternativeChoices.get_children():
|
||
$AlternativeChoices.remove_child(i);
|
||
for i in $GameEnd.get_children():
|
||
$GameEnd.remove_child(i);
|
||
|
||
|
||
RunDialogic();
|
||
|
||
func Win():
|
||
var scene = load("res://scenes/GameEnd/WinScene.tscn").instance();
|
||
if $GameEnd.get_child_count() == 0:
|
||
$GameEnd.add_child(scene)
|
||
else :
|
||
$GameEnd.get_child(0).queue_free()
|
||
$GameEnd.add_child(scene)
|
||
|
||
func Loose():
|
||
var scene = load("res://scenes/GameEnd/LooseScene.tscn").instance();
|
||
$GameEnd.add_child(scene);
|
||
|
||
func setBackground2(sceneName, ignoreFade = false, fadeTime = 2.5)->bool:
|
||
var backs = $"Background";
|
||
|
||
Dialogic.set_variable("CurrentBackground", sceneName)
|
||
|
||
var scenePath = "res://scenes/BackgroundScenes/" + sceneName + ".tscn";
|
||
|
||
if not ResourceLoader.exists(scenePath):
|
||
scenePath = "res://scenes/BackgroundScenes/Chernii_ekran.tscn";
|
||
|
||
backgroundLoadingScene = scenePath;
|
||
SceneLoader.load_scene(scenePath);
|
||
|
||
if not ignoreFade:
|
||
BackgroundFade(true);
|
||
|
||
return true;
|
||
|
||
func Shake():
|
||
|
||
var max_offset = Vector2(175, 50)
|
||
var max_roll = 0.1
|
||
|
||
var trauma_power = 2
|
||
var amount = pow(trauma, trauma_power)
|
||
noise_y += 1
|
||
$Camera2D.current = true
|
||
$Camera2D.rotation = max_roll * amount * noise.get_noise_2d(noise.seed, noise_y)
|
||
$Camera2D.position.x = 960.0 + max_offset.x * amount * noise.get_noise_2d(noise.seed * 2, noise_y)
|
||
$Camera2D.position.y = 540.0 + max_offset.y * amount * noise.get_noise_2d(noise.seed * 3, noise_y)
|
||
|
||
func StartShake():
|
||
randomize()
|
||
noise.seed = randi()
|
||
noise.period = 2
|
||
noise.octaves = 1
|
||
$ShakeTimer.start(1.1)
|
||
isShaking = true
|
||
trauma = 1.0
|
||
|
||
func StopShake():
|
||
$Camera2D.position = Vector2(960.0, 540.0)
|
||
$Camera2D.rotation = 0.0
|
||
|
||
func _process(delta):
|
||
if isShaking:
|
||
trauma = max(trauma - 0.25 * delta, 0)
|
||
Shake()
|
||
|
||
func _on_ShakeTimer_timeout():
|
||
StopShake()
|
||
isShaking = false
|
||
|
||
func DemonstrateKarma():
|
||
if $Game.get_child(0).has_node("DialogNode"):
|
||
var dialogNode = $Game.get_child(0).get_node("DialogNode");
|
||
dialogNode.DemonstrateKarma();
|
||
|
||
func setBackgroundDLC(sceneName, ignoreFade = false, fadeTime:float = 1.75)->bool:
|
||
$Darkening.interpolateTime = float(fadeTime);
|
||
var backs = $"Background";
|
||
|
||
if Dialogic.get_variable("CurrentBackground") == sceneName:
|
||
var shouldCreate = true;
|
||
|
||
for i in backs.get_children():
|
||
if i.name == sceneName:
|
||
shouldCreate = false;
|
||
if not shouldCreate:
|
||
return false;
|
||
|
||
Dialogic.set_variable("CurrentBackground", sceneName)
|
||
|
||
var scenePath = "res://dlc/scenes/" + sceneName + ".tscn";
|
||
|
||
if not ResourceLoader.exists(scenePath):
|
||
scenePath = "res://scenes/BackgroundScenes/Chernii_ekran.tscn";
|
||
|
||
if not SettingsSingleton.GetAsyncBackgroundLoading():
|
||
SyncBackgroundLoading(scenePath);
|
||
return true;
|
||
|
||
backgroundLoadingScene = scenePath;
|
||
SceneLoader.load_scene(scenePath);
|
||
|
||
if not ignoreFade:
|
||
BackgroundFade(true);
|
||
|
||
return true;
|