Beispiel #1
0
        /// <summary>
        /// <see cref="IControlController.HandleUserAction"/>
        /// </summary>
        public void HandleUserAction()
        {
            float width  = Screen.width;
            var   touchs = Input.touches;

            if (touchs.Length != 0)
            {
                if (touchs[0].position.x < width / 3.0f)
                {
                    var delta = _userSlideView.GetBlock().BoundMin.x - _fieldBlock.BoundMin.x;
                    var dist  = Mathf.Min(delta, _slideSpeed);
                    _userSlideView.Move(new Vector2(-dist, 0));
                }
                else if (touchs[0].position.x < width * 2.0f / 3.0f)
                {
                    _isPressStartGame = true;
                }
                else
                {
                    var delta = _fieldBlock.BoundMax.x - _userSlideView.GetBlock().BoundMax.x;
                    var dist  = Mathf.Min(delta, _slideSpeed);
                    _userSlideView.Move(new Vector2(dist, 0));
                }
            }
        }
Beispiel #2
0
        private void AcceptBonus(Bonus bonus)
        {
            switch (bonus.bonusType)
            {
            case BonusType.SPEED:
                if (_gameParams.ballSpeed + _speedBallBonus + bonus.bonusSize > _gameParams.ballSpeedMin)
                {
                    _speedBallBonus += bonus.bonusSize;
                }
                break;

            case BonusType.SPLIT_BALL:
                var mainBall = _gameFieldView.Balls[0];
                var ball     = _gameFieldView.AddBall(mainBall.GetCenter());
                ball.LastMoveDir = mainBall.LastMoveDir * -1;
                break;

            case BonusType.EXPAND_USER_SLIDE:
                _userSlideView.SizeBonus += bonus.bonusSize;
                var block      = _userSlideView.GetBlock();
                var fieldBlock = _gameFieldView.FieldBlock;
                var delta      = 0.0f;
                if (block.BoundMin.x < fieldBlock.BoundMin.x)
                {
                    delta = fieldBlock.BoundMin.x - block.BoundMin.x;
                }
                else if (block.BoundMax.x > fieldBlock.BoundMax.x)
                {
                    delta = fieldBlock.BoundMax.x - block.BoundMax.x;
                }

                _userSlideView.Move(new Vector2(delta, 0));
                break;
            }
        }
 /// <summary>
 /// <see cref="IControlController.HandleUserAction"/>
 /// </summary>
 public void HandleUserAction()
 {
     if (Input.GetKey(KeyCode.A))
     {
         var delta = _userSlideView.GetBlock().BoundMin.x - _fieldBlock.BoundMin.x;
         var dist  = Mathf.Min(delta, _slideSpeed);
         _userSlideView.Move(new Vector2(-dist, 0));
     }
     if (Input.GetKey(KeyCode.D))
     {
         var delta = _fieldBlock.BoundMax.x - _userSlideView.GetBlock().BoundMax.x;
         var dist  = Mathf.Min(delta, _slideSpeed);
         _userSlideView.Move(new Vector2(dist, 0));
     }
     if (Input.GetKey(KeyCode.Space))
     {
         _isPressStartGame = true;
     }
 }