Пример #1
0
        /// <summary>
        /// Query hardware
        /// </summary>
        /// <returns>Hardware configuration</returns>
        public RB.HardwareSettings QueryHardware()
        {
            var hw = new RB.HardwareSettings();

            hw.DisplaySize = new Vector2i(640, 360);

            return(hw);
        }
Пример #2
0
        /// <summary>
        /// Query hardware
        /// </summary>
        /// <returns>Hardware settings</returns>
        public RB.HardwareSettings QueryHardware()
        {
            var hw = new RB.HardwareSettings();

            hw.DisplaySize = new Vector2i(512 / 2, 384 / 2);

            return(hw);
        }
Пример #3
0
        private bool ValidateHWSettings(RB.HardwareSettings hw)
        {
            if (hw.DisplaySize.width <= 0 || hw.DisplaySize.width >= HW_MAX_DISPLAY_DIMENSION || hw.DisplaySize.height <= 0 || hw.DisplaySize.height >= HW_MAX_DISPLAY_DIMENSION)
            {
                Debug.LogError("Display resolution is invalid");
                return(false);
            }

            if (hw.DisplaySize.width % 2 != 0 || hw.DisplaySize.height % 2 != 0)
            {
                Debug.LogError("Display width and height must both be divisible by 2!");
                return(false);
            }

            if (hw.MapSize.width <= 0 || hw.MapSize.height <= 0 || hw.MapLayers <= 0)
            {
                Debug.LogError("Invalid map size");
                return(false);
            }

            if (hw.MapLayers > HW_MAX_MAP_LAYERS)
            {
                Debug.LogError("Maximum map layers cannot exceed " + HW_MAX_MAP_LAYERS);
                return(false);
            }

            if (hw.MapSize.width * hw.MapSize.height * hw.MapLayers > HW_MAX_MAP_TILES)
            {
                Debug.LogError("Maximum map tiles (width * height * layers) cannot exceed " + HW_MAX_MAP_TILES);
                return(false);
            }

            if (hw.MapChunkSize.x < 1 || hw.MapChunkSize.x > 1024)
            {
                Debug.LogError("Map chunk width must be between 1 and 1024");
                return(false);
            }

            if (hw.MapChunkSize.y < 1 || hw.MapChunkSize.y > 1024)
            {
                Debug.LogError("Map chunk height must be between 1 and 1024");
                return(false);
            }

            if (hw.FPS < 20 || hw.FPS > 200)
            {
                Debug.LogError("FPS is invalid, should be between 20 and 200 frames per second");
                return(false);
            }

            if ((int)hw.PixelStyle < (int)RB.PixelStyle.Square || (int)hw.PixelStyle > (int)RB.PixelStyle.Tall)
            {
                Debug.LogError("Pixel style is invalid");
                return(false);
            }

            return(true);
        }
Пример #4
0
    public RB.HardwareSettings QueryHardware()
    {
        RB.HardwareSettings settings = new RB.HardwareSettings();

        settings.DisplaySize = new Vector2i(480, 256);
        //settings.DisplaySize = new Vector2i(480 + 240, 256 + 128);

        return(settings);
    }
Пример #5
0
        /// <summary>
        /// Query hardware
        /// </summary>
        /// <returns>Hardware settings</returns>
        public RB.HardwareSettings QueryHardware()
        {
            var hw = new RB.HardwareSettings();

            hw.MapSize     = new Vector2i(200, 32);
            hw.MapLayers   = 7;
            hw.DisplaySize = new Vector2i(480, 270);

            return(hw);
        }
        /// <summary>
        /// Query hardware. Here you initialize your retro game hardware.
        /// </summary>
        /// <returns>Hardware settings</returns>
        public RB.HardwareSettings QueryHardware()
        {
            var hw = new RB.HardwareSettings();

            // Set your display size
            hw.DisplaySize = new Vector2i(1280 / 2, 720 / 2);

            // Set tilemap maximum size, default is 256, 256. Keep this close to your minimum required size to save on memory
            //// hw.MapSize = new Vector2i(256, 256);

            // Set tilemap maximum layers, default is 8. Keep this close to your minimum required size to save on memory
            //// hw.MapLayers = 8;

            return(hw);
        }
Пример #7
0
        /// <summary>
        /// Initialize the hardware subsystem
        /// </summary>
        /// <param name="hardwareSettings">Hardware settings</param>
        /// <returns>True if successful</returns>
        public bool Initialize(RB.HardwareSettings hardwareSettings)
        {
            if (!ValidateHWSettings(hardwareSettings))
            {
                return(false);
            }

            mDisplaySize = hardwareSettings.DisplaySize;

            mMapSize      = hardwareSettings.MapSize;
            mMapLayers    = hardwareSettings.MapLayers;
            mMapChunkSize = hardwareSettings.MapChunkSize;

            mFPS = hardwareSettings.FPS;
            mSecondsPerUpdate = 1.0f / mFPS;

            mPixelStyle = hardwareSettings.PixelStyle;

            return(true);
        }
Пример #8
0
        /// <summary>
        /// Query hardware. Here you initialize your retro game hardware.
        /// </summary>
        /// <returns>Hardware settings</returns>
        public RB.HardwareSettings QueryHardware()
        {
            var hw = new RB.HardwareSettings();

            int height = 1920;

            if (!UnityEngine.Application.isMobilePlatform)
            {
                height = 1800;
            }

            // Set your display size
            hw.DisplaySize = new Vector2i(1080 / 5, height / 5); // 216 x 360 (216 x 384 mobile)

            // Set tilemap maximum size, default is 256, 256. Keep this close to your minimum required size to save on memory
            //// hw.MapSize = new Vector2i(256, 256);

            // Set tilemap maximum layers, default is 8. Keep this close to your minimum required size to save on memory
            //// hw.MapLayers = 8;

            return(hw);
        }
Пример #9
0
        /// <summary>
        /// Initialize the subsystem wrapper
        /// </summary>
        /// <param name="settings">Hardware settings to initialize with</param>
        /// <returns>True if successful</returns>
        public bool Initialize(RB.HardwareSettings settings)
        {
            var resourceBucketObj = GameObject.Find("ResourceBucket");

            if (resourceBucketObj == null)
            {
                Debug.Log("Can't find ResourceBucket game object");
                return(false);
            }

            ResourceBucket = resourceBucketObj.GetComponent <RetroBlitResourceBucket>();
            if (ResourceBucket == null)
            {
                return(false);
            }

            HW = new RetroBlitHW();
            if (HW == null || !HW.Initialize(settings))
            {
                return(false);
            }

            var cameraObj = GameObject.Find("RetroBlitPixelCamera");

            if (cameraObj == null)
            {
                Debug.Log("Can't find RetroBlitPixelCamera game object");
                return(false);
            }

            PixelCamera = cameraObj.GetComponent <RetroBlitPixelCamera>();
            if (PixelCamera == null || !PixelCamera.Initialize(this))
            {
                return(false);
            }

            Renderer = new RetroBlitRenderer();
            if (Renderer == null || !Renderer.Initialize(this))
            {
                return(false);
            }

            Font = new RetroBlitFont();
            if (Font == null || !Font.Initialize(this))
            {
                return(false);
            }

            Tilemap = new RetroBlitTilemap();
            if (Tilemap == null || !Tilemap.Initialize(this))
            {
                return(false);
            }

            Input = new RetroBlitInput();
            if (Input == null || !Input.Initialize(this))
            {
                return(false);
            }

            var audioObj = GameObject.Find("RetroBlitAudio");

            if (audioObj == null)
            {
                Debug.Log("Can't find RetroBlitAudio game object");
                return(false);
            }

            Audio = audioObj.GetComponent <RetroBlitAudio>();
            if (Audio == null || !Audio.Initialize(this))
            {
                return(false);
            }

            Effects = new RetroBlitEffects();
            if (Effects == null || !Effects.Initialize(this))
            {
                return(false);
            }

            Perf = new RetroBlitPerf();
            if (Perf == null || !Perf.Initialize(this))
            {
                return(false);
            }

            return(true);
        }
Пример #10
0
        /// <summary>
        /// Initialize the subsystem wrapper
        /// </summary>
        /// <param name="settings">Hardware settings to initialize with</param>
        /// <returns>True if successful</returns>
        public bool Initialize(RB.HardwareSettings settings)
        {
            // Store the main thread for later reference
            mainThread = System.Threading.Thread.CurrentThread;

            ResourceBucket = gameObject.GetComponent <RBResourceBucket>();
            if (ResourceBucket == null)
            {
                return(false);
            }

            HW = new RBHardware();
            if (HW == null || !HW.Initialize(settings))
            {
                return(false);
            }

            var pixelCameraObj = GameObject.Find("RetroBlitPixelCamera");

            if (pixelCameraObj == null)
            {
                Debug.Log("Can't find RetroBlitPixelCamera game object, is your RetroBlit scene setup correctly?");
                return(false);
            }

            PixelCamera = pixelCameraObj.GetComponent <RBPixelCamera>();
            if (PixelCamera == null || !PixelCamera.Initialize(this))
            {
                return(false);
            }

            var presentCameraObj = GameObject.Find("RetroBlitPresentCamera");

            if (presentCameraObj == null)
            {
                Debug.Log("Can't find RetroBlitPresentCamera game object, is your RetroBlit scene setup correctly?");
                return(false);
            }

            PresentCamera = presentCameraObj.GetComponent <RBPresentCamera>();
            if (PresentCamera == null || !PresentCamera.Initialize(this))
            {
                return(false);
            }

            AssetManager = new RBAssetManager();
            if (AssetManager == null)
            {
                return(false);
            }

            Renderer = new RBRenderer();
            if (Renderer == null || !Renderer.Initialize(this))
            {
                return(false);
            }

            Font = new RBFont();
            if (Font == null || !Font.Initialize(this))
            {
                return(false);
            }

            Tilemap = new RBTilemapTMX();
            if (Tilemap == null || !Tilemap.Initialize(this))
            {
                return(false);
            }

            Input = new RBInput();
            if (Input == null || !Input.Initialize(this))
            {
                return(false);
            }

            var audioObj = GameObject.Find("RetroBlitAudio");

            if (audioObj == null)
            {
                Debug.Log("Can't find RetroBlitAudio game object");
                return(false);
            }

            Audio = audioObj.GetComponent <RBAudio>();
            if (Audio == null || !Audio.Initialize(this))
            {
                return(false);
            }

            Effects = new RBEffects();
            if (Effects == null || !Effects.Initialize(this))
            {
                return(false);
            }

            Perf = new RBPerf();
            if (Perf == null || !Perf.Initialize(this))
            {
                return(false);
            }

            // Unload all assets that were waiting for main thread to get unloaded. These could be from a previously
            // initialized game.
            AssetManager.UnloadAllMainThread();

            instance = this;

            // Collect garbage
            System.GC.Collect();

            return(true);
        }