This repository has been archived on 2026-01-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
AW_2025/Assets/Scripts/SimulationManager.cs

112 lines
2.3 KiB
C#
Raw Permalink Normal View History

using UnityEngine;
2025-03-04 17:38:33 +09:00
public class SimulationManager : MonoBehaviour
{
Animator[] allAnimator;
public bool isSpeedUp;
2025-03-06 14:21:07 +09:00
public float upSpeedValue = 5;
2025-03-06 17:51:47 +09:00
Panel_Property property;
2025-03-05 09:54:54 +09:00
Panel_Result resultUI;
private void Awake()
{
2025-03-06 17:51:47 +09:00
property = FindAnyObjectByType<Panel_Property>();
allAnimator = FindObjectsByType<Animator>(FindObjectsSortMode.None);
2025-03-05 09:54:54 +09:00
resultUI = FindAnyObjectByType<Panel_Result>();
resultUI.gameObject.SetActive(false);
2025-03-05 17:44:27 +09:00
AnimationPlay(false);
}
void Update()
{
2025-03-06 17:51:47 +09:00
if (Input.GetKeyDown(KeyCode.Keypad1))
{
property.Activate(0);
}
if (Input.GetKeyDown(KeyCode.Keypad2))
{
property.Activate(1);
}
if (Input.GetKeyDown(KeyCode.Keypad3))
{
property.Activate(2);
}
if (Input.GetKeyDown(KeyCode.Keypad4))
{
property.Activate(3);
}
if (Input.GetKeyDown(KeyCode.Keypad5))
{
property.Activate(4);
}
if (Input.GetKeyDown(KeyCode.Keypad6))
{
property.Activate(5);
}
if (Input.GetKeyDown(KeyCode.Keypad7))
{
property.Activate(6);
}
if (Input.GetKeyDown(KeyCode.S))
{
ToggleAnimationSpeedUp();
}
2025-03-04 17:38:33 +09:00
if (Input.GetKeyDown(KeyCode.Space))
{
AnimationPlay(false);
ShowResultUI();
}
}
2025-03-05 17:44:27 +09:00
public void AnimationPlay(bool playing)
{
foreach (Animator animator in allAnimator)
{
2025-03-04 17:38:33 +09:00
if (playing)
{
animator.Play(animator.GetCurrentAnimatorStateInfo(0).fullPathHash);
2025-03-06 14:21:07 +09:00
animator.speed = Random.Range(0.5f, 1.5f);
}
else
{
animator.speed = 0;
}
}
}
void ToggleAnimationSpeedUp()
{
isSpeedUp = !isSpeedUp;
if (isSpeedUp)
{
2025-03-06 14:21:07 +09:00
foreach (Animator animator in allAnimator)
{
animator.speed *= upSpeedValue;
}
}
else
{
2025-03-06 14:21:07 +09:00
foreach (Animator animator in allAnimator)
{
animator.speed /= upSpeedValue;
}
}
2025-03-06 14:21:07 +09:00
}
2025-03-04 17:38:33 +09:00
void ShowResultUI()
{
2025-03-05 09:54:54 +09:00
resultUI.gameObject.SetActive(true);
2025-03-04 17:38:33 +09:00
}
}