示例#1
0
    /// <summary>
    ///     Is called every frame that the mouse is over this objects bounding box
    /// </summary>
    void OnMouseOver()
    {
        if (!_enabled)
        {
            return;
        }

        // Left mouse button behaviour
        if (!_revealed && _parent.Controls[EControls.TilePressed].IsActive())
        {
            _leftDown = true;
            TilePress();
        }
        if (_parent.Controls[EControls.TileReleased].IsActive() && _leftDown)
        {
            _parent.OnTileClick(gameObject);
        }

        // Right mouse button behaviour
        if (!_revealed && _parent.Controls[EControls.TileFlagPressed].IsActive())
        {
            _rightDown = true;
        }
        if (_parent.Controls[EControls.TileFlagReleased].IsActive() && _rightDown)
        {
            _parent.OnTileRightClick(gameObject);
        }

        // Middle mouse button behaviour
        if (_revealed && _parent.Controls[EControls.TileSquarePressed].IsActive())
        {
            _middleDown = true;
            foreach (var neighbour in _neighbours.Where(neighbour => !neighbour._flagged && !neighbour._revealed))
            {
                neighbour.TilePress();
            }
        }
        if (_parent.Controls[EControls.TileSquareReleased].IsActive() && _middleDown)
        {
            _parent.OnTileMiddleClick(gameObject);
        }
    }