69 lines
1.5 KiB
C#
69 lines
1.5 KiB
C#
using TMPro;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
|
|
class Finish : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject Effects1;
|
|
[SerializeField] private GameObject Effects2;
|
|
[SerializeField] private GameObject WinMenu;
|
|
[SerializeField] private PlayerInput Player1_Input;
|
|
[SerializeField] private PlayerInput Player2_Input;
|
|
[SerializeField] private TextMeshProUGUI WinText;
|
|
[SerializeField] private GameObject StripeActive;
|
|
|
|
private void Start()
|
|
{
|
|
Effects1.SetActive(false);
|
|
Effects2.SetActive(false);
|
|
WinMenu.SetActive(false);
|
|
}
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.gameObject.tag == "Player 1")
|
|
{
|
|
OnePlayerWin();
|
|
}
|
|
|
|
else if (other.gameObject.tag == "Player 2")
|
|
{
|
|
SecondPlayerWin();
|
|
}
|
|
|
|
if (other.gameObject.tag == "Player 1" || other.gameObject.tag == "Player 2")
|
|
{
|
|
ActiveObject();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void OnePlayerWin()
|
|
{
|
|
WinText.text = "Ïåðâûé èãðîê ïîáåäèë";
|
|
StripeActive.SetActive(false);
|
|
}
|
|
|
|
private void SecondPlayerWin()
|
|
{
|
|
WinText.text = "Âòîðîé èãðîê ïîáåäèë";
|
|
StripeActive.SetActive(false);
|
|
}
|
|
|
|
private void ActiveObject()
|
|
{
|
|
Effects1.SetActive(true);
|
|
Effects2.SetActive(true);
|
|
WinMenu.SetActive(true);
|
|
Player1_Input.enabled = false;
|
|
Player2_Input.enabled = false;
|
|
|
|
}
|
|
|
|
|
|
}
|