2023-05-07 20:33:15 +00:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using TMPro;
|
|
|
|
|
|
|
|
using HeavenStudio.Common;
|
|
|
|
|
|
|
|
namespace HeavenStudio
|
|
|
|
{
|
|
|
|
public class OpeningManager : MonoBehaviour
|
|
|
|
{
|
2023-12-26 05:22:51 +00:00
|
|
|
[SerializeField] AudioSource openingAudio;
|
2023-05-07 20:33:15 +00:00
|
|
|
[SerializeField] Animator openingAnim;
|
|
|
|
[SerializeField] TMP_Text buildText;
|
|
|
|
[SerializeField] TMP_Text versionDisclaimer;
|
2023-10-29 19:44:47 +00:00
|
|
|
[SerializeField] bool enableSecondDisclaimer;
|
2023-05-07 20:33:15 +00:00
|
|
|
|
|
|
|
bool fastBoot = false;
|
2023-12-26 05:22:51 +00:00
|
|
|
float timer = 0;
|
|
|
|
|
2023-05-07 20:33:15 +00:00
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
string[] args = System.Environment.GetCommandLineArgs();
|
|
|
|
for (int i = 1; i < args.Length; i++)
|
|
|
|
{
|
|
|
|
// first arg is always this executable
|
|
|
|
Debug.Log(args[i]);
|
|
|
|
if (args[i].IndexOfAny(Path.GetInvalidPathChars()) == -1)
|
|
|
|
{
|
|
|
|
if (File.Exists(args[i]) && (args[i].EndsWith(".riq") || args[i].EndsWith(".tengoku")))
|
|
|
|
{
|
2023-12-26 05:22:51 +00:00
|
|
|
GlobalGameManager.PlayOpenFile = args[i];
|
2023-05-07 20:33:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (args[i] == "--nosplash")
|
|
|
|
{
|
|
|
|
fastBoot = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-26 05:22:51 +00:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
buildText.text = "EDITOR";
|
|
|
|
#else
|
|
|
|
buildText.text = Application.buildGUID.Substring(0, 8) + " " + AppInfo.Date.ToString("dd/MM/yyyy hh:mm:ss");
|
|
|
|
#endif
|
2023-05-07 20:33:15 +00:00
|
|
|
|
2023-10-29 19:44:47 +00:00
|
|
|
if ((Application.platform is RuntimePlatform.OSXPlayer or RuntimePlatform.OSXEditor) || !enableSecondDisclaimer)
|
2023-05-07 20:33:15 +00:00
|
|
|
{
|
|
|
|
versionDisclaimer.text = "";
|
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// string ver = "<color=#FFFFCC>If you're coming from an older Heaven Studio build, copy your settings configs over from\n<color=#FFFF00>";
|
|
|
|
// if (Application.platform is RuntimePlatform.WindowsPlayer or RuntimePlatform.WindowsEditor)
|
|
|
|
// {
|
|
|
|
// ver += Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\AppData\\LocalLow\\Megaminerzero\\Heaven Studio\\";
|
|
|
|
// ver += "<color=#FFFFCC>\nto\n<color=#FFFF00>";
|
|
|
|
// ver += Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\AppData\\LocalLow\\RHeavenStudio\\Heaven Studio\\";
|
|
|
|
// }
|
|
|
|
// else if (Application.platform is RuntimePlatform.LinuxPlayer or RuntimePlatform.LinuxEditor)
|
|
|
|
// {
|
|
|
|
// ver += "~/.config/unity3d/Megaminerzero/Heaven Studio/";
|
|
|
|
// ver += "<color=#FFFFCC>\nto\n<color=#FFFF00>";
|
|
|
|
// ver += "~/.config/unity3d/RHeavenStudio/Heaven Studio/";
|
|
|
|
// }
|
|
|
|
// versionDisclaimer.text = ver;
|
|
|
|
// }
|
2023-05-07 20:33:15 +00:00
|
|
|
|
|
|
|
if (!GlobalGameManager.IsFirstBoot && !PersistentDataManager.gameSettings.showSplash)
|
|
|
|
{
|
|
|
|
fastBoot = true;
|
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
|
2023-05-07 20:33:15 +00:00
|
|
|
if (fastBoot)
|
|
|
|
{
|
|
|
|
OnFinishDisclaimer(0.1f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-12-26 05:22:51 +00:00
|
|
|
timer = 0;
|
2023-05-07 20:33:15 +00:00
|
|
|
openingAnim.Play("FirstOpening", -1, 0);
|
2023-12-26 05:22:51 +00:00
|
|
|
openingAudio.PlayScheduled(AudioSettings.dspTime + 0.5);
|
2023-05-07 20:33:15 +00:00
|
|
|
StartCoroutine(WaitAndFinishOpening());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-26 05:22:51 +00:00
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
if (!fastBoot)
|
|
|
|
{
|
|
|
|
timer += Time.deltaTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-07 20:33:15 +00:00
|
|
|
IEnumerator WaitAndFinishOpening()
|
|
|
|
{
|
2023-12-26 05:22:51 +00:00
|
|
|
WaitUntil wait = new WaitUntil(() => CheckForInput() || (timer >= 8));
|
|
|
|
yield return wait;
|
2023-05-07 20:33:15 +00:00
|
|
|
OnFinishDisclaimer(0.35f);
|
|
|
|
}
|
|
|
|
|
2023-12-26 05:22:51 +00:00
|
|
|
bool CheckForInput()
|
|
|
|
{
|
|
|
|
var controllers = PlayerInput.GetInputControllers();
|
|
|
|
foreach (var newController in controllers)
|
|
|
|
{
|
|
|
|
if (newController.GetLastButtonDown(true) > 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-05-07 20:33:15 +00:00
|
|
|
void OnFinishDisclaimer(float fadeDuration = 0)
|
|
|
|
{
|
2023-12-26 05:22:51 +00:00
|
|
|
openingAudio.Stop();
|
|
|
|
if (GlobalGameManager.PlayOpenFile is not null or "")
|
2023-05-07 20:33:15 +00:00
|
|
|
{
|
|
|
|
GlobalGameManager.LoadScene("Game", fadeDuration, 0.5f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-12-26 05:22:51 +00:00
|
|
|
GlobalGameManager.LoadScene("Title", fadeDuration, fadeDuration);
|
2023-05-07 20:33:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|