Актуальная версия
This commit is contained in:
@ -1,23 +1,68 @@
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
|
||||
|
||||
class Finish : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject Effects;
|
||||
[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()
|
||||
{
|
||||
Effects.SetActive(false);
|
||||
Effects1.SetActive(false);
|
||||
Effects2.SetActive(false);
|
||||
WinMenu.SetActive(false);
|
||||
}
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.tag == "Player 1" || other.gameObject.tag == "Player 2")
|
||||
if (other.gameObject.tag == "Player 1")
|
||||
{
|
||||
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
||||
Effects.SetActive(true);
|
||||
|
||||
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 = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
StripeActive.SetActive(false);
|
||||
}
|
||||
|
||||
private void SecondPlayerWin()
|
||||
{
|
||||
WinText.text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
StripeActive.SetActive(false);
|
||||
}
|
||||
|
||||
private void ActiveObject()
|
||||
{
|
||||
Effects1.SetActive(true);
|
||||
Effects2.SetActive(true);
|
||||
WinMenu.SetActive(true);
|
||||
Player1_Input.enabled = false;
|
||||
Player2_Input.enabled = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
8
Assets/Scripts/Start.meta
Normal file
8
Assets/Scripts/Start.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b690ea24f392e2b49925a24d6af5431e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
51
Assets/Scripts/Start/Starter.cs
Normal file
51
Assets/Scripts/Start/Starter.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Starter : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float _starter = 5f;
|
||||
[SerializeField] private Text _timer;
|
||||
|
||||
[SerializeField] private PlayerInput _dontMovePlayer1;
|
||||
[SerializeField] private PlayerInput _dontMovePlayer2;
|
||||
|
||||
[SerializeField] private Image _borders;
|
||||
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_timer.text = _starter.ToString();
|
||||
|
||||
_dontMovePlayer1.enabled = false;
|
||||
_dontMovePlayer2.enabled = false;
|
||||
|
||||
_borders.enabled = true;
|
||||
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
_starter -= Time.deltaTime;
|
||||
_timer.text = Mathf.Round(_starter).ToString();
|
||||
|
||||
|
||||
if (_starter < 1f)
|
||||
{
|
||||
enabled = false;
|
||||
|
||||
if (_timer != null)
|
||||
{
|
||||
Destroy(_timer.gameObject);
|
||||
_dontMovePlayer1.enabled = true;
|
||||
_dontMovePlayer2.enabled = true;
|
||||
_borders.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Start/Starter.cs.meta
Normal file
11
Assets/Scripts/Start/Starter.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f64f6fc12993a641a703f0eb9d3b67d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user