/
Veteread
/
Packer
Обзор
Документация
Войти
/
Veteread
/
Packer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
PlayerBlockDropper.cs
102 строки
3 KB
Veteread
upload files
04 май 2025, 10:49
04 май 2025, 10:49
a5dcff3
Код
Авторство
О чём код?
using UnityEngine; public class PlayerBlockDropper : MonoBehaviour { [Header("Systems")] [SerializeField] private BlockSpawnSystem spawnSystem; [SerializeField] private BlockThrowSystem throwSystem; [SerializeField] private GameProgressTracker progressTracker; [SerializeField] private BlockSelectionUI selectionUI; [SerializeField] private Camera gameCamera; private Block currentBlock; private float lastCheckTime; private bool isWaitingForThrow; // ����� ��������� private void Start() { if (selectionUI != null) { selectionUI.OnBlockSelected += OnBlockSelected; } else { Debug.LogError("BlockSelectionUI not assigned!"); } } private void Update() { if (Input.touchCount > 0) { HandleInput(); } if (Time.time - lastCheckTime > 0.5f) { progressTracker.CheckCompletion(); lastCheckTime = Time.time; } } private void OnBlockSelected(GameObject blockPrefab) { if (currentBlock != null) { Destroy(currentBlock.gameObject); } spawnSystem.ShowSpawnPoints(); isWaitingForThrow = false; // ����� ��������� } private void HandleInput() { Touch touch = Input.GetTouch(0); Vector2 touchPos = gameCamera.ScreenToWorldPoint(touch.position); // ���� 1: ����� ����� ������ if (currentBlock == null && touch.phase == TouchPhase.Began) { if (spawnSystem.TrySelectPoint(touch.position, gameCamera)) { GameObject prefab = selectionUI.GetSelectedPrefab(); if (prefab != null) { currentBlock = spawnSystem.SpawnBlock(prefab, spawnSystem.SelectedPoint, this); isWaitingForThrow = true; // ������ � ������ Debug.Log("������ � ������"); } } } // ���� 2: ������ ������ else if (isWaitingForThrow && touch.phase == TouchPhase.Began) { throwSystem.StartAiming(touchPos); isWaitingForThrow = false; Debug.Log("������ ������"); } // ���� 3: ������� ������ else if (throwSystem.IsThrowing) { if (touch.phase == TouchPhase.Moved) { throwSystem.TrySetDirection(touchPos); Debug.Log("������� ������1"); } else if (touch.phase == TouchPhase.Ended) { throwSystem.ExecuteThrow(currentBlock); currentBlock = null; Debug.Log("������� ������2"); } } } public void RemoveBlock(Block block) { if (currentBlock == block) { currentBlock = null; } } }