Ejemplo n.º 1
0
        /// <summary>
        /// 初期化を行う。
        /// </summary>
        /// <param name="title">タイトル</param>
        /// <param name="width">横幅</param>
        /// <param name="height">縦幅</param>
        /// <param name="option">オプション</param>
        /// <returns>成否</returns>
        public static bool Initialize(string title, int width, int height, EngineOption option)
        {
            if (core != null)
            {
                return(false);
            }

            //if (!CheckDLL()) return false;

            try
            {
                core = swig.Core_Imp.CreateCore();
            }
            catch (System.TypeInitializationException)
            {
                // DLLが見つからないケース
                return(false);
            }

            var result = core.Initialize(title, width, height, option.IsFullScreen, option.GraphicsType == GraphicsType.OpenGL, option.IsMultithreadingMode);

            if (result)
            {
                GC.Initialize();
                SetupMembers();
                return(true);
            }
            else
            {
                core.Release();
                core = null;
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 終了処理を行う。
        /// </summary>
        public static void Terminate()
        {
            if (core == null)
            {
                return;
            }

            CurrentScene = null;

            GC.Terminate();

            core.Terminate();
            core.Release();
            core = null;

            Mouse = null;

            var refCount = swig.ace_core_cs.GetGlobalReferenceCount__();

            if (refCount > 0)
            {
                //Console.WriteLine("未開放のインスタンスが{0}個存在します。", refCount);
                throw new Exception(string.Format("未開放のインスタンスが{0}個存在します。", refCount));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 終了処理を行う。
        /// </summary>
        public static void Terminate()
        {
            if (core == null)
            {
                return;
            }

            if (CurrentScene != null)
            {
                CurrentScene.Dispose();
            }

            if (nextScene != null)
            {
                nextScene.Dispose();
            }

            if (previousScene != null)
            {
                previousScene.Dispose();
            }


            CurrentScene  = null;
            nextScene     = null;
            previousScene = null;
            transition    = null;

            GC.Terminate();

            core.Terminate();
            core.Release();
            core = null;

            Mouse = null;

            var refCount = swig.asd_core.GetGlobalReferenceCount__();

            if (refCount > 0)
            {
                Particular.Helper.ThrowUnreleasedInstanceException(refCount);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 外部ウインドウにゲーム画面を表示する初期化を行う。
        /// </summary>
        /// <param name="handle1">ハンドル1</param>
        /// <param name="handle2">ハンドル2</param>
        /// <param name="width">横幅</param>
        /// <param name="height">縦幅</param>
        /// <param name="option">オプション</param>
        /// <returns>成否</returns>
        public static bool InitializeByExternalWindow(IntPtr handle1, IntPtr handle2, int width, int height, EngineOption option)
        {
            if (core != null)
            {
                return(false);
            }

            if (!CheckDLL())
            {
                return(false);
            }

            try
            {
                core = swig.Core_Imp.CreateCore();
            }
            catch (System.TypeInitializationException)
            {
                // DLLが見つからないケース
                return(false);
            }

            var result = core.InitializeByExternalWindow(handle1, handle2, width, height, option.GraphicsType == GraphicsType.OpenGL, option.IsMultithreadingMode);

            if (result)
            {
                GC.Initialize();
                SetupMembers();
                return(true);
            }
            else
            {
                core.Release();
                core = null;
                return(false);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 終了処理を行う。
        /// </summary>
        public static void Terminate()
        {
            if(core == null) return;

            if(CurrentScene != null)
            {
                CurrentScene.CallDestroy();
            }

            if(nextScene != null)
            {
                nextScene.CallDestroy();
            }

            if(previousScene != null)
            {
                previousScene.CallDestroy();
            }

            CurrentScene = null;
            nextScene = null;
            previousScene = null;
            transition = null;

            GC.Terminate();

            core.Terminate();
            core.Release();
            core = null;

            Mouse = null;

            var refCount = swig.asd_core.GetGlobalReferenceCount__();

            if(refCount > 0)
            {
                Particular.Helper.ThrowUnreleasedInstanceException(refCount);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 外部ウインドウにゲーム画面を表示する初期化を行う。
        /// </summary>
        /// <param name="handle1">ハンドル1</param>
        /// <param name="handle2">ハンドル2</param>
        /// <param name="width">横幅</param>
        /// <param name="height">縦幅</param>
        /// <param name="option">オプション</param>
        /// <returns>成否</returns>
        public static bool InitializeByExternalWindow(IntPtr handle1, IntPtr handle2, int width, int height, EngineOption option)
        {
            if(core != null) return false;

            if(!Particular.Helper.CheckInitialize()) return false;

            core = Particular.Helper.CreateCore();
            if (core == null) return false;

            var graphicsType = option.GraphicsDevice;
            if(graphicsType == GraphicsDeviceType.Default)
            {
                graphicsType = Particular.Helper.GetDefaultDevice();
            }

            var coreOption = new swig.CoreOption();
            coreOption.GraphicsDevice = (swig.GraphicsDeviceType)graphicsType;
            coreOption.IsFullScreen = option.IsFullScreen;
            coreOption.IsReloadingEnabled = option.IsReloadingEnabled;

            var result = core.InitializeByExternalWindow(handle1, handle2, width, height, coreOption);

            if(result)
            {
                GC.Initialize();
                SetupMembers();

                if(option.AutoGeneratedLayer == AutoGeneratedLayerType.Layer2D)
                {
                    var scene = new Scene();
                    var layer = new Layer2D();
                    scene.AddLayer(layer);
                    ChangeScene(scene);
                }
                else if(option.AutoGeneratedLayer == AutoGeneratedLayerType.Layer3D)
                {
                    var scene = new Scene();
                    var layer = new Layer3D();
                    scene.AddLayer(layer);
                    ChangeScene(scene);
                }

                return true;
            }
            else
            {
                core.Release();
                core = null;
                return false;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 外部ウインドウにゲーム画面を表示する初期化を行う。
        /// </summary>
        /// <param name="handle1">ハンドル1</param>
        /// <param name="handle2">ハンドル2</param>
        /// <param name="width">横幅</param>
        /// <param name="height">縦幅</param>
        /// <param name="option">オプション</param>
        /// <returns>成否</returns>
        public static bool InitializeByExternalWindow(IntPtr handle1, IntPtr handle2, int width, int height, EngineOption option)
        {
            if (core != null)
            {
                return(false);
            }

            if (!Particular.Helper.CheckInitialize())
            {
                return(false);
            }

            core = Particular.Helper.CreateCore();
            if (core == null)
            {
                return(false);
            }


            var graphicsType = option.GraphicsDevice;

            if (graphicsType == GraphicsDeviceType.Default)
            {
                graphicsType = Particular.Helper.GetDefaultDevice();
            }

            var coreOption = new swig.CoreOption();

            coreOption.GraphicsDevice     = (swig.GraphicsDeviceType)graphicsType;
            coreOption.IsFullScreen       = option.IsFullScreen;
            coreOption.WindowPosition     = (swig.WindowPositionType)option.WindowPosition;
            coreOption.IsWindowResizable  = option.IsWindowResizable;
            coreOption.IsReloadingEnabled = option.IsReloadingEnabled;
            coreOption.ColorSpace         = (swig.ColorSpaceType)option.ColorSpace;

            var result = core.InitializeByExternalWindow(handle1, handle2, width, height, coreOption);

            if (result)
            {
                GC.Initialize();
                SetupMembers();

                if (option.AutoGeneratedLayer == AutoGeneratedLayerType.Layer2D)
                {
                    var scene = new Scene();
                    var layer = new Layer2D();
                    scene.AddLayer(layer);
                    ChangeScene(scene, true);
                }
                else if (option.AutoGeneratedLayer == AutoGeneratedLayerType.Layer3D)
                {
                    var scene = new Scene();
                    var layer = new Layer3D(null);
                    scene.AddLayer(layer);
                    ChangeScene(scene, true);
                }

                CommitChanges();
                transitionState.Proceed();

                return(true);
            }
            else
            {
                core.Release();
                core = null;
                return(false);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 初期化を行う。
        /// </summary>
        /// <param name="title">タイトル</param>
        /// <param name="width">横幅</param>
        /// <param name="height">縦幅</param>
        /// <param name="option">オプション</param>
        /// <returns>成否</returns>
        public static bool Initialize(string title, int width, int height, EngineOption option)
        {
            if (core != null)
            {
                return(false);
            }

            if (!Particular.Helper.CheckInitialize())
            {
                return(false);
            }

            core = Particular.Helper.CreateCore();
            if (core == null)
            {
                return(false);
            }

            var graphicsType = option.GraphicsDevice;

            if (graphicsType == GraphicsDeviceType.Default)
            {
                graphicsType = Particular.Helper.GetDefaultDevice();
            }

            var coreOption = new swig.CoreOption();

            coreOption.GraphicsDevice     = (swig.GraphicsDeviceType)graphicsType;
            coreOption.IsFullScreen       = option.IsFullScreen;
            coreOption.WindowPosition     = (swig.WindowPositionType)option.WindowPosition;
            coreOption.IsReloadingEnabled = option.IsReloadingEnabled;

            var result = core.Initialize(title, width, height, coreOption);

            if (result)
            {
                GC.Initialize();
                SetupMembers();

                if (option.AutoGeneratedLayer == AutoGeneratedLayerType.Layer2D)
                {
                    var scene = new Scene();
                    var layer = new Layer2D();
                    scene.AddLayer(layer);
                    ChangeScene(scene);
                }
                else if (option.AutoGeneratedLayer == AutoGeneratedLayerType.Layer3D)
                {
                    var scene = new Scene();
                    var layer = new Layer3D();
                    scene.AddLayer(layer);
                    ChangeScene(scene);
                }

                return(true);
            }
            else
            {
                core.Release();
                core = null;
                return(false);
            }
        }