Example #1
0
        private void ChangeCameraPosition(float xOffset, float yOffset)
        {
            if (xOffset != 0)
            {
                if (yOffset != 0)
                {
                    XYCameraPosition cameraPosition = _gameValueService.GetXYCameraPosition();

                    float newXPosition = cameraPosition.XPosition + xOffset;
                    float newYPosition = cameraPosition.YPosition + yOffset;

                    _gameValueService.SetCameraPosition(newXPosition, newYPosition);
                }
                else
                {
                    float xCameraPosition = _gameValueService.GetXCameraPosition();
                    _gameValueService.SetXCameraPosition(xCameraPosition + xOffset);
                }
            }
            else if (yOffset != 0)
            {
                float yCameraPosition = _gameValueService.GetYCameraPosition();
                _gameValueService.SetYCameraPosition(yCameraPosition + yOffset);
            }
        }
        /// <inheritdoc/>>
        public XYCameraPosition GetXYCameraPosition()
        {
            const int bytesToRead    = sizeof(float) * 2;
            int       xCameraAddress = _addressFinder.GetXCameraAddress();
            var       bytes          = _processFunctionsService.ReadMemoryBytes(_processHandle, xCameraAddress, bytesToRead);

            var result = new XYCameraPosition
                         (
                BitConverter.ToSingle(bytes, 0),
                BitConverter.ToSingle(bytes, sizeof(float))
                         );

            return(result);
        }