예제 #1
0
        public void LoadLoadingScreen(Texture background = null)
        {
            LoadingSymbol = TextureLoader.FileToTexture("assets/textures/LoadingSymbol.jpg");
            bg            = new GameObject("Background");
            if (background == null)
            {
                BlackBG = HoBMenuScene.menubg;
            }
            else
            {
                BlackBG = background;
            }

            UiImageRendererComponent bgImage =
                new UiImageRendererComponent(BlackBG, false, 1, DefaultFilepaths.DefaultUiImageShader);

            bgImage.RenderQueue = -1;
            bg.AddComponent(bgImage);
            bg.AddComponent(new BackgroundMover());
            Add(bg);

            GameObject text            = new GameObject("text");
            GameFont   f               = FontLibrary.LoadFontDirect("assets/fonts/default_font.ttf", 64);
            UiTextRendererComponent tr = new UiTextRendererComponent(f, false, 1, DefaultFilepaths.DefaultUiTextShader);

            text.AddComponent(tr);
            bg.Add(text);
            tr.Text        = "Loading...";
            tr.SystemColor = Color.Black;
            tr.Scale       = Vector2.One * 3;
            tr.RenderQueue = -1;
            tr.Position    = new Vector2(-0.7f, -0.7f);
            loading        = new GameObject("Loading");
            UiImageRendererComponent loadingImage =
                new UiImageRendererComponent(LoadingSymbol, false, 1, DefaultFilepaths.DefaultUiImageShader);

            loadingImage.RenderQueue = -1;
            loading.AddComponent(loadingImage);
            Add(loading);
            float size = 0.05f;

            loadingImage.Position = new Vector2(0.7f, -0.7f);
            loadingImage.Scale    = new Vector2(size, GameEngine.Instance.AspectRatio * size);
            LinearAnimation loadAnim = new LinearAnimation();
            Interpolator    intP     = new Arc2Interpolator();

            loadAnim.Interpolator     = intP;
            loadAnim.StartPos         = loadingImage.Position;
            loadAnim.EndPos           = loadingImage.Position + Vector2.UnitY * 0.1f;
            loadAnim.MaxAnimationTime = 0.5f;
            loadAnim.Trigger          = AnimationTrigger.None;
            loadAnim.AnimationDelay   = 0f;
            Animator anim = new Animator(new List <Animation> {
                loadAnim
            }, loadingImage);

            loading.AddComponent(anim);
            LoopTimer(anim, loadAnim);
            GameObject   obj   = new GameObject("Timer");
            GeneralTimer timer = new GeneralTimer(0.5f, () => LoopTimer(anim, loadAnim), true);

            obj.AddComponent(timer);
            Add(obj);
        }