From f45ebbceb6a4b9fb2bd4cde975534385658c489f Mon Sep 17 00:00:00 2001 From: Evgenij Titarenko Date: Sun, 25 Aug 2024 12:27:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=D0=B0=20=D0=BC=D0=B5?= =?UTF-8?q?=D0=B6=D0=B4=D1=83=20=D1=81=D1=86=D0=B5=D0=BD=D0=B0=D0=BC=D0=B8?= =?UTF-8?q?.=20=D0=98=20=D0=B3=D0=BB=D0=B0=D0=B2=D0=BD=D0=BE=D0=B5=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8E.=20=D0=A2=D0=B8=D0=BF=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prefabs/SceneManager.tscn | 14 ++++++++ project.godot | 6 +++- resources/sprites/ui/menu.png | Bin 0 -> 4593 bytes resources/sprites/ui/menu.png.import | 34 ++++++++++++++++++ scenes/Startup.tscn | 47 +++++++++++++++++++++++++ scripts/SceneManager.cs | 22 ++++++++++++ scripts/Startup.cs | 50 +++++++++++++++++++++++++++ 7 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 prefabs/SceneManager.tscn create mode 100644 resources/sprites/ui/menu.png create mode 100644 resources/sprites/ui/menu.png.import create mode 100644 scenes/Startup.tscn create mode 100644 scripts/SceneManager.cs create mode 100644 scripts/Startup.cs diff --git a/prefabs/SceneManager.tscn b/prefabs/SceneManager.tscn new file mode 100644 index 0000000..56b3c47 --- /dev/null +++ b/prefabs/SceneManager.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=2 format=3 uid="uid://cs8w774ovpf5w"] + +[ext_resource type="Script" path="res://scripts/SceneManager.cs" id="1_3bhed"] + +[node name="SceneManager" type="Node"] +script = ExtResource("1_3bhed") +Scenes = { +"Day1": "res://scenes/Day1.tscn", +"Day2": "res://scenes/Day2.tscn", +"Day3": "res://scenes/Day3.tscn", +"Day4": "res://scenes/Day4.tscn", +"Day5": "res://scenes/Day5.tscn", +"Menu": "res://scenes/Startup.tscn" +} diff --git a/project.godot b/project.godot index 58c0ac5..be5174a 100644 --- a/project.godot +++ b/project.godot @@ -11,10 +11,14 @@ config_version=5 [application] config/name="chill-jam-10" -run/main_scene="res://scenes/Day1.tscn" +run/main_scene="res://scenes/Startup.tscn" config/features=PackedStringArray("4.3", "C#", "GL Compatibility") config/icon="res://icon.svg" +[autoload] + +SceneManager="*res://prefabs/SceneManager.tscn" + [display] window/size/viewport_width=640 diff --git a/resources/sprites/ui/menu.png b/resources/sprites/ui/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..d947de00b88d271db5451ac0a5e2855d2615e3bc GIT binary patch literal 4593 zcmb7Idpy(o|KCW|>7;w#Bc@J?i0Ohe%$zzBVwg)VZQYei%5vI;*(s%~xr9O%8jX~nd2p6~1H^?JTvuh#>2H^*Ps>#PTX zK)*Vj{L2#r0^0-6KeW~Y*Bhp+5a0&JdO98h6}Re+gFu@To&NgM3zsQ=!HU=AY`+__ zGwg+!Iug8wQ z-S|qUbAVn@yi6|+h-7PD(anPQcUUw%pQx!K63nvBu(yaL|C_8>WG^l(B~)B% zMFU1H|EexL8J}}GW&I{lb5iX_cc1kkSXXrwgiCIBF3FDNEVRd--pK5tL^aVa@6zm|9)}HuW zCG{eM&h8+P@8IdVBBSaPz~Y_`t(+=Ps**NNf?(~rS9X2t#1_8z3H+)-n(a9}Q>SSZ zDb;l-3V!nC>H1CS0!*e)L@k6`yK$3)+%pVL?}4Ey`M?zSFEqZsR9w7@t~FFi%1aE> z+QmXbY2@gXRTaDdW#KjIMRsqdP@~1maw@ftx-63(oI}K{G$Gxf#n)@D>xnXnz)LH{ zrqb;i`_TK+4+(;R48hX86x8PQt4RTGpD<=w5QM22v?Ja0`KK{#gmiu~7C$bus-)_q zXw+el8d}M3it3dY|C3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thF$_Q#=B3`pUS( z6;B|8Qck*V%pEPAKnfz??~#H$Dw2W=y+TGIephM59sSnSo)}|_4D`ZghIy6Sko6tV z=j-tY-z7VgP|ET!VPB8>&FNZE9$cHU2}|5jy3$7%OK?h?5?a1hFXoS1G12c}rUNc1 z%*!)rY&%lcJgSK&!`Uv&V?qckTnP}9@jBrw1HhUR3)dJQx3!xwC==!N+n64aq}El; zx_HN5sHVe(bbo&~I}OLo%;J<6^5x6c)o>o_ z2w>vLjz{qlY3GtC7iWH$S;GDLBjsH=7M4qSiE^y)5u86ae&d0U+p$V70#=m(w;wD_ z=ph6S`HdRD9mw#;`GqKhuIjj|YRzZqZN$#L#5a|#@T4Sui-e*2I6pMHjH`_V{JK@f zi<)+t|8R7{OW$k?b43SQ$4Yyg)u3NdeBXVWL%=xD^RLFleYqlB6a`>j?;_HknY}YD znAKAkP+s;3fh3H?+5&+v?BJ{U%@E*7etwU-29K2+6D_-#)zt4_pROiZjbn(T_y|A+|zmVrPUNtd5nh_Lm3mO*J!R5VE{@{m3aZfZ^>11LHYz z;lGXC8g>I4Cn~^n3a8&QiR@QC#V=Nu<(>k!Z$TH_Q!cuf7>*s86$9BDQhSqwM>#Mu zaMclmouMg#x8ifIJkRnb>k#}cu-hD#eAuChh%xY@L8YVzh^8BCL*DF3EoPfnaN?K6h9HU^LaqzHY!L^nLi7*Bzqh$h!2~+WpVmuP$ zi2^?Hrz|*a`%8UWygtzA+rN#VW|=iWGXLoh-D`a#L)Wo~0ag1*0V_Kr1Nkw|xW#Nt zDEus0Qj|kp241ZImclcE+k?!1S!Jab Scenes; + + public string CurrentScene; + + public void SwitchScene(string sceneName) + { + GetTree().ChangeSceneToFile(Scenes[sceneName]); + } + + public override void _Ready() + { + var scenePath = (string)ProjectSettings.GetSetting("application/run/main_scene"); + CurrentScene = Scenes.First(pair => pair.Value == scenePath).Key; + } +} diff --git a/scripts/Startup.cs b/scripts/Startup.cs new file mode 100644 index 0000000..d64d0fd --- /dev/null +++ b/scripts/Startup.cs @@ -0,0 +1,50 @@ +using Godot; +using System; + +public partial class Startup : Node2D +{ + private enum State + { + Default, + Transition + } + + private State _state = State.Default; + + private ColorRect _colorRect; + + private AudioStreamPlayer _music; + + private double _transitionTimeout = 0; + + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + _colorRect = (ColorRect)FindChild("ColorRect"); + _music = (AudioStreamPlayer)FindChild("AudioStreamPlayer"); + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _PhysicsProcess(double delta) + { + if (_state == State.Transition) + { + _transitionTimeout += delta; + // _colorRect.Color = _colorRect.Color.Lerp(new Color(0, 0, 0, 255), (float)_transitionTimeout/2); + _colorRect.Color = new Color(0, 0, 0, Mathf.Lerp(0, 1, (float)_transitionTimeout/2)); + _music.VolumeDb = Mathf.Lerp(0, -41, (float)_transitionTimeout/2); + if (_music.VolumeDb < -40) + { + GetNode("/root/SceneManager").SwitchScene("Day1"); + } + } + } + + public override void _Input(InputEvent @event) + { + if (@event.IsActionPressed("Interact")) + { + _state = State.Transition; + } + } +}