Added password input thing
This commit is contained in:
60
Assets/Scripts/PasswordScriptThing.cs
Normal file
60
Assets/Scripts/PasswordScriptThing.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace InterfaceOff.WorldScene
|
||||
{
|
||||
public class PasswordScriptThing : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Text PasswordText;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
PasswordText.text = "";
|
||||
}
|
||||
|
||||
private static bool IsAnyKeyPressed()
|
||||
{
|
||||
return Input.GetKeyDown(KeyCode.A) ||
|
||||
Input.GetKeyDown(KeyCode.B) ||
|
||||
Input.GetKeyDown(KeyCode.C) ||
|
||||
Input.GetKeyDown(KeyCode.D) ||
|
||||
Input.GetKeyDown(KeyCode.E) ||
|
||||
Input.GetKeyDown(KeyCode.F) ||
|
||||
Input.GetKeyDown(KeyCode.G) ||
|
||||
Input.GetKeyDown(KeyCode.H) ||
|
||||
Input.GetKeyDown(KeyCode.I) ||
|
||||
Input.GetKeyDown(KeyCode.J) ||
|
||||
Input.GetKeyDown(KeyCode.K) ||
|
||||
Input.GetKeyDown(KeyCode.L) ||
|
||||
Input.GetKeyDown(KeyCode.M) ||
|
||||
Input.GetKeyDown(KeyCode.N) ||
|
||||
Input.GetKeyDown(KeyCode.O) ||
|
||||
Input.GetKeyDown(KeyCode.P) ||
|
||||
Input.GetKeyDown(KeyCode.Q) ||
|
||||
Input.GetKeyDown(KeyCode.R) ||
|
||||
Input.GetKeyDown(KeyCode.S) ||
|
||||
Input.GetKeyDown(KeyCode.T) ||
|
||||
Input.GetKeyDown(KeyCode.U) ||
|
||||
Input.GetKeyDown(KeyCode.V) ||
|
||||
Input.GetKeyDown(KeyCode.W) ||
|
||||
Input.GetKeyDown(KeyCode.X) ||
|
||||
Input.GetKeyDown(KeyCode.Y) ||
|
||||
Input.GetKeyDown(KeyCode.Z) ||
|
||||
Input.GetKeyDown(KeyCode.Space);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (IsAnyKeyPressed())
|
||||
{
|
||||
PasswordText.text += '*';
|
||||
}
|
||||
|
||||
if (PasswordText.text.Length > 12)
|
||||
{
|
||||
transform.parent.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/PasswordScriptThing.cs.meta
Normal file
11
Assets/Scripts/PasswordScriptThing.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4eca7ed9833dbad44b3e2e8f144ebd1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -22,6 +22,7 @@ namespace InterfaceOff
|
||||
[field: SerializeField] private GameObject DeathInfo { get; set; }
|
||||
[field: SerializeField] private SpawnableWindowType[] WindowTypes { get; set; }
|
||||
[field: SerializeField] private GameObject Parent { get; set; }
|
||||
[field: SerializeField] private GameObject PasswordField { get; set; }
|
||||
private int TotalSpawnWeight { get; set; }
|
||||
|
||||
[field: SerializeField] public int SpawnedWindowCount { get; private set; }
|
||||
@@ -95,6 +96,11 @@ namespace InterfaceOff
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (Random.Range(0, 1000) == 500)
|
||||
{
|
||||
PasswordField.SetActive(true);
|
||||
}
|
||||
|
||||
/* Spawns new windows whilst active */
|
||||
if (AutoSpawn)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user