Exemplo n.º 1
0
    public void Click()
    {
        // Variables:
        // Is there a tile currently selected?
        bool selectionExists = selected;
        // Is the tile that's selected a slot?
        bool selectionIsSlot = selectionExists && selected.GetComponent <VectorSlot>();
        // Is the vectorLocal in the selection in a slot?
        bool selectionVLocalAssignedToSlot = selectionExists && VectorSlot.isVectorAssignedAnySlot(selected.VLocal);
        // Are any slots open?
        bool anySlotsOpen = VectorSlot.AnySlotsOpen();
        // Is the tile that's clicked a slot?
        bool clickedIsSlot = GetComponent <VectorSlot>();
        // Is the vectorLocal in the tile that's clicked in a slot?
        bool clickedVLocalAssignedToSlot = VectorSlot.isVectorAssignedAnySlot(this.VLocal);
        // Is the vectorLocal in the tile that's clicked a match for the selection vectorLocal?
        bool clickedVLocalMatchesSelectionVLocal = selectionExists && (this.VLocal == selected.VLocal);

        if (!selectionExists)
        {
            if (!clickedIsSlot)
            {
                if (anySlotsOpen && !clickedVLocalAssignedToSlot)
                {
                    VectorSlot.NextSlotOpen(true).GetComponent <VectorTile>().Populate(this.VLocal);
                    FindObjectOfType <SquadAssignment>().SaveSquad();
                    return;
                }
                else
                {
                    Select();
                    return;
                }
            }
            else
            {
                Select();
                return;
            }
        }
        else
        {
            if (clickedVLocalMatchesSelectionVLocal)
            {
                Deselect();
                return;
            }
            else
            {
                if (selectionIsSlot)
                {
                    if (clickedIsSlot)
                    {
                        Select();
                        return;
                    }
                    else
                    {
                        if (clickedVLocalAssignedToSlot)
                        {
                            VectorTile  tileA = VectorSlot.whatSlotIsVectorAssigned(this.VLocal).GetComponent <VectorTile>();
                            VectorTile  tileB = VectorSlot.whatSlotIsVectorAssigned(selected.VLocal).GetComponent <VectorTile>();
                            VectorLocal tmp   = tileA.VLocal;
                            tileA.Populate(tileB.VLocal);
                            tileB.Populate(tmp);
                            Deselect();
                            FindObjectOfType <SquadAssignment>().SaveSquad();
                            return;
                        }
                        else
                        {
                            selected.Populate(this.VLocal);
                            Deselect();
                            FindObjectOfType <SquadAssignment>().SaveSquad();
                            return;
                        }
                    }
                }
                else
                {
                    if (clickedIsSlot)
                    {
                        if (selectionVLocalAssignedToSlot)
                        {
                            VectorTile  tileA = VectorSlot.whatSlotIsVectorAssigned(this.VLocal).GetComponent <VectorTile>();
                            VectorTile  tileB = VectorSlot.whatSlotIsVectorAssigned(selected.VLocal).GetComponent <VectorTile>();
                            VectorLocal tmp   = tileA.VLocal;
                            tileA.Populate(tileB.VLocal);
                            tileB.Populate(tmp);
                            Deselect();
                            FindObjectOfType <SquadAssignment>().SaveSquad();
                            return;
                        }
                        else
                        {
                            VectorSlot.whatSlotIsVectorAssigned(this.VLocal).GetComponent <VectorTile>().Populate(selected.VLocal);
                            Deselect();
                            FindObjectOfType <SquadAssignment>().SaveSquad();
                            return;
                        }
                    }
                    else
                    {
                        Select();
                        return;
                    }
                }
            }
        }
    }