Exemplo n.º 1
0
        public bool Handle(IEvent evt)
        {
            PlayerLostEvent playerLostEvent = evt as PlayerLostEvent;

            if (playerLostEvent != null)
            {
                WaitProcess processChain    = new WaitProcess(Constants.Animations.GAME_OVER_WAIT);
                string      gameOverContent = playerLostEvent.WinPlayer.Name + Constants.Pong.GAME_OVER_CONTENT_SUFFIX;
                processChain.SetNext(new GameOverTextAnimation(_engine,
                                                               FontEntity.Create(_engine,
                                                                                 Vector2.Zero,
                                                                                 Content.Load <BitmapFont>(Constants.Resources.FONT_PONG_INTRO),
                                                                                 gameOverContent),
                                                               _mainCamera,
                                                               GameManager.GraphicsDevice))
                .SetNext(new WaitProcess(Constants.Animations.GAME_OVER_POST_WAIT))
                .SetNext(new DelegateCommand(() =>
                {
                    GameManager.ChangeState(new LobbyGameState(GameManager,
                                                               _player1.InputMethod,
                                                               (_player2 is AIPlayer) ? null : _player2.InputMethod));
                }));

                _processManager.Attach(processChain);

                return(false);
            }

            return(false);
        }
Exemplo n.º 2
0
        void BeginIntroSequence()
        {
            WaitProcess             wait1 = new WaitProcess(Constants.Animations.INTRO_WAIT_DURATION);
            ReadyIntroTextAnimation readyIntroAnimation = new ReadyIntroTextAnimation(_engine,
                                                                                      FontEntity.Create(_engine,
                                                                                                        Vector2.Zero,
                                                                                                        Content.Load <BitmapFont>(Constants.Resources.FONT_PONG_INTRO),
                                                                                                        Constants.Pong.INTRO_READY_CONTENT),
                                                                                      _mainCamera,
                                                                                      GameManager.GraphicsDevice);

            wait1.SetNext(readyIntroAnimation);

            GoIntroTextAnimation goIntroAnimation = new GoIntroTextAnimation(_engine,
                                                                             FontEntity.Create(_engine,
                                                                                               Vector2.Zero,
                                                                                               Content.Load <BitmapFont>(Constants.Resources.FONT_PONG_INTRO),
                                                                                               Constants.Pong.INTRO_GO_CONTENT),
                                                                             _mainCamera,
                                                                             GameManager.GraphicsDevice);

            readyIntroAnimation.SetNext(goIntroAnimation);

            goIntroAnimation.SetNext(new DelegateCommand(() =>
            {
                EventManager.Instance.TriggerEvent(new StartEvent());
            }));

            _processManager.Attach(wait1);
        }
Exemplo n.º 3
0
        public void TestInactiveBeforeStarted()
        {
            // Arrange.
            WaitProcess process = new WaitProcess(3.0f);

            // Assert.
            Assert.IsFalse(process.Active);
        }
Exemplo n.º 4
0
        public void TestActiveWhenStarted()
        {
            // Arrange.
            WaitProcess process = new WaitProcess(3.0f);

            // Act.
            this.game.ProcessManager.AddProcess(process);

            // Assert.
            Assert.IsTrue(process.Active);
        }
Exemplo n.º 5
0
 private void SaveSettings()
 {
     using (WaitProcess w = new WaitProcess(this))
     {
         w.ChangeStatus("Saving settings ...");
         if (Directory.Exists(txtImageGalleryDirectory.Text))
         {
             _settings.ImageGalleryDirectory = txtImageGalleryDirectory.Text;
             _settings.SaveToFile();
         }
     }
 }
Exemplo n.º 6
0
        public void TestWaitProcessDeadAfterExpired()
        {
            // Arrange.
            WaitProcess process = new WaitProcess(3.0f);

            this.game.ProcessManager.AddProcess(process);

            // Act.
            this.game.Update(3.0f);

            // Assert.
            Assert.IsTrue(process.Dead);
        }
Exemplo n.º 7
0
        public void TestWaitProcessAliveBeforeExpired()
        {
            // Arrange.
            WaitProcess process = new WaitProcess(3.0f);

            this.game.ProcessManager.AddProcess(process);

            // Act.
            this.game.Update(1.0f);

            // Assert.
            Assert.IsFalse(process.Dead);
        }
Exemplo n.º 8
0
        public void TestUpdateProcess()
        {
            // Arrange.
            WaitProcess process = new WaitProcess(3.0f);

            this.game.ProcessManager.AddProcess(process);

            // Act.
            this.game.Update(1.0f);

            // Assert.
            Assert.AreEqual(1.0f, process.TimeElapsed);
        }
Exemplo n.º 9
0
        public static Process CreateLaserEnemyProcessChain(ProcessManager processManager, Engine engine, Entity entity, float waitTime, bool loop)
        {
            Process chain       = new WaitProcess(waitTime);
            Process loopProcess = null;

            if (loop)
            {
                loopProcess = new DelegateProcess(() =>
                {
                    processManager.Attach(CreateLaserEnemyProcessChain(processManager, engine, entity, CVars.Get <float>("laser_enemy_successive_wait_period"), true));
                });
            }
            chain.SetNext(new LaserEnemyFreezeRotation(engine, entity))
            .SetNext(new LaserWarmUpProcess(engine, entity))
            .SetNext(new WaitProcess(CVars.Get <float>("laser_enemy_warm_up_duration")))
            .SetNext(new LaserShootProcess(engine, entity))
            .SetNext(new LaserEnemyUnfreezeRotation(engine, entity))
            .SetNext(loopProcess);
            return(chain);
        }
Exemplo n.º 10
0
        void PlayNewBall(Player playerToServe, bool wait)
        {
            Process ballReturnSequence = new WaitProcess(wait ? 1.0f : 0.0f);

            _processManager.Attach(ballReturnSequence);

            float direction = Constants.Pong.BALL_PLAYER2_STARTING_ROTATION_DEGREES;

            if (playerToServe == _owner.Player1)
            {
                direction = Constants.Pong.BALL_PLAYER1_STARTING_ROTATION_DEGREES;
            }

            ballReturnSequence.SetNext(new DelegateCommand(() =>
            {
                Entity ballEntity = BallEntity.Create(_owner.Engine,
                                                      _owner.Content.Load <Texture2D>(Constants.Resources.TEXTURE_PONG_BALL),
                                                      Vector2.Zero,
                                                      direction);
                EventManager.Instance.QueueEvent(new BallServeEvent(ballEntity, Vector2.Zero));
            }));
        }
Exemplo n.º 11
0
        public static Entity AddBehavior(Engine engine, Entity entity, ProcessManager processManager)
        {
            entity.AddComponent(new EnemyComponent());
            entity.AddComponent(new GravityHoleEnemyComponent(
                                    CVars.Get <float>("gravity_hole_enemy_radius"),
                                    CVars.Get <float>("gravity_hole_enemy_force"),
                                    CVars.Get <int>("gravity_hole_enemy_lifespan")));

            Process process = new WaitProcess(CVars.Get <int>("gravity_hole_enemy_lifespan"));

            processManager.Attach(process)
            .SetNext(new DelegateProcess(() => {
                entity.GetComponent <GravityHoleEnemyComponent>().ScalingAnimation = false;
                entity.GetComponent <GravityHoleEnemyComponent>().PingAnimation    = false;
            }))
            .SetNext(new EntityScaleProcess(engine, entity,
                                            CVars.Get <float>("gravity_hole_animation_despawn_duration"),
                                            entity.GetComponent <TransformComponent>().Scale, 0, Easings.Functions.SineEaseIn))
            .SetNext(new EntityDestructionProcess(engine, entity));
            entity.AddComponent(new GravityHoleSpawningProcessComponent(process));

            return(entity);
        }