예제 #1
0
    private IEnumerator BuildPositionDetection()
    {
        while (!isPlaceSelected)
        {
            if (Input.GetMouseButtonDown(0))
            {
                isPlaceSelected = true;

                Vector3 worldPosition      = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Vector2 clickWorldPosition = new Vector2(worldPosition.x, worldPosition.y);

                if (Physics2D.OverlapPoint(clickWorldPosition) != null &&
                    tilemapHandler.ScreenPositionToTilemapNode(Input.mousePosition).tile.isSlot)
                {
                    alertManager.ShowWarningModal("Slot bloqueado pela torre!");
                }
                else
                {
                    BuildBarrack(Input.mousePosition, goldManager.playerGoldReserve);
                }

                if (buildPositionSelection != null)
                {
                    StopCoroutine(buildPositionSelection);
                }
                yield break;
            }
            else
            {
                yield return(new WaitForFixedUpdate());
            }
        }
    }