using System.Collections; using System.Collections.Generic; using UnityEngine; public class CrossButtonHandler : MonoBehaviour { private bool _mouseDown = false; private HintSpawner _activePoint; public bool active = false; private CellSpawnAndOperate _cellOperator; public bool _isInCell = false; private activePointSpawner _pointSpawner; public bool isSpawnerHint = false; private GameObject _tagget; void Start() { _tagget = GameObject.FindGameObjectWithTag("tenpoints_tagget"); _activePoint = GameObject.FindGameObjectWithTag("MainCamera").GetComponent(); _cellOperator = GameObject.FindGameObjectWithTag("MainCamera").GetComponent(); _pointSpawner = Object.FindObjectOfType(); } void Update() { Debug.Log(active); if (Input.GetMouseButtonDown(0)) { if (Vector3.Distance(Input.mousePosition, gameObject.transform.position) < 100){ active = true; if (_isInCell) { _cellOperator.uncheckButton(transform.position); } else { _pointSpawner.delete(); } } } if (Input.GetMouseButtonUp(0)) { if (active) { active = false; Vector3 pos = _activePoint.destroyHintAndReturnItsPosition(); Debug.Log(pos.ToString() + _tagget.transform.position.ToString()); if (isSpawnerHint) { _pointSpawner.add(); } _activePoint.activeButton = null; _cellOperator.checkButton(pos); Destroy(gameObject); } } if (active) { _activePoint.activeButton = gameObject.GetComponent(); transform.position = Input.mousePosition; } } }