示例#1
0
    public void CallClick()
    {
        if (disabled)
        {
            return;
        }

        Vector2      worldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        RaycastHit2D hit           = Physics2D.Raycast(worldPosition, Vector2.down * .2f);

        if (hit && hit.collider.tag == "Tile")
        {
            Tile t = hit.collider.GetComponent <Tile>();
            if (t)
            {
                //Se o bloco tiver ocupado por algo, interage com o que está em cima dele
                if (t.ocupation != null)
                {
                    SetTile(t);
                    ExitCurrentSelection();
                    SetSelection(t.ocupation);
                }
                //Se não, verifica se o bloco é selecionável
                else if (t.Selectable)
                {
                    if (currentSelection != null)
                    {
                        // passar pro PlayerPanel porque vai ter as infos de skills e opções de movimento selecionadas
                        currentSelection.GetComponent <TacticsUnit>().SetActionTarget(t);
                        playerPanel.ClosePanel();
                    }
                }
                //Se clicar em um bloco com nada, cancela a ação atual
                else
                {
                    playerPanel.CancelButton();
                }
            }
        }
    }