示例#1
0
 public void OnMovebleInTarget(EMKCellType eMKPlayerNumber)
 {
     if (eMKPlayerNumber == EMKCellType.Player1)
     {
         player1.ObjectPlacedInRightPlace();
     }
     else
     {
         player2.ObjectPlacedInRightPlace();
     }
     MKAudioManager.Instance.m_boxInPlace.GetComponent <AudioSource>().Play();
 }
示例#2
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);
    }
示例#3
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];
 }
示例#4
0
    /*********************************************************
    * Move
    *********************************************************/
    public bool MoveToCell(ref uint currentCellRow, ref uint currentCellCol, EMKMove move)
    {
        EMKCellType currentCellType = m_cells[currentCellRow, currentCellCol].type;

        //Players
        if (IsCellTypePlayer(currentCellType))
        {
            return(CanMovePlayerToCell(ref currentCellRow, ref currentCellCol, move));
        }

        //Players with a movable object
        if (IsCellTypePlayerWithMovable(currentCellType))
        {
            Vector2 nextCell    = GetNextLogicPosition(currentCellRow, currentCellCol, move);
            uint    nextCellRow = (uint)nextCell.x;
            uint    nextCellCol = (uint)nextCell.y;

            bool nextCellMovable = true;

            if (nextCellRow == currentCellRow && nextCellCol == currentCellCol)
            {
                nextCellMovable = false; //Grid limits
            }
            else if (m_cells[nextCellRow, nextCellCol].type != EMKCellType.Movable)
            {
                nextCellMovable = false; //Next cell is not the movable object related to the player
            }

            if (nextCellMovable)
            {
                //The player is pushing the movable object
                return(CanMoveMovableToNextCell(ref currentCellRow, ref currentCellCol, move));
            }
            else
            {
                //The player is pulling the movable object
                return(CanMovePlayerWithMovableToNextCell(ref currentCellRow, ref currentCellCol, move));
            }
        }

        //Only players can move
        return(false);
    }
示例#5
0
    /*********************************************************
    * Interact
    *********************************************************/
    public bool InteractWithCell(uint currentCellRow, uint currentCellCol, EMKMove move)
    {
        EMKCellType currentCellType = m_cells[currentCellRow, currentCellCol].type;

        //Players
        if (IsCellTypePlayer(currentCellType))
        {
            return(CanPlayerInteractWithCell(currentCellRow, currentCellCol, move));
        }

        //Players with a movable object
        if (IsCellTypePlayerWithMovable(currentCellType))
        {
            EMKCellType typePlayer = (currentCellType == EMKCellType.PlayerWithMovable1) ? EMKCellType.Player1 : EMKCellType.Player2;
            m_cells[currentCellRow, currentCellCol].type = typePlayer;
            return(true);
        }

        //Only players can interact
        return(false);
    }
示例#6
0
    protected bool CanPlayerInteractWithCell(uint currentCellRow, uint currentCellCol, EMKMove move)
    {
        Vector2 nextCell   = GetNextLogicPosition(currentCellRow, currentCellCol, move);
        uint    objCellRow = (uint)nextCell.x;
        uint    objCellCol = (uint)nextCell.y;

        //Grid limits
        if (objCellRow == currentCellRow && objCellCol == currentCellCol)
        {
            return(false);
        }

        EMKCellType objCellType = m_cells[objCellRow, objCellCol].type;

        //The objective cell is not a Movable object or a Button
        if (objCellType != EMKCellType.Movable && objCellType != EMKCellType.Button)
        {
            return(false);
        }

        if (objCellType == EMKCellType.Movable)
        {
            //The objective cell is a Movable object
            EMKCellType currentCellType = m_cells[currentCellRow, currentCellCol].type;
            EMKCellType typePlayer      = (currentCellType == EMKCellType.Player1) ? EMKCellType.PlayerWithMovable1 : EMKCellType.PlayerWithMovable2;
            m_cells[currentCellRow, currentCellCol].type = typePlayer;
        }
        else if (objCellType == EMKCellType.Button)
        {
            //The objective cell is a Button (actually, is THE button, we assume there is only one)
            if (MKGame.Instance.GetFurnitureManager().PressButton() == true)
            {
                MKGame.Instance.GetCharacterManager().ChangePowers();
                MKGame.Instance.GetUIManager().ChangePowersIU();
            }
        }

        return(true);
    }
示例#7
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);
    }
示例#8
0
 protected bool IsCellTypePlayerWithMovable(EMKCellType cellType)
 {
     return(cellType == EMKCellType.PlayerWithMovable1 || cellType == EMKCellType.PlayerWithMovable2);
 }
示例#9
0
 protected bool IsCellTypePlayer(EMKCellType cellType)
 {
     return(cellType == EMKCellType.Player1 || cellType == EMKCellType.Player2);
 }
示例#10
0
 protected bool CanPlaceInCell(uint row, uint col, EMKCellType type)
 {
     return(m_cells[row, col].type == EMKCellType.Empty);
 }
示例#11
0
    void ProcessCharacterGrab()
    {
        if (bIsMoving)
        {
            return;
        }

        Vector2 nextLogicPosition = MKGame.Instance.GetGameManager().GetNextLogicPosition(
            m_CharacterIndexPositionX, m_CharacterIndexPositionY, GetMoveFromFacing());

        EMKCellType cellType = MKGame.Instance.GetGameManager().GetCellType((uint)nextLogicPosition.x, (uint)nextLogicPosition.y);

        if (cellType != EMKCellType.Button && !CanMoveObjectInThisDirection(transform.forward))
        {
            return;
        }

        // Check if the player wants to perform a grab
        if (m_PlayerNumber == EMKPlayerNumber.Player1 && Input.GetButtonDown("Grab1"))
        {
            if (MKGame.Instance.GetGameManager().InteractWithCell(m_CharacterIndexPositionX, m_CharacterIndexPositionY, GetMoveFromFacing()))
            {
                Debug.Log("Suscceful grab or drop player 1");
                if (currentColorController != null)
                {
                    grabbingObject = !grabbingObject;
                    if (grabbingObject)
                    {
                        PlayPush();
                    }
                    else
                    {
                        PlayIlde();
                    }
                    currentColorController.ToogleGrabFeedBack();
                    MKAudioManager.Instance.m_grabbingstuf.GetComponent <AudioSource>().Play();
                }
                else
                {
                    Debug.Log("currentColorController is null");
                }
            }
        }
        else if (m_PlayerNumber == EMKPlayerNumber.Player2 && Input.GetButtonDown("Grab2"))
        {
            if (MKGame.Instance.GetGameManager().InteractWithCell(m_CharacterIndexPositionX, m_CharacterIndexPositionY, GetMoveFromFacing()))
            {
                Debug.Log("Suscceful grab or drop player 2");
                if (currentColorController != null)
                {
                    grabbingObject = !grabbingObject;
                    if (grabbingObject)
                    {
                        PlayPush();
                    }
                    else
                    {
                        PlayIlde();
                    }
                    currentColorController.ToogleGrabFeedBack();
                    MKAudioManager.Instance.m_grabbingstuf.GetComponent <AudioSource>().Play();
                }
                else
                {
                    Debug.Log("currentColorController is null");
                }
            }
        }
    }