chip-game/Assets/Scripts/WinPanel.cs
se_ga 2118668ac9 FIX: Все игровые эффекты теперь зависят от настройки громкости эффектов
До этого некоторые легаси объекты могли звучать даже при выключенном звуке
2026-03-19 16:30:10 +03:00

68 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WinPanel : MonoBehaviour
{
public GameObject win1, win2, winBot;
public AudioSource sound;
public void ShowWin(CellState winner)
{
win1.SetActive(false);
win2.SetActive(false);
winBot.SetActive(false);
switch (winner)
{
case CellState.Player1:
win1.SetActive(true); break;
case CellState.Player2:
win2.SetActive(true); break;
case CellState.Empty:
winBot.SetActive(true); break;
}
sound.volume = SettingsManager.GetFloat("SoundsVolume", 0);
sound.Play();
StartCoroutine(OpenPanel());
}
public void CloseWin()
{
StartCoroutine(ClosePanel());
}
IEnumerator OpenPanel()
{
float param = 0;
while (param < 1)
{
param += Time.deltaTime;
param = Mathf.Clamp01(param);
transform.localScale = new Vector3(1, param, 1);
yield return null;
}
}
IEnumerator ClosePanel()
{
float param = 1;
while (param > 0)
{
param -= Time.deltaTime;
param = Mathf.Clamp01(param);
transform.localScale = new Vector3(1, param, 1);
yield return null;
}
sound.Stop();
}
}