Пример #1
0
        private void SpaceTrick(World world, Platform platform, Player player)
        {
            Clear(squares);
            foreach (Square s in squares)
            {
                s.ChangePos(Direction.DOWN);
            }

            if (!IsHit(squares, world.walls[0]) && !IsHit(squares, platform.platform))
            {
                player.AddScore(2);
                SpaceTrick(world, platform, player);
            }
            else
            {
                foreach (Square s in squares)
                {
                    s.PosUp();
                }
                Draw(squares);
                platform.AddToPlatform(squares);
                moveable = false;
            }
        }
Пример #2
0
        public void Move(List <Square> squares, ConsoleKey key, World world, Platform platform, Player player)
        {
            if (key == ConsoleKey.LeftArrow)
            {
                Clear(squares);
                foreach (Square s in squares)
                {
                    s.ChangePos(Direction.LEFT);
                }

                if (!IsHit(squares, world.walls[1]) && !IsHit(squares, platform.platform))
                {
                    Draw(squares);
                }
                else
                {
                    foreach (Square s in squares)
                    {
                        s.ChangePos(Direction.RIGTH);
                    }
                    Draw(squares);
                }
            }
            else if (key == ConsoleKey.RightArrow)
            {
                Clear(squares);
                foreach (Square s in squares)
                {
                    s.ChangePos(Direction.RIGTH);
                }

                if (!IsHit(squares, world.walls[2]) && !IsHit(squares, platform.platform))
                {
                    Draw(squares);
                }
                else
                {
                    foreach (Square s in squares)
                    {
                        s.ChangePos(Direction.LEFT);
                    }
                    Draw(squares);
                }
            }
            else if (key == ConsoleKey.DownArrow)
            {
                Clear(squares);
                foreach (Square s in squares)
                {
                    s.ChangePos(Direction.DOWN);
                }

                if (!IsHit(squares, world.walls[0]) && !IsHit(squares, platform.platform))
                {
                    Draw(squares);
                }
                else
                {
                    foreach (Square s in squares)
                    {
                        s.PosUp();
                    }
                    Draw(squares);
                    platform.AddToPlatform(squares);
                    moveable = false;
                }

                player.AddScore(1);
            }
            else if (key == ConsoleKey.UpArrow)
            {
                Rotate(ref actualRotatationNumber, world, platform);
            }
            else if (key == ConsoleKey.Spacebar)
            {
                SpaceTrick(world, platform, player);
            }
        }