2026-07-14 11:14:13 +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();
}
}