示例#1
0
        private void OnSceneLoad_Test()
        {
            //ResourceManager.LoadResource<string, TextLoadingParameters>("res_str_test_0", new TextLoadingParameters(new[] { "res_str_test_0.txt" }, Encoding.UTF8), 1, false);
            //if (!ResourceManager.TryGetResource("res_str_test_0", out string str, true))
            //    Log.WriteLine("Could not get resource 'res_str_test_0'", LogType.Message);

            ResourceManager.LoadResource <ITexture, TextureLoadingParameters>("res_tex_test_0", new TextureLoadingParameters(new[] { "res_tex_test_0.png" }, TextureWrapMode.ClampToEdge, TextureFilterMode.Nearest), 2, false);
            ResourceManager.LoadResource <ITexture, TextureLoadingParameters>("res_tex_test_1", new TextureLoadingParameters(new[] { "res_tex_test_1.png" }, TextureWrapMode.ClampToEdge, TextureFilterMode.Nearest), 2, false);
            ResourceManager.LoadResource <ITexture, TextureLoadingParameters>("res_tex_test_2", new TextureLoadingParameters(new[] { "res_tex_micha.png" }, TextureWrapMode.ClampToEdge, TextureFilterMode.Nearest), 2, false);
            ResourceManager.LoadResource <ITextureAtlas, FontLoadingParameters>($"font_Consolas_16", new FontLoadingParameters(new FontFamily("Consolas"), 16), 0, true);

            if (!ResourceManager.TryGetResource("res_tex_test_0", out ITexture tex0, true))
            {
                Log.WriteLine("Could not get resource 'res_tex_test_0'", LogType.Message);
            }

            if (!ResourceManager.TryGetResource("res_tex_test_1", out ITexture tex1, true))
            {
                Log.WriteLine("Could not get resource 'res_tex_test_1'", LogType.Message);
            }

            if (!ResourceManager.TryGetResource("res_tex_test_2", out ITexture tex2, true))
            {
                Log.WriteLine("Could not get resource 'res_tex_test_2'", LogType.Message);
            }

            IGameObject go_viewport = Scene.CreateGameObject("go_viewport");
            Viewport    viewport    = go_viewport.AddComponent <Viewport>();

            //viewport.Transform.Position = new Vector2(1, 0);
            Scene.MainViewport = viewport;
            viewport.Zoom      = 1;
            //viewport.Width *= 10f;
            //viewport.Height *= 10f;
            //viewport.Transform.Position.x += 1;
            GUIHandler guiHandler = go_viewport.AddComponent <GUIHandler>();

            ResourceManager.TryGetResource("internal_circleShader", out IShader shader, true);

            //IGameObject go_sprite = Scene.CreateGameObject("go_sprite");
            //go_sprite.Transform.Z = 0.65f;
            //Sprite sprite = go_sprite.AddComponent<Sprite>();
            //sprite.Transform.Scale = new Vector2(0.95f, 0.95f);
            //sprite.Color = new Color(255, 0, 255, 63);

            IGameObject go_cSprite = Scene.CreateGameObject("go_cSprite");

            go_cSprite.Transform.Z = 0.65f;

            // uniforms
            Color cSpriteColor = Color.WHITE;
            float innerRadius  = 0.1f;
            float startAngle   = 0.0f;
            float sweepAngle   = 1f;

            // vertex attributes
            (VertexAttribute va, float[][] data)[] vertexAttributes =
示例#2
0
        private void OnSceneLoad_CellularAutomata()
        {
            IGameObject go_viewport = Scene.CreateGameObject("go_viewport");
            Viewport    viewport    = go_viewport.AddComponent <Viewport>();

            Scene.MainViewport = viewport;
            GUIHandler guiHandler = go_viewport.AddComponent <GUIHandler>();

            IGameObject gO_cellularAutomata = Scene.CreateGameObject("gO_cellularAutomata");
            ForestFire  forestFire          = gO_cellularAutomata.AddComponent <ForestFire>(new CellularAutomataInitializationData(2, 100, true, NeighbourhoodMode.Moore));

            gO_cellularAutomata.Transform.Position.x -= (viewport.Width - 1) / 2f;

            IGameObject gO_pieChart = Scene.CreateGameObject("go_pieChart");
            PieChart    pieChart    = gO_pieChart.AddComponent <PieChart>(forestFire);

            gO_pieChart.Transform.Scale       = new Vector2(0.25f, 0.25f);
            gO_pieChart.Transform.Position.x += 0.25f;
        }