Example #1
0
        /// <summary>
        /// Switches the selected block if the user scrolls.
        /// </summary>
        private void SwitchBlock()
        {
            SetGhostBlockVisibility(false);

            float scroll = InputUtil.GetScrollWheel();

            if (scroll != 0)
            {
                if (scroll < 0)
                {
                    _selectedBlock++;
                    if ((int)_selectedBlock >= numBlockTypes)
                    {
                        _selectedBlock--;
                    }
                }
                else
                {
                    _selectedBlock--;
                    if (_selectedBlock < 0)
                    {
                        _selectedBlock = 0;
                    }
                }
            }
            else if (Input.GetButtonDown("Fire3"))
            {
                _selectedBlock++;
                if ((int)_selectedBlock >= numBlockTypes)
                {
                    _selectedBlock = 0;
                }
            }
            else
            {
                for (KeyCode key = KeyCode.Alpha1; key <= keyLimit; key++)
                {
                    if (InputUtil.GetKeyDown(key))
                    {
                        _selectedBlock = (BlockType)(key - KeyCode.Alpha1);
                    }
                }
            }
        }