Пример #1
0
    private void InitLoadingScreen()
    {
        GameObject loadingScreenGO = GameObject.Instantiate(GameConfig.Instance.m_LoadingScreenPrefab, Vector3.zero, Quaternion.identity);

        m_LoadingScreenComponent = loadingScreenGO.GetComponent <LoadingScreenComponent>();
        GameObject.DontDestroyOnLoad(loadingScreenGO);
    }
Пример #2
0
 public void AddValidComponent(LoadingScreenComponent component)
 {
     if (component)
     {
         component.Parent = this;
         components.Add(component);
     }
 }
Пример #3
0
        private void LoadLevel(string level)
        {
            _loadingEntity = _registry.CreateAbstractEntity();
            var component = new LoadingScreenComponent();

            component.Texture    = Texture.LoadTextureUnsafe(_loadingScreen);
            component.Transform *= Matrix4.CreateScale(1f, 1f, 1);
            component.Transform *= Matrix4.CreateFromAxisAngle(new Vector3(1), 0);
            component.Transform *= Matrix4.CreateTranslation(Application.Width * 3f / 10f, -Application.Height * 3f / 10f, 0);
            _ = _registry.AddSingletonComponent(_loadingEntity, component);
            _registry.AddSystem <LoadingScreenSystem>(World.System.UpdateFlags.Update | World.System.UpdateFlags.Render);

            _loadingScreenCamera = _registry.CreateAbstractEntity();
            _ = _registry.AddSingletonComponent(_loadingScreenCamera, new OrthoCameraComponent(_registry.CachedTransform != Matrix4.Identity ? _registry.CachedTransform : Matrix4.Identity));

            _loadingTask = Scene.LoadSceneAsync(level);

            _registry.ActivateSystems();
        }
Пример #4
0
        protected override void Initialize()
        {
            this.settings = new GameSettings();

            GameSettingsComponent settingsComponent = new GameSettingsComponent(this, settings, graphics);

            this.Components.Add(settingsComponent);

            LoadingScreenComponent loading = new LoadingScreenComponent(this, settings);

            this.Components.Add(loading);

            MenuItemsComponent menuItems = new MenuItemsComponent(
                this,
                settings,
                new Vector2(this.viewport.Width * 0.45f, this.viewport.Height * 0.75f),
                Color.Blue,
                Color.Yellow,
                72
                );

            menuItems.AddItem("Hrát", "new-game");
            menuItems.AddItem("Nastavení", "settings");
            menuItems.AddItem("O høe", "about");
            menuItems.AddItem("Odejít", "exit");

            MenuItemsComponent settingScreenItems = new MenuItemsComponent(
                this,
                settings,
                new Vector2(this.viewport.Width * 0.45f, this.viewport.Height * 0.75f),
                Color.Blue,
                Color.Yellow,
                72
                );

            settingScreenItems.AddItem("Postava", "player-sprite");
            settingScreenItems.AddItem("Hudba", "music-enabled");
            settingScreenItems.AddItem("Zpìt do menu", "back");

            ScrollingBackgroundComponent scrollingBackground = new ScrollingBackgroundComponent(this, settings);

            this.Components.Add(scrollingBackground);

            GameSettingsScreenComponent settingsScreenComponent = new GameSettingsScreenComponent(this, settings, settingScreenItems);

            this.Components.Add(settingsScreenComponent);

            AboutScreenComponent aboutScreenComponent = new AboutScreenComponent(this, settings);

            this.Components.Add(aboutScreenComponent);

            MenuComponent menu = new MenuComponent(this, settings, menuItems);

            this.Components.Add(menu);

            LevelComponent level = new LevelComponent(this, settings, scrollingBackground);

            this.Components.Add(level);

            this.loadingScreen  = new GameWindow(this, loading);
            this.menuWindow     = new GameWindow(this, menu, menuItems, settingsComponent, scrollingBackground);
            this.ingameWindow   = new GameWindow(this, level, settingsComponent, scrollingBackground);
            this.settingsScreen = new GameWindow(this, settingsScreenComponent, settingScreenItems, settingsComponent, scrollingBackground);
            this.aboutScreen    = new GameWindow(this, settingsComponent, scrollingBackground, aboutScreenComponent);

            foreach (GameComponent component in this.Components)
            {
                this.SwitchComponent(component, false);
            }

            // BASE GRAPHICS STUFF
            this.IsMouseVisible = false;
            //this.graphics.IsFullScreen = true;
            this.graphics.PreferredBackBufferHeight = 720;
            this.graphics.PreferredBackBufferWidth  = 1280;
            this.graphics.ApplyChanges();

            this.SwitchWindows(loadingScreen);

            base.Initialize();
        }