465 lines
10 KiB
C#
465 lines
10 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Events/IntroScene.cs")]
|
|
public partial class IntroScene : Node2D
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
private RichTextLabel text;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private RichTextLabel call;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private RichTextLabel hud;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Sprite2D[] options;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Sprite2D[] gun;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Sprite2D[] trees;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Sprite2D soul;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private AnimatedSprite2D outlaw;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Control box;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D optionBar;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D treeHolder;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Texture2D[] buttons;
|
|
|
|
private string baseText;
|
|
|
|
private int option;
|
|
|
|
private int menu;
|
|
|
|
private int state;
|
|
|
|
private int steps;
|
|
|
|
private bool textDelay;
|
|
|
|
private bool rand;
|
|
|
|
private float kCall;
|
|
|
|
private Coroutine busy;
|
|
|
|
private string[] texts;
|
|
|
|
private static readonly AudioStream step = GD.Load<AudioStream>("res://Audio/Sounds/snd_step1.wav");
|
|
|
|
private AudioStreamPlayer bleeps;
|
|
|
|
private static readonly Vector2[] soulMainOpt = new Vector2[2]
|
|
{
|
|
new Vector2(-142f, 100f),
|
|
new Vector2(-63f, 100f)
|
|
};
|
|
|
|
private static readonly Vector2[] soulActSelec = new Vector2[2]
|
|
{
|
|
new Vector2(-137f, 17f),
|
|
new Vector2(-137f, 37f)
|
|
};
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
box.Modulate = Main.colorClear;
|
|
treeHolder.Modulate = Main.colorClear;
|
|
base.ZIndex = 1001;
|
|
Coroutine.Start(Cutscene());
|
|
AudioStreamPlayer obj = new AudioStreamPlayer
|
|
{
|
|
Stream = TextSystem.defaultBleep2
|
|
};
|
|
AudioStreamPlayer node = obj;
|
|
bleeps = obj;
|
|
AddChild(node, forceReadableName: false, InternalMode.Disabled);
|
|
texts = FileAccess.Open(Texts.textFolder + "Rooms/Intro.txt", FileAccess.ModeFlags.Read).GetAsText(skipCr: true).Split('\n');
|
|
for (int i = 0; i < texts.Length; i++)
|
|
{
|
|
texts[i] = texts[i].Replace("\\n", "\n").Replace("\\t", "\t");
|
|
}
|
|
call.Text = "[shake level=6 rate=7]" + texts[9];
|
|
hud.Text = Texts.common[28].ToUpper() + "\t" + Texts.common[91] + "\t1\t\t\tHP [img=7 color=#ffff00]res://Sprites/Menus/Menu Sprites/HPBar3.tres[/img][img=7 color=#ffff00]res://Sprites/Menus/Menu Sprites/HPBar3.tres[/img] 20 / 20";
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
for (int i = 0; i < trees.Length; i++)
|
|
{
|
|
trees[i].RotationDegrees = 2f * Mathf.Sin(Mathf.DegToRad((float)Time.GetTicksMsec() * 0.05f + (float)(i * 100)));
|
|
}
|
|
if (text.Visible && text.VisibleRatio < 1f)
|
|
{
|
|
if (!bleeps.Playing)
|
|
{
|
|
bleeps.Play();
|
|
}
|
|
if (textDelay)
|
|
{
|
|
textDelay = false;
|
|
}
|
|
else
|
|
{
|
|
text.VisibleCharacters++;
|
|
textDelay = true;
|
|
}
|
|
}
|
|
else if (bleeps.Playing)
|
|
{
|
|
bleeps.Stop();
|
|
}
|
|
if (state > 1)
|
|
{
|
|
kCall += Main.deltaTime;
|
|
float num = Mathf.Abs(Mathf.Sin(Mathf.DegToRad(kCall) / 2f));
|
|
float num2 = Mathf.Clamp(num, 0f, 0.1f);
|
|
call.Modulate = Main.colorClear.Lerp(Main.colorWhite, num2);
|
|
if (num2 < 0.1f && !rand)
|
|
{
|
|
call.Position = new Vector2(Main.RandomRange(-120, 0), Main.RandomRange(-130, -40));
|
|
rand = true;
|
|
}
|
|
else if (num > 0.9f)
|
|
{
|
|
rand = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private IEnumerator TreeAnim(int amt = 1, float time = 60f, bool updateButtons = false)
|
|
{
|
|
for (int b = 0; b < amt; b++)
|
|
{
|
|
Audio.PlaySound(step, 1.5f);
|
|
for (float a = 0f; a < time; a += Main.deltaTime)
|
|
{
|
|
float weight = Mathf.SmoothStep(0f, 1f, a / time);
|
|
for (int i = 0; i < trees.Length / 2; i++)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
trees[i].Position = new Vector2(-124f, 1f).Lerp(new Vector2(-221f, 32f), weight);
|
|
trees[i].Scale = Vector2.One * Mathf.Lerp(2.153f, 3f, weight);
|
|
break;
|
|
case 1:
|
|
trees[i].Position = new Vector2(-81f, -33f).Lerp(new Vector2(-124f, 1f), weight);
|
|
trees[i].Scale = Vector2.One * Mathf.Lerp(1.583f, 2.153f, weight);
|
|
break;
|
|
case 2:
|
|
trees[i].Position = new Vector2(-58f, -60f).Lerp(new Vector2(-81f, -33f), weight);
|
|
trees[i].Scale = Vector2.One * Mathf.Lerp(1.08f, 1.583f, weight);
|
|
break;
|
|
case 3:
|
|
trees[i].Position = new Vector2(-78f, -70f).Lerp(new Vector2(-58f, -60f), weight);
|
|
break;
|
|
}
|
|
trees[i + trees.Length / 2].Position = new Vector2(0f - trees[i].Position.X, trees[i].Position.Y);
|
|
trees[i + trees.Length / 2].Scale = trees[i].Scale;
|
|
}
|
|
yield return null;
|
|
}
|
|
for (float a = 0f; a < 10f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
if (updateButtons)
|
|
{
|
|
UpdateButtons(updateText: true);
|
|
}
|
|
}
|
|
|
|
private IEnumerator Cutscene()
|
|
{
|
|
Audio.ChangeMusic(GD.Load<AudioStream>("res://Audio/Music/AUDIO_DRONE.ogg"));
|
|
for (float a = 0f; a < 280f; a += Main.deltaTime)
|
|
{
|
|
box.Modulate = Main.colorClear.Lerp(Main.colorWhite, a / 120f);
|
|
yield return null;
|
|
}
|
|
for (float a = 0f; a <= 80f; a += Main.deltaTime)
|
|
{
|
|
optionBar.Modulate = Main.colorClear.Lerp(Main.colorWhite, a / 80f);
|
|
treeHolder.Modulate = optionBar.Modulate;
|
|
yield return null;
|
|
}
|
|
for (float a = 0f; a < 40f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
busy = Coroutine.Start(TreeAnim(3));
|
|
while (!busy.done)
|
|
{
|
|
yield return null;
|
|
}
|
|
for (float a = 0f; a < 40f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
text.VisibleRatio = 0f;
|
|
text.Visible = true;
|
|
while (text.VisibleRatio < 1f)
|
|
{
|
|
yield return null;
|
|
}
|
|
while (!Input.IsActionJustPressed(Main.keys[4]))
|
|
{
|
|
yield return null;
|
|
}
|
|
baseText = texts[0];
|
|
yield return null;
|
|
UpdateButtons(updateText: true);
|
|
while (steps < 2)
|
|
{
|
|
MenuInput();
|
|
while (true)
|
|
{
|
|
Coroutine coroutine = busy;
|
|
if (coroutine == null || coroutine.done)
|
|
{
|
|
break;
|
|
}
|
|
yield return null;
|
|
}
|
|
yield return null;
|
|
}
|
|
state = 1;
|
|
Deselect();
|
|
yield return null;
|
|
outlaw.Modulate = new Color(1f, 1f, 1f, 0.1f);
|
|
while (!Input.IsActionJustPressed(Main.keys[4]))
|
|
{
|
|
yield return null;
|
|
}
|
|
text.Text = "";
|
|
for (float a = 0f; a < 80f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
outlaw.Play("Stand");
|
|
option = 0;
|
|
menu = 0;
|
|
baseText = texts[1];
|
|
UpdateButtons(updateText: true);
|
|
state = 2;
|
|
while (state < 3)
|
|
{
|
|
MenuInput();
|
|
while (true)
|
|
{
|
|
Coroutine coroutine2 = busy;
|
|
if (coroutine2 == null || coroutine2.done)
|
|
{
|
|
break;
|
|
}
|
|
yield return null;
|
|
}
|
|
yield return null;
|
|
}
|
|
Deselect();
|
|
text.Visible = false;
|
|
gun[0].Visible = true;
|
|
for (float a = 0f; a < 300f; a += Main.deltaTime)
|
|
{
|
|
gun[1].Scale = new Vector2(2f, 2f).Lerp(Vector2.Zero, a / 300f);
|
|
if (Input.IsActionJustPressed(Main.keys[4]))
|
|
{
|
|
Audio.PlaySound("snd_hit.wav");
|
|
break;
|
|
}
|
|
yield return null;
|
|
}
|
|
Audio.ChangeMusic((Audio.AudioBlock)null, 5f);
|
|
AudioStreamPlayer sfx = Audio.PlaySound("mus_cymbal.ogg");
|
|
CameraController.Transition(Main.colorWhite, 300f, null, Main.colorClear);
|
|
while (true)
|
|
{
|
|
Coroutine transitionRoutine = CameraController.transitionRoutine;
|
|
if ((transitionRoutine == null || transitionRoutine.done) && !sfx.Playing)
|
|
{
|
|
break;
|
|
}
|
|
gun[1].Modulate = ((Mathf.Sin(Mathf.DegToRad((float)Time.GetTicksMsec() * 0.75f)) > 0f) ? Main.colorGray : Main.colorWhite);
|
|
yield return null;
|
|
}
|
|
for (float a = 0f; a < 30f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
yield return null;
|
|
Main.inEvent = Coroutine.Start(IntroClassRoom.FirstEvent());
|
|
QueueFree();
|
|
}
|
|
|
|
private void MenuInput()
|
|
{
|
|
if (text.VisibleRatio < 1f && Input.IsActionJustPressed(Main.keys[4]))
|
|
{
|
|
text.VisibleCharacters = int.MaxValue;
|
|
return;
|
|
}
|
|
switch (menu)
|
|
{
|
|
case 0:
|
|
if (Input.IsActionJustPressed(Main.keys[4]))
|
|
{
|
|
if (option == 0)
|
|
{
|
|
if (state == 0)
|
|
{
|
|
baseText = texts[2];
|
|
UpdateText();
|
|
}
|
|
else
|
|
{
|
|
state = 3;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
option = 0;
|
|
menu = 2;
|
|
}
|
|
Audio.PlaySound(Audio.commonSounds[2]);
|
|
UpdateButtons();
|
|
}
|
|
else if (Input.IsActionJustPressed(Main.keys[2]))
|
|
{
|
|
option = (int)Main.Repeat(option + 1, 2f);
|
|
UpdateButtons();
|
|
Audio.PlaySound(Audio.commonSounds[0]);
|
|
}
|
|
else if (Input.IsActionJustPressed(Main.keys[3]))
|
|
{
|
|
option = (int)Main.Repeat(option - 1, 2f);
|
|
UpdateButtons();
|
|
Audio.PlaySound(Audio.commonSounds[0]);
|
|
}
|
|
break;
|
|
case 2:
|
|
if (Input.IsActionJustPressed(Main.keys[4]))
|
|
{
|
|
Audio.PlaySound(Audio.commonSounds[2]);
|
|
baseText = texts[3];
|
|
if (state > 0)
|
|
{
|
|
soul.Visible = false;
|
|
baseText = texts[4];
|
|
UpdateText();
|
|
menu = 0;
|
|
option = 0;
|
|
UpdateButtons();
|
|
}
|
|
else if (option == 0)
|
|
{
|
|
text.Text = "";
|
|
steps++;
|
|
menu = 0;
|
|
busy = Coroutine.Start(TreeAnim(3, 40f, updateButtons: true));
|
|
soul.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
baseText = texts[5];
|
|
UpdateText();
|
|
menu = 0;
|
|
UpdateButtons();
|
|
}
|
|
}
|
|
else if (Input.IsActionJustPressed(Main.keys[0]) && state == 0)
|
|
{
|
|
option = (int)Main.Repeat(option + 1, 2f);
|
|
UpdateButtons();
|
|
Audio.PlaySound(Audio.commonSounds[0]);
|
|
}
|
|
else if (Input.IsActionJustPressed(Main.keys[1]) && state == 0)
|
|
{
|
|
option = (int)Main.Repeat(option - 1, 2f);
|
|
UpdateButtons();
|
|
Audio.PlaySound(Audio.commonSounds[0]);
|
|
}
|
|
else if (Input.IsActionJustPressed(Main.keys[5]))
|
|
{
|
|
menu = 0;
|
|
option = 1;
|
|
UpdateButtons(updateText: true);
|
|
Audio.PlaySound(Audio.commonSounds[0]);
|
|
}
|
|
break;
|
|
case 1:
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void Deselect()
|
|
{
|
|
for (int i = 0; i < options.Length; i++)
|
|
{
|
|
options[i].Texture = buttons[i];
|
|
}
|
|
soul.Visible = false;
|
|
}
|
|
|
|
private void UpdateText()
|
|
{
|
|
text.Text = baseText;
|
|
text.VisibleRatio = 0f;
|
|
}
|
|
|
|
private void UpdateButtons(bool updateText = false)
|
|
{
|
|
soul.Visible = true;
|
|
if (updateText)
|
|
{
|
|
UpdateText();
|
|
}
|
|
if (menu == 0)
|
|
{
|
|
soul.Position = soulMainOpt[option];
|
|
for (int i = 0; i < options.Length; i++)
|
|
{
|
|
options[i].Texture = buttons[i + ((option == i) ? 4 : 0)];
|
|
}
|
|
}
|
|
else if (menu == 1)
|
|
{
|
|
soul.Position = soulActSelec[option];
|
|
}
|
|
else if (menu == 2)
|
|
{
|
|
soul.Position = soulActSelec[option];
|
|
text.VisibleCharacters = int.MaxValue;
|
|
if (state == 0)
|
|
{
|
|
text.Text = "\t" + texts[6] + "\n\t" + texts[7];
|
|
}
|
|
else
|
|
{
|
|
text.Text = "\t" + texts[8];
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|