Было очень много экстренных ситуаций. И по мне стреляли, и я упал в лужу нахуй блять, и лежал нахуй
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class IoTestPanel : MonoBehaviour
|
|
{
|
|
[SerializeField] List<AudioClip> wowSounds;
|
|
private float timer = 0;
|
|
|
|
[SerializeField] RectTransform pipeline;
|
|
[SerializeField] List<ButtonTester> buttonTesters;
|
|
private int currentTesterIndex = 0;
|
|
|
|
private float exitTime = 3f;
|
|
[SerializeField] Image ExitImage;
|
|
|
|
private Vector2 velocity = Vector2.zero;
|
|
|
|
private void OnEnable()
|
|
{
|
|
foreach (var tester in buttonTesters) { tester.active = false; }
|
|
|
|
pipeline.anchoredPosition = Vector2.zero;
|
|
currentTesterIndex = 0;
|
|
buttonTesters[currentTesterIndex].active = true;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
ExitProcessing();
|
|
|
|
ButtonPinMapping buttonToPress = buttonTesters[currentTesterIndex].button;
|
|
if (In.GetButton(buttonToPress))
|
|
{
|
|
buttonTesters[currentTesterIndex].EmulatePress();
|
|
SoundManager.instance.playClip(wowSounds[Random.Range(0, wowSounds.Count)]);
|
|
buttonTesters[currentTesterIndex].active = false;
|
|
|
|
currentTesterIndex = (currentTesterIndex + 1 + buttonTesters.Count) % buttonTesters.Count;
|
|
buttonTesters[currentTesterIndex].active = true;
|
|
}
|
|
|
|
Vector2 target = new Vector2(200 * currentTesterIndex, 0);
|
|
pipeline.anchoredPosition = Vector2.SmoothDamp(
|
|
pipeline.anchoredPosition,
|
|
target,
|
|
ref velocity,
|
|
0.3f
|
|
);
|
|
}
|
|
|
|
private void ExitProcessing()
|
|
{
|
|
bool pressedExit = In.GetButton(ButtonPinMapping.startOnePlayer) && In.GetButton(ButtonPinMapping.startTwoPlayers);
|
|
timer += pressedExit ? Time.deltaTime : -3 * Time.deltaTime;
|
|
timer = Mathf.Clamp(timer, 0, exitTime);
|
|
|
|
float fillAmount = timer / exitTime;
|
|
ExitImage.fillAmount = fillAmount;
|
|
|
|
if (timer >= 3)
|
|
{
|
|
GameManager.instance.stateMachine.ChangeState(new SettingsState());
|
|
}
|
|
}
|
|
} |