Esempio n. 1
0
    private void MoveBox(Box.Direction dir)
    {
        if (dir == Direction.Down)
        {
            if (displayPos.y > -4.2)
            {
                displayPos.y -= 1.3f;
            }
        }
        else if (dir == Direction.Up)
        {
            if (displayPos.y < 2.55)
            {
                displayPos.y += 1.3f;
            }
        }
        else if (dir == Direction.Left)
        {
            if (displayPos.x > -3.3)
            {
                displayPos.x -= 1.3f;
            }
        }
        else if (dir == Direction.Right)
        {
            if (displayPos.x < 4.45)
            {
                displayPos.x += 1.3f;
            }
        }

        if (GameController.currentPhase == GameController.Phase.One)
        {
            if (displayPos.x < -3.3)
            {
                displayPos.x = -3.3f;
            }
            else if (displayPos.x > 4.45)
            {
                displayPos.x = 4.45f;
            }
            else if (displayPos.y < -4.2)
            {
                displayPos.y = -4.2f;
            }
            else if (displayPos.y > 2.55)
            {
                displayPos.y = 2.55f;
            }
        }

        UpdatePosition();
    }
Esempio n. 2
0
        /// <summary>
        ///     Spawns a new box
        /// </summary>
        /// <param name="startPosition">The starting position left aligned</param>
        /// <param name="color"></param>
        /// <param name="size">The beginning size of the box</param>
        /// <param name="fallSpeed">^^</param>
        /// <param name="movingDir"></param>
        private void SpawnNewBox(int startPosition, Color color, int size, int fallSpeed, Box.Direction movingDir)
        {
            var box = new Box(color, size, fallSpeed, movingDir);

            box.Button.Click += (_, __) =>
            {
                RemoveBox(box);
                _boxes.Remove(box);
                _score += _scorePerBox;
            };
            _boxes.Add(box);
            Controls.Add(box.Button);

            box.Show(this, startPosition);
        }