コード例 #1
0
        /// <summary>
        /// Creates the UI elements and add them to the EntityManager.
        /// </summary>
        private void CreateUI()
        {
            var currentScore = EntitiesFactory.CreateCurrentScore(275, (int)this.VirtualScreenManager.VirtualWidth);

            currentScore.Text = this.finalScore.ToString();
            this.EntityManager.Add(currentScore);

            var bestScoreText = EntitiesFactory.CreateBestScore(395, this.gameStorage.BestScore);

            this.EntityManager.Add(bestScoreText);

            var button = EntitiesFactory.CreatePlayButton(423, 451);

            this.EntityManager.Add(button);

            button.Click += (o, e) =>
            {
                var screenTransition = new CoverTransition(TimeSpan.FromSeconds(0.25), CoverTransition.EffectOptions.FromBotton)
                {
                    EaseFunction = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    }
                };

                WaveServices.ScreenContextManager.Pop(screenTransition);
            };
        }
コード例 #2
0
        private void BackToInitial()
        {
            WaveServices.GetService <ScoreService>().RegisterScore(this.currentScore);

            InitialScene intialScene = null;

            ScreenTransition transition = new CoverTransition(TimeSpan.FromMilliseconds(500), CoverTransition.EffectOptions.FromTop);

            transition.EaseFunction = new CubicEase()
            {
                EasingMode = EasingMode.EaseInOut
            };

#if MAC
            intialScene = new InitialScene();
            intialScene.Initialize(WaveServices.GraphicsDevice);
            WaveServices.ScreenContextManager.To(new ScreenContext(intialScene), transition);
#else
            WaveBackgroundTask.Run(() =>
            {
                intialScene = new InitialScene();
                intialScene.Initialize(WaveServices.GraphicsDevice);
            })
            .ContinueWith((t) =>
            {
                WaveServices.ScreenContextManager.To(new ScreenContext(intialScene), transition);
            });
#endif
        }
コード例 #3
0
        private void TapToPlayTouchTap(object sender, GestureEventArgs e)
        {
            if (count == 0)
            {
                count++;

                GameScene gameScene = null;

                ScreenTransition transition = new CoverTransition(TimeSpan.FromMilliseconds(500), CoverTransition.EffectOptions.FromTop);
                transition.EaseFunction = new CubicEase()
                {
                    EasingMode = EasingMode.EaseInOut
                };

                this.loadingEntity.IsVisible = true;
                var animationService = WaveServices.GetService <AnimationService>();
                animationService.CreatePulseAnimation(this.loadingEntity, 1000).Run();

#if MAC
                gameScene = new GameScene();
                gameScene.Initialize(WaveServices.GraphicsDevice);
                WaveServices.ScreenContextManager.To(new ScreenContext(gameScene), transition);
#else
                WaveBackgroundTask.Run(() =>
                {
                    gameScene = new GameScene();
                    gameScene.Initialize(WaveServices.GraphicsDevice);
                })
                .ContinueWith((t) =>
                {
                    WaveServices.ScreenContextManager.To(new ScreenContext(gameScene), transition);
                });
#endif
            }
        }
コード例 #4
0
        /// <summary>
        /// Creates the UI elements and add them to the EntityManager.
        /// </summary>
        private void CreateUI()
        {
            var gameOver = EntitiesFactory.CreateGameOverText();

            this.EntityManager.Add(gameOver);

            var currentScore = EntitiesFactory.CreateCurrentScore(275);

            currentScore.Text = this.gameScene.CurrentScore.ToString();
            this.EntityManager.Add(currentScore);

            var bestScoreText = EntitiesFactory.CreateBestScore(395, this.gameStorage.BestScore);

            this.EntityManager.Add(bestScoreText);

            var button = EntitiesFactory.CreatePlayButton(423, 451);

            this.EntityManager.Add(button);

            button.Click += (o, e) =>
            {
                var screenTransition = new CoverTransition(TimeSpan.FromSeconds(0.25), CoverTransition.EffectOptions.FromBotton)
                {
                    EaseFunction = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    }
                };

                WaveServices.ScreenContextManager.Pop(screenTransition);

                this.gameScene.SetState(GameScene.GameSceneStates.Gameplay);
                this.gameScene.Resume();
            };

            var background = EntitiesFactory.CreateGameOverBackground();

            this.EntityManager.Add(background);
        }
コード例 #5
0
        /// <summary>
        /// Do game over transition.
        /// </summary>
        private void GameOverTransition()
        {
            var notRunningInEditorMode = this.Owner.Scene is GameScene;

            if (notRunningInEditorMode)
            {
                this.IsScoreVisible = false;
                this.Owner.Scene.Pause();

                var screenTransition = new CoverTransition(TimeSpan.FromSeconds(0.5), CoverTransition.EffectOptions.FromBotton)
                {
                    EaseFunction = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    }
                };

                WaveServices.ScreenContextManager.Push(new ScreenContext(new GameOverScene(this.CurrentScore)), screenTransition);
            }
            else
            {
                this.SetState(GameplayStates.Gameplay);
            }
        }
コード例 #6
0
        /// <summary>
        /// Changes the scene state.
        /// </summary>
        /// <param name="state">The state.</param>
        public void SetState(GameSceneStates state)
        {
            var previusState = this.CurrentState;

            this.CurrentState = state;

            switch (state)
            {
            case GameSceneStates.Intro:
                this.currentScoreTB.IsVisible = false;

                foreach (var obstacle in this.EntityManager.FindAllByTag("OBSTACLE"))
                {
                    var obstaclePair = (ObstaclePair)obstacle;
                    obstaclePair.Entity.Enabled = false;
                }

                this.EntityManager.Find("kite")
                .FindComponent <KiteBehavior>()
                .SetState(KiteBehavior.KiteStates.TakeOff);
                break;

            case GameSceneStates.Gameplay:
                this.currentScoreTB.IsVisible = true;
                this.CurrentScore             = 0;
                this.EntityManager.Find("kite")
                .FindComponent <KiteBehavior>()
                .SetState(KiteBehavior.KiteStates.Gameplay);

                this.ResetScene(previusState != GameSceneStates.Intro);
                this.SetScrollEnable(true);
                break;

            case GameSceneStates.Crash:
                // Crash Effect
                this.crashEffect.DoEffect();

                //Dissable Scroll
                this.SetScrollEnable(false);
                break;

            case GameSceneStates.GameOver:
                WaveServices.TimerFactory.CreateTimer("GameoverTimer", TimeSpan.FromMilliseconds(200), () =>
                {
                    this.currentScoreTB.IsVisible = false;
                    this.Pause();

                    var screenTransition = new CoverTransition(TimeSpan.FromSeconds(0.5), CoverTransition.EffectOptions.FromBotton)
                    {
                        EaseFunction = new CubicEase()
                        {
                            EasingMode = EasingMode.EaseInOut
                        }
                    };

                    WaveServices.ScreenContextManager.Push(new ScreenContext(new GameOverScene()), screenTransition);
                }, false);
                break;

            default:
                break;
            }
        }