Beispiel #1
0
//---------------------------------------------------------------
        /// <summary>
        /// Loading main content
        /// </summary>
        public void LoadContent(TGraphicEngine GraphicEngine)
        {
            // Loading content by the engine (same for all programs)
            // In this example, there is no content, we load it manually
            #region LoadContentEngine
            // 1. Загружаем заставку
            // Loading the splash screen
            GameBase.LoadIntro();
            // 2. Загружаем ядро описывающее все данные программы
            // Load the kernel describing all program data
            Content.LoadCore();
            // 3. Загружаем стартовые события игры (там инициализируются события - например примение настроек под конкретную игру, загрузочный экран)
            // We load the starting events of the game (events are initialized there - for example, applying settings for a specific game, loading screen)
            GameBase.LoadEvents(Content);
            // 5. Загружаем настройки пользователей
            // Loading user settings
            //Content.LoadGameOptions("SimpleDraw", "GameOptions");
            // 6. Загружаем стартовую сцену и те бинарные данные которые нужны для нее
            // We load the starting scene and the binary data that is needed for it
            //Content.LoadScene("MainScene");
            //Content.LoadScene("Scene_TestMonoForms");
            Content.LoadScene("");
            // 7. Загружаем стартовую логику игры (там инициализируются логические скрипты)
            // We load the starting logic of the game (logic scripts are initialized there)
            GameBase.LoadLogic(Content);
            #endregion

            // EXAMPLE
            // An example of working with content and data model. All game objects can be created in xml
            // ! Displayed objects are described in the core folder in the content folder (Test.xml)
            // ! Textures and models are in the mods folder in the content folder

            // Referencing created to Test.xml items
            Content["My3DModelObject"].ToModel3D().OnClick_MouseButton             += OnClick_MouseButton;
            Content["My3DTextureAnimatedObject"].ToTexture3D().OnClick_MouseButton += OnClick_MouseButton;

            // Run script for My3DTextureAnimatedObject (it is set in Test.xml, see  )
            Content.Add(new TScript_Test());
        }
//---------------------------------------------------------------
        /// <summary>
        /// Loading main content
        /// </summary>
        public void LoadContent(TGraphicEngine GraphicEngine)
        {
            // Loading content by the engine (same for all programs)
            // In this example, there is no content, we load it manually
            #region LoadContentEngine
            // 1. Загружаем заставку
            // Loading the splash screen
            GameBase.LoadIntro();
            // 2. Загружаем ядро описывающее все данные программы
            // Load the kernel describing all program data
            Content.LoadCore();
            // 3. Загружаем стартовые события игры (там инициализируются события - например примение настроек под конкретную игру, загрузочный экран)
            // We load the starting events of the game (events are initialized there - for example, applying settings for a specific game, loading screen)
            GameBase.LoadEvents(Content);
            // 5. Загружаем настройки пользователей
            // Loading user settings
            //Content.LoadGameOptions("SimpleDraw", "GameOptions");
            // 6. Загружаем стартовую сцену и те бинарные данные которые нужны для нее
            // We load the starting scene and the binary data that is needed for it
            //Content.LoadScene("MainScene");
            //Content.LoadScene("Scene_TestMonoForms");
            Content.LoadScene("");
            // 7. Загружаем стартовую логику игры (там инициализируются логические скрипты)
            // We load the starting logic of the game (logic scripts are initialized there)
            GameBase.LoadLogic(Content);
            #endregion

            // EXAMPLE FOR 3D TEXTURE
            // 1. Create a geometric object (there can be three options - 3D texture, 3D model and sprite)
            TTexture3D Texture3D = new TTexture3D(Content.Game.Render);
            // 2. Load image from file
            Texture3D.LoadTexture(AstraEngine.Engine.ETypeTextures.ColorTexture, TFile.GetCurrentPath() + "\\ImageTest.png");
            // 3. Specifying the position and rotation of the object
            Texture3D.Position = new Vector3(0, 0, -1000);
            Texture3D.Rotation = new Vector3(0, 30, 30);
            // 4. Using the lighting controller and setting the light
            Texture3D.ControlLight.AddDirectionLight(Color.Red, 1.0f, new Vector3(0, 1000, 1000));
            // 5. Bind the click event on the object
            Texture3D.OnClick_MouseButton += OnClick_MouseButton;
            // 6. We add the created geometry object to the universal content part.
            // This is necessary for creating complex programs and universal processing with scripts.
            Content.Add(new TContentPart("ImageTest", Texture3D));
            // Referring to the part recorded in the content by name
            var MyTestTexture3D = Content["ImageTest"];
            // Writing an additional arbitrary variable to a universal object
            MyTestTexture3D.SetData("MyTime", DateTime.Now);
            // Reading back
            var ReturnMyTime = MyTestTexture3D.ToDateTime("MyTime");

            // EXAMPLE FOR 3D MODEL
            // 1. Create a geometric object (there can be three options - 3D texture, 3D model and sprite)
            TModel3D Model3D = new TModel3D(Content.Game.Render);
            // 2. Load model from file
            Model3D.LoadModel(TFile.GetCurrentPath() + "\\ModelTest.fbx");
            // 3. Load color and normal maps
            Model3D.LoadTexture(AstraEngine.Engine.ETypeTextures.ColorTexture, TFile.GetCurrentPath() + "\\DiffuseMap.jpg");
            Model3D.LoadTexture(AstraEngine.Engine.ETypeTextures.NormalTexture, TFile.GetCurrentPath() + "\\NormalMap.jpg");
            // 4. Specifying the position and scale of the object
            Model3D.Position = new Vector3(500, 0, -1000);
            Model3D.Scale    = new Vector3(2, 2, 2);
            // 5. Using the lighting controller and setting the light
            Model3D.ControlLight.SetAmbientLight(Color.White, 0.1f);
            Model3D.ControlLight.AddDirectionLight(Color.White, 0.5f, new Vector3(0, 1000, 1000));
            // 6. Bind the click event on the object
            Model3D.OnClick_MouseButton += OnClick_MouseButton;

            // EXAMPLE FOR 2D SPRITE AND TEXT
            // 1. Create a geometric object (there can be three options - 3D texture, 3D model and sprite)
            TSprite2D Sprite2D = new TSprite2D(Content.Game.Render);
            // 2. Using the font controller, set the font settings
            Sprite2D.ControlFont.SetFont(AstraEngine.Geometry.EFont.Arial, 20);
            Sprite2D.ControlFont.SetColour(Color.Green);
            // 3. Specifying the position of the object
            Sprite2D.Position = new Vector3(0, 0, 0);
            // 4. We add the created geometry object to the universal content part.
            // This is necessary for creating complex programs and universal processing with scripts.
            Content.Add(new TContentPart("MySrite", Sprite2D));
        }