예제 #1
0
    public bool PlaceInCell(uint row, uint col, EMKCellType type, EMKColor color)
    {
        if (!CanPlaceInCell(row, col, type))
        {
            return(false);
        }

        if (type == EMKCellType.Target)
        {
            IncLevelTargetsLeft();
        }

        m_cells[row, col].type  = type;
        m_cells[row, col].color = color;
        return(true);
    }
예제 #2
0
 public void SetColor(EMKColor baseColor, EMKCellType type)
 {
     myType = type;
     if (type == EMKCellType.Target)
     {
         foreach (MeshRenderer meshRenderer in meshRendererList)
         {
             meshRenderer.enabled = false;
             cakeslice.Outline outline = meshRenderer.gameObject.AddComponent <cakeslice.Outline>();
             if (baseColor == EMKColor.Red)
             {
                 outline.color = 0;
             }
             else if (baseColor == EMKColor.Green)
             {
                 outline.color = 1;
             }
             else if (baseColor == EMKColor.Blue)
             {
                 outline.color = 2;
             }
         }
     }
     else if (type == EMKCellType.Movable)
     {
         foreach (MeshRenderer meshRenderer in meshRendererList)
         {
             //set outline
             cakeslice.Outline outline = meshRenderer.gameObject.AddComponent <cakeslice.Outline>();
             if (baseColor == EMKColor.Red)
             {
                 outline.color = 0;
             }
             else if (baseColor == EMKColor.Green)
             {
                 outline.color = 1;
             }
             else if (baseColor == EMKColor.Blue)
             {
                 outline.color = 2;
             }
             //set layer
             meshRenderer.gameObject.layer = LayerMask.NameToLayer("FurnitureRayLayer");
         }
     }
     furnitureColor = colorMap[baseColor];
 }
예제 #3
0
    protected bool CanMoveMovableToNextCell(ref uint playerCellRow, ref uint playerCellCol, EMKMove move)
    {
        Vector2 movableCell    = GetNextLogicPosition(playerCellRow, playerCellCol, move);
        uint    movableCellRow = (uint)movableCell.x;
        uint    movableCellCol = (uint)movableCell.y;

        //Grid limits
        if (movableCellRow == playerCellRow && movableCellCol == playerCellCol)
        {
            return(false);
        }

        Vector2 nextMovableCell    = GetNextLogicPosition(movableCellRow, movableCellCol, move);
        uint    nextMovableCellRow = (uint)nextMovableCell.x;
        uint    nextMovableCellCol = (uint)nextMovableCell.y;

        //Grid limits again
        if (nextMovableCellRow == movableCellRow && nextMovableCellCol == movableCellRow)
        {
            return(false);
        }

        bool canMove = false;

        if (m_cells[nextMovableCellRow, nextMovableCellCol].type == EMKCellType.Empty)
        {
            //The next cell for the movable object is empty
            canMove = true;

            MKGame.Instance.GetFurnitureManager().MoveFurniture(
                movableCellRow, movableCellCol, nextMovableCellRow, nextMovableCellCol);

            m_cells[nextMovableCellRow, nextMovableCellCol].type  = EMKCellType.Movable;
            m_cells[nextMovableCellRow, nextMovableCellCol].color = m_cells[movableCellRow, movableCellCol].color;

            m_cells[movableCellRow, movableCellCol].type  = m_cells[playerCellRow, playerCellCol].type;
            m_cells[movableCellRow, movableCellCol].color = m_cells[playerCellRow, playerCellCol].color;

            m_cells[playerCellRow, playerCellCol].type  = EMKCellType.Empty;
            m_cells[playerCellRow, playerCellCol].color = EMKColor.None;

            playerCellRow = movableCellRow;
            playerCellCol = movableCellCol;
        }
        else if (m_cells[nextMovableCellRow, nextMovableCellCol].type == EMKCellType.Target)
        {
            //The next cell for the movable object is a target
            //Check colors
            EMKColor nextMovableColor = m_cells[nextMovableCellRow, nextMovableCellCol].color;
            EMKColor movableColor     = m_cells[movableCellRow, movableCellCol].color;

            if (nextMovableColor == movableColor)
            {
                //Movable object and target with the same color
                canMove = true;
                DecLevelTargetsLeft();

                MKGame.Instance.GetFurnitureManager().MoveFurniture(
                    movableCellRow, movableCellCol, nextMovableCellRow, nextMovableCellCol);

                m_cells[nextMovableCellRow, nextMovableCellCol].type = EMKCellType.TargetFull;

                EMKCellType currentPlayerType = m_cells[playerCellRow, playerCellCol].type;
                EMKCellType newPlayerType     = (currentPlayerType == EMKCellType.PlayerWithMovable1) ? EMKCellType.Player1 : EMKCellType.Player2;

                MKGame.Instance.GetCharacterManager().OnMovebleInTarget(newPlayerType);

                m_cells[movableCellRow, movableCellCol].type  = newPlayerType;
                m_cells[movableCellRow, movableCellCol].color = m_cells[playerCellRow, playerCellCol].color;

                m_cells[playerCellRow, playerCellCol].type  = EMKCellType.Empty;
                m_cells[playerCellRow, playerCellCol].color = EMKColor.None;

                playerCellRow = movableCellRow;
                playerCellCol = movableCellCol;
            }
        }

        return(canMove);
    }