88 lines
2.1 KiB
C#
88 lines
2.1 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class KeyboardShortcuts : MonoBehaviour
|
||
|
{
|
||
|
public static KeyboardShortcuts Instance;
|
||
|
public List<char> KeyStrokes = new List<char>();
|
||
|
|
||
|
private void Awake()
|
||
|
{
|
||
|
if (Instance != null)
|
||
|
{
|
||
|
Destroy(Instance);
|
||
|
}
|
||
|
Instance = this;
|
||
|
}
|
||
|
|
||
|
public void DropdownPrevious(Dropdown dropdown)
|
||
|
{
|
||
|
dropdown.value = dropdown.value - 1 < 0 ? dropdown.options.Count - 1 : dropdown.value - 1;
|
||
|
}
|
||
|
|
||
|
public void DropdownNext(Dropdown dropdown)
|
||
|
{
|
||
|
dropdown.value = dropdown.value + 1 >= dropdown.options.Count ? 0 : dropdown.value + 1;
|
||
|
}
|
||
|
|
||
|
private void Update()
|
||
|
{
|
||
|
KatboiSequence();
|
||
|
|
||
|
if (Input.anyKeyDown && !string.IsNullOrEmpty(Input.inputString))
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
}
|
||
|
catch(System.Exception e)
|
||
|
{
|
||
|
Debug.LogWarning("caught " + e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Time
|
||
|
if (Input.GetKeyDown(KeyCode.LeftArrow))
|
||
|
{
|
||
|
FateViewerMain.Instance.ChangeAnimationFrame(-1);
|
||
|
}
|
||
|
|
||
|
if (Input.GetKeyDown(KeyCode.RightArrow))
|
||
|
{
|
||
|
FateViewerMain.Instance.ChangeAnimationFrame(1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void KatboiSequence()
|
||
|
{
|
||
|
List<string> sequences = new List<string>()
|
||
|
{
|
||
|
"KATBOI01"
|
||
|
};
|
||
|
|
||
|
if (Input.anyKeyDown && !string.IsNullOrEmpty(Input.inputString))
|
||
|
{
|
||
|
if (KeyStrokes.Count >= 10)
|
||
|
{
|
||
|
KeyStrokes = ((IEnumerable<char>)KeyStrokes).Reverse().Take(10).Reverse().ToList();
|
||
|
}
|
||
|
KeyStrokes.Add(Input.inputString.ToUpper()[0]);
|
||
|
}
|
||
|
|
||
|
string passcode = sequences.FirstOrDefault(s => new string(KeyStrokes.ToArray()).Contains(s));
|
||
|
|
||
|
if (!string.IsNullOrEmpty(passcode))
|
||
|
{
|
||
|
switch (passcode)
|
||
|
{
|
||
|
case "KATBOI01":
|
||
|
break;
|
||
|
default: break;
|
||
|
}
|
||
|
KeyStrokes.Clear();
|
||
|
}
|
||
|
}
|
||
|
}
|