Example #1
0
    public void updateContentTypeByColorIndex(int color)
    {
        switch (color)
        {
        case (1):
            contentColor = Piece.EColor.BLUE;
            break;

        case (2):
            contentColor = Piece.EColor.GREEN;
            break;

        case (3):
            contentColor = Piece.EColor.ORANGE;
            break;

        case (4):
            contentColor = Piece.EColor.PINK;
            break;

        case (5):
            contentColor = Piece.EColor.PURPLE;
            break;

        case (6):
            contentColor = Piece.EColor.YELLOW;
            break;
        }
    }
Example #2
0
    public Cell[] getCellsOfSameColor(Piece.EColor cellColor)
    {
        List <Cell> selection = new List <Cell>();

        for (int i = 0; i < cells.Count; i++)
        {
            if (cells[i].contentColor == cellColor)
            {
                selection.Add(cells[i]);
            }
        }
        return(selection.ToArray());
    }
Example #3
0
 public void setCellContentColor(Cell cell, Piece.EColor color)
 {
     cell.contentColor = color;
 }
Example #4
0
 public void setCellContentColor(int x, int y, Piece.EColor color)
 {
     setCellContentColor(getCellAt(x, y), color);
 }
Example #5
0
 public void setCellContentColor(int cellIndex, Piece.EColor color)
 {
     setCellContentColor(cells[cellIndex], color);
 }
Example #6
0
    /**
     * Ocupa la celda indicada y le asigna el contenido y tipo indicado
     **/
    public void occupyAndConfigureCell(Cell cell, GameObject content, Piece.EType type, Piece.EColor color, bool positionate = false)
    {
        cell.occupied = true;

        setCellContent(cell, content, true, positionate);       //destroy
        setCellContentType(cell, type);
        setCellContentColor(cell, color);
    }
Example #7
0
 /**
  * Ocupa la celda indicada y le asigna el contenido y tipo indicado
  **/
 public void occupyAndConfigureCell(int cellIndex, GameObject content, Piece.EType type, Piece.EColor color, bool positionate = false)
 {
     occupyAndConfigureCell(cells[cellIndex], content, type, color, positionate);
 }
Example #8
0
    void OnDrag(DragGesture gesture)
    {
        //Solo se ejecuta una vez por frame (multifinger puede llamarlo mas de una vez)
        if (!allowInput || lastTimeDraggedFrame == Time.frameCount)
        {
            return;
        }

        lastTimeDraggedFrame = Time.frameCount;

        switch (gesture.Phase)
        {
        case (ContinuousGesturePhase.Started):
        {
            if (currentSelected != null)
            {
                activateRayCasters(false);
                somethingDragged = true;

                Vector3 posOverFinger = Camera.main.ScreenToWorldPoint(new Vector3(gesture.Position.x, gesture.Position.y, 0));
                posOverFinger.z = currentSelected.transform.position.z;
                posOverFinger  += offsetPositionOverFinger;
                moveTo(currentSelected, posOverFinger, pieceSpeed);
                isOnPlayer(true);
            }
        }
        break;

        case (ContinuousGesturePhase.Updated):
        {
            if (currentSelected != null)
            {
                Vector3 posOverFinger = Camera.main.ScreenToWorldPoint(new Vector3(gesture.Position.x, gesture.Position.y, 0));
                posOverFinger.z = currentSelected.transform.position.z;
                posOverFinger  += offsetPositionOverFinger;
                moveTo(currentSelected, posOverFinger, pieceSpeed);

                if (OnCellSelected != null)
                {
                    Cell cellSelected = cellsManager.getCellUnderPoint(currentSelected.transform.position);
                    if (cellSelected != null)
                    {
                        if (cellSelected.content != null)
                        {
                            if (cellSelected.contentColor != Piece.EColor.LETTER_OBSTACLE &&
                                cellSelected.contentColor != Piece.EColor.NONE)
                            {
                                //if (selectedCellColor != null)
                                if (selectedCellColor != Piece.EColor.NONE)
                                {
                                    if (selectedCellColor != cellSelected.contentColor)
                                    {
                                        OnCellSelected(cellSelected);
                                    }
                                }
                                else
                                {
                                    selectedCellColor = cellSelected.contentColor;
                                    OnCellSelected(cellSelected);
                                }
                            }
                            else
                            {
                                OnCellSelected(null);
                            }
                        }
                        else
                        {
                            OnCellSelected(null);
                        }
                    }
                }
            }
        }
        break;

        case (ContinuousGesturePhase.Ended):
        {
            if (currentSelected)
            {
                activateRayCasters(true);
                if (OnDrop != null)
                {
                    OnDrop();
                }
                reset();
            }
        }
        break;
        }
    }