Esempio n. 1
0
        private void GhostMove(Ghost ghost)
        {
            int direction = Direction(ghost);

            Invalidate(ghost.GetFrame());

            // Moves the ghost based on the direction given by the Direction method
            switch (direction)
            {
                case 1:
                    {
                        if (CanGhostMove(Side.left, ghost))
                        {
                            ghost.MoveLeft(ClientRectangle);
                        }
                        Invalidate(ghost.GetFrame());
                        break;

                    }

                case 2:
                    {

                        if (CanGhostMove(Side.right, ghost))
                        {
                            ghost.MoveRight(ClientRectangle);
                        }

                        Invalidate(ghost.GetFrame());
                        break;

                    }

                case 3:
                    {

                        if (CanGhostMove(Side.bottom, ghost))
                        {
                            ghost.MoveDown(ClientRectangle);
                        }
                        Invalidate(ghost.GetFrame());
                        break;

                    }

                case 4:
                    {
                        if (CanGhostMove(Side.top, ghost))
                        {
                            ghost.MoveUp(ClientRectangle);
                        }
                        Invalidate(ghost.GetFrame());
                        break;

                    }
                default:
                    break;

            }
        }