Пример #1
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;
            }
        }
Пример #2
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;
            }
        }