void Update() { /* if (((Input.touchCount > 0) && Input.touches[0].phase == TouchPhase.Began)&&(selectable)) * { * selectable = false; * initialPosition = Input.GetTouch(0).position; * RaycastHit2D nullchecker = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position), Vector2.zero); * if (nullchecker.collider == null) * { * // hexagonManager.Deselect(); * } * else * { * RaycastHit2D[] hit = Physics2D.CircleCastAll(Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position), 0.15f, Vector2.zero); * if (hexagonManager.IsValidGroup(hit)) * { * hexagonManager.Select(hit); * DetectSwipe(); * //if (swipeDetected) * { * StartCoroutine(Waiter(hit)); * } * } * } * selectable = true; * }*/ //for testing on editor #if UNITY_EDITOR if (!hexagonManager.gameoverPanel.activeSelf) { if (Input.GetMouseButtonDown(0)) { initialPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); } if ((hexagonManager.touchAvailable) && (Input.GetMouseButtonUp(0))) { currentPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (selected && DetectSwipe(currentPosition)) { hexagonManager.touchAvailable = false; StartCoroutine(hexagonManager.Waiter(hit)); } else { RaycastHit2D nullchecker = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (nullchecker.collider == null) { selected = hexagonManager.Deselect(); } else { hit = Physics2D.CircleCastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), 0.15f, Vector2.zero); if (hexagonManager.IsValidGroup(hit)) { selected = hexagonManager.Select(hit); } else { hexagonManager.Deselect(); } } hexagonManager.touchAvailable = true; } } } #endif }
void Start() { instance = GetComponent <TouchManager>(); hexagonManager = GetComponent <HexagonManager>(); hexagonManager.Deselect(); }