コード例 #1
0
ファイル: SplashScreen.cs プロジェクト: Kairna/TouchAndPlay
        public override void Update()
        {
            base.UpdateComponents();

            switch (currentState)
            {
                case SplashScreenState.FADING_IN:
                    logoAlpha += 0.01f;
                    if (logoAlpha >= 1.0f)
                    {
                        currentState = SplashScreenState.SHOWING;
                    }
                    break;
                case SplashScreenState.SHOWING:
                    logoStayingDuration -= 1;
                    if (logoStayingDuration <= 0)
                    {
                        currentState = SplashScreenState.FADING_OUT;
                    }
                    break;
                case SplashScreenState.FADING_OUT:
                    logoAlpha -= .01f;
                    if (logoAlpha <= 0f)
                    {
                        currentState = SplashScreenState.GOTO_NEXT_SCREEN;
                        base.transitionState = BasicScreenState.TRANSITION_OUT;
                    }
                    break;
            }
        }
コード例 #2
0
        public MenuResult Update(GameTime gameTime)
        {
            if (state == SplashScreenState.FADE && animateTime == 0)
            {
                MediaPlayer.Play(MusicControl.music_menu);
            }

            cooldown -= gameTime.ElapsedGameTime.Milliseconds;
            if (cooldown < 0)
            {
                cooldown = 0;
            }
            animateTime += gameTime.ElapsedGameTime.Milliseconds;
            PlayerIndex controllingPlayer = Game.playerIndex;

            if (state == SplashScreenState.FADE && animateTime > maxAnimateTime)
            {
                state       = SplashScreenState.READY;
                animateTime = maxAnimateTime;
            }
            if (state == SplashScreenState.SLIDE && animateTime > maxAnimateTime)
            {
                animateTime = maxAnimateTime;
                state       = SplashScreenState.WAIT;
                return(MenuResult.GoToMainMenu);
            }
            if (state == SplashScreenState.WAIT && this.stillActive == true)
            {
                stillActive = false;
                return(MenuResult.GoToMainMenu);
            }
            if (state == SplashScreenState.READY)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Space))
                {
                    Game.playerIndex = PlayerIndex.One;
                    state            = SplashScreenState.SLIDE;
                    animateTime      = 0;
                }
                for (PlayerIndex index = Game.playerIndex; index <= PlayerIndex.Four; index++)
                {
                    if (GamePad.GetState(index).Buttons.Start == ButtonState.Pressed)
                    {
                        Game.playerIndex = index;
                        state            = SplashScreenState.SLIDE;
                        animateTime      = 0;
                        break;
                    }
                }
            }

            return(MenuResult.None);
        }
コード例 #3
0
ファイル: SceneSystem.cs プロジェクト: Alan-love/xenko
        protected override void LoadContent()
        {
            var content         = Services.GetSafeServiceAs <ContentManager>();
            var graphicsContext = Services.GetSafeServiceAs <GraphicsContext>();

            if (SplashScreenUrl != null && content.Exists(SplashScreenUrl))
            {
                splashScreenTexture = content.Load <Texture>(SplashScreenUrl, ContentManagerLoaderSettings.StreamingDisabled);
                splashScreenState   = splashScreenTexture != null ? SplashScreenState.Intro : SplashScreenState.Invalid;
                SplashScreenEnabled = true;
            }

            // Preload the scene if it exists and show splash screen
            if (InitialSceneUrl != null && content.Exists(InitialSceneUrl))
            {
                if (SplashScreenEnabled)
                {
                    sceneTask = content.LoadAsync <Scene>(InitialSceneUrl);
                }
                else
                {
                    SceneInstance = new SceneInstance(Services, content.Load <Scene>(InitialSceneUrl));
                }
            }
            else
            {
                SceneInstance ??= new SceneInstance(Services)
                {
                    RootScene = new Scene()
                };
            }

            if (InitialGraphicsCompositorUrl != null && content.Exists(InitialGraphicsCompositorUrl))
            {
                if (SplashScreenEnabled)
                {
                    compositorTask = content.LoadAsync <GraphicsCompositor>(InitialGraphicsCompositorUrl);
                }
                else
                {
                    GraphicsCompositor = content.Load <GraphicsCompositor>(InitialGraphicsCompositorUrl);
                }
            }

            // Create the drawing context
            renderContext     = RenderContext.GetShared(Services);
            renderDrawContext = new RenderDrawContext(Services, renderContext, graphicsContext);
        }
コード例 #4
0
    private void OnGUI()
    {
        if (!Permission.HasUserAuthorizedPermission(Permission.Microphone))  // permissions not granted:
        {
            splashScreenState = SplashScreenState.PermissionsDenied;
            Color currColor = PermissionsWaitText.color;
            currColor.a = 0;
            PermissionsWaitText.color = currColor;

            currColor   = PermissionsDeniedText.color;
            currColor.a = 1;
            PermissionsDeniedText.color = currColor;
        }
        else  // permissions granted:
        {
            splashScreenState = SplashScreenState.DisplayIntroduction;
            hasPermissions    = true;
        }
    }
コード例 #5
0
ファイル: SceneSystem.cs プロジェクト: Alan-love/xenko
        public override void Draw(GameTime gameTime)
        {
            // Reset the context
            renderContext.Reset();

            var renderTarget = renderDrawContext.CommandList.RenderTarget;

            // If the width or height changed, we have to recycle all temporary allocated resources.
            // NOTE: We assume that they are mostly resolution dependent.
            if (previousWidth != renderTarget.ViewWidth || previousHeight != renderTarget.ViewHeight)
            {
                // Force a recycle of all allocated temporary textures
                renderContext.Allocator.Recycle(link => true);
            }

            previousWidth  = renderTarget.ViewWidth;
            previousHeight = renderTarget.ViewHeight;

            // Update the entities at draw time.
            renderContext.Time = gameTime;

            // The camera processor needs the graphics compositor
            using (renderContext.PushTagAndRestore(GraphicsCompositor.Current, GraphicsCompositor))
            {
                // Execute Draw step of SceneInstance
                // This will run entity processors
                SceneInstance?.Draw(renderContext);
            }

            // Render phase
            // TODO GRAPHICS REFACTOR
            //context.GraphicsDevice.Parameters.Set(GlobalKeys.Time, (float)gameTime.Total.TotalSeconds);
            //context.GraphicsDevice.Parameters.Set(GlobalKeys.TimeStep, (float)gameTime.Elapsed.TotalSeconds);

            renderDrawContext.ResourceGroupAllocator.Flush();
            renderDrawContext.QueryManager.Flush();

            // Push context (pop after using)
            using (renderDrawContext.RenderContext.PushTagAndRestore(SceneInstance.Current, SceneInstance))
            {
                GraphicsCompositor?.Draw(renderDrawContext);
            }

            //do this here, make sure GCompositor and Scene are updated/rendered the next frame!
            if (sceneTask != null && compositorTask != null)
            {
                switch (splashScreenState)
                {
                case SplashScreenState.Invalid:
                {
                    if (sceneTask.IsCompleted && compositorTask.IsCompleted)
                    {
                        SceneInstance      = new SceneInstance(Services, sceneTask.Result);
                        GraphicsCompositor = compositorTask.Result;
                        sceneTask          = null;
                        compositorTask     = null;
                    }
                    break;
                }

                case SplashScreenState.Intro:
                {
                    Game.GraphicsContext.CommandList.Clear(Game.GraphicsContext.CommandList.RenderTarget, SplashScreenColor);

                    if (gameTime.Total.TotalSeconds > SplashScreenFadeTime)
                    {
                        splashScreenState = SplashScreenState.FadingIn;
                        fadeTime          = 0.0f;
                    }
                    break;
                }

                case SplashScreenState.FadingIn:
                {
                    var color  = Color4.White;
                    var factor = MathUtil.SmoothStep((float)fadeTime / SplashScreenFadeTime);
                    color *= factor;
                    if (factor >= 1.0f)
                    {
                        splashScreenState = SplashScreenState.Showing;
                    }

                    fadeTime += gameTime.Elapsed.TotalSeconds;

                    RenderSplashScreen(color, BlendStates.AlphaBlend);
                    break;
                }

                case SplashScreenState.Showing:
                {
                    RenderSplashScreen(Color4.White, BlendStates.Default);

                    if (gameTime.Total.TotalSeconds > MinSplashScreenTime && sceneTask.IsCompleted && compositorTask.IsCompleted)
                    {
                        splashScreenState = SplashScreenState.FadingOut;
                        fadeTime          = 0.0f;
                    }
                    break;
                }

                case SplashScreenState.FadingOut:
                {
                    var color  = Color4.White;
                    var factor = (MathUtil.SmoothStep((float)fadeTime / SplashScreenFadeTime) * -1) + 1;
                    color *= factor;
                    if (factor <= 0.0f)
                    {
                        splashScreenState = SplashScreenState.Invalid;
                    }

                    fadeTime += gameTime.Elapsed.TotalSeconds;

                    RenderSplashScreen(color, BlendStates.AlphaBlend);
                    break;
                }
                }
            }
        }
コード例 #6
0
ファイル: AppStates.cs プロジェクト: gazcredible/howami
    public override void Init(Object obj = null)
    {
        instance = this;

        StressApp.instance.canvasController.SetScreen("Splash_Screen");
    }
コード例 #7
0
ファイル: SplashScreen.cs プロジェクト: Kairna/TouchAndPlay
 private void Init()
 {
     logoStayingDuration = 50;
     currentState = SplashScreenState.FADING_IN;
     logoAlpha = 0f;
 }