111 lines
2.5 KiB
C#
111 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Envirioment/Bench.cs")]
|
|
public partial class Bench : Area2D, Interacteable
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
private SaveFile.Flags flag = SaveFile.Flags.None;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private AudioStream sound;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private float volume = 0.7f;
|
|
|
|
private Vector2[] pos;
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
pos = new Vector2[GetChildCount() - 1];
|
|
for (int i = 0; i < pos.Length; i++)
|
|
{
|
|
pos[i] = GetChild<Node2D>(i + 1).GlobalPosition;
|
|
}
|
|
}
|
|
|
|
public void Interact()
|
|
{
|
|
if (Player.instance.GlobalPosition.Y > base.GlobalPosition.Y)
|
|
{
|
|
Main.inEvent = Coroutine.Start(SitEvent());
|
|
}
|
|
else
|
|
{
|
|
Player.instance.canInput = true;
|
|
}
|
|
}
|
|
|
|
private IEnumerator SitEvent()
|
|
{
|
|
AudioStream m = Audio.music.Stream;
|
|
Party.ChangeCollider(state: false);
|
|
Audio.FadeSound(Audio.music, 1f);
|
|
Party.MoveTo(pos, 0.5f, align: true, Entity.Direction.South);
|
|
while (!Party.IsStopped())
|
|
{
|
|
yield return null;
|
|
}
|
|
Party.UpdateFollowerEntities();
|
|
PartyAnim();
|
|
if (sound != null)
|
|
{
|
|
Audio.ChangeMusic(sound, 0.5f, volume);
|
|
}
|
|
for (float a = 0f; a < 60f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
while (!Input.IsActionJustPressed(Main.keys[4]))
|
|
{
|
|
yield return null;
|
|
}
|
|
Audio.FadeSound(Audio.music, 0.5f);
|
|
for (float a = 0f; a < 30f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
Audio.ChangeMusic(m);
|
|
Party.LookAt(Entity.Direction.South);
|
|
Party.UpdateAnim();
|
|
Party.ChangeCollider(state: true);
|
|
Player.instance.ResetFollowStep();
|
|
yield return null;
|
|
}
|
|
|
|
private static void PartyAnim()
|
|
{
|
|
for (int i = 0; i < SaveFile.current.activeParty.Count; i++)
|
|
{
|
|
Party.party[SaveFile.current.activeParty[i]].oEntity.sprite.FlipH = false;
|
|
Entity.IDs id = Party.party[SaveFile.current.activeParty[i]].oEntity.id;
|
|
if (id != Entity.IDs.Clover)
|
|
{
|
|
if (id == Entity.IDs.Axis)
|
|
{
|
|
Party.party[SaveFile.current.activeParty[i]].oEntity.anim.Play("TramSit");
|
|
continue;
|
|
}
|
|
}
|
|
else if (Player.instance.animMod == Entity.AnimMods.Hat)
|
|
{
|
|
Party.party[SaveFile.current.activeParty[i]].oEntity.anim.Play("SitBenchHat");
|
|
continue;
|
|
}
|
|
if (SaveFile.HasFlag(SaveFile.Flags.IsInDW))
|
|
{
|
|
Party.party[SaveFile.current.activeParty[i]].oEntity.anim.Play("SitBenchDW");
|
|
}
|
|
else
|
|
{
|
|
Party.party[SaveFile.current.activeParty[i]].oEntity.anim.Play("SitBench");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|