public override void OnEnter()
 {
     _fill = new Texture2D(GameState.GameInstance.GraphicsDevice, 1, 1);
     _fill.SetData(new[] { Color.White });
     _words = GameState.GameInstance.Content.Load<Texture2D>(WordsTexture);
     _drawOne = true;
     var evt = new SoundEvent(DoomEventType.PlaySound, AnnouncerSoundOne);
     MessagingSystem.DispatchEvent(evt, "MatchIntro");
     _stopwatch.Start();
 }
Example #2
0
        private ActionAnimationScript ShootFireballAction(Level level, AbilityDetails abilityDetails, Tile selectedTile)
        {
            // calculate damages
            var damageList = abilityDetails.CalculateDamages(level, selectedTile);

            // animation
            CurrentAnimation = ActorAnimationManager.Make("cacoshoot", ActorId);
            CurrentAnimation.OnComplete = Idle;

            var tilebox = selectedTile.CreateBoundingBox();
            var average = tilebox.Min + (tilebox.Max - tilebox.Min) / 2.0f;
            Vector3 target = new Vector3(average.X, tilebox.Max.Y + Height / 2.0f, average.Z);
            BoundingBox targetBoundingBox = new BoundingBox(target - new Vector3(20, 20, 20), target + new Vector3(20, 20, 20));
            Vector3 source = new Vector3(Position.X, Position.Y + Height / 3.0f, Position.Z);
            var direction = target - source;
            var velocity = Vector3.Normalize(direction) * 5.0f;
            var cacoFireball = ActorSpawnMethods.GetSpawnMethod(ActorType.CacoFireball).Invoke(source, velocity);
            var spawnEvent = new ActorEvent(DoomEventType.SpawnActor, cacoFireball);
            var soundEvent = new SoundEvent(DoomEventType.PlaySound, FireballShootSound);

            var script = new ActionAnimationScriptBuilder().Name(ActorId + "shootFireball")
                .Segment()
                    .OnStart(() =>
                    {
                        FacePoint(selectedTile.GetTopCenter(), false);
                        MessagingSystem.DispatchEvent(spawnEvent, ActorId);
                        MessagingSystem.DispatchEvent(soundEvent, ActorId);
                    })
                    .EndCondition(() => targetBoundingBox.Contains(cacoFireball.Position) == ContainmentType.Contains)
                    .OnComplete(() =>
                    {
                        ApplyAndDisplayDamages(damageList);
                        cacoFireball.Die();
                    })
                .Segment()
                    .EndOnEvent(DoomEventType.AnimationEnd, cacoFireball.ActorId)
                    .OnComplete(() =>
                        MessagingSystem.DispatchEvent(new DespawnActorEvent(DoomEventType.DespawnActor, cacoFireball), ActorId)
                        )
                .Build();

            return script;
        }
 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     if (_stopwatch.Elapsed > (AnnouncerSoundOneDuration + AnnouncerSoundTwoDuration) || GameState.GameInstance.SkipLevelIntros)
     {
         _stopwatch.Stop();
         NextState = new StateTransition(() => new FreeCamera(GameState, null));
     }
     else if (_stopwatch.Elapsed > AnnouncerSoundOneDuration && !_playedSecondSound)
     {
         _playedSecondSound = true;
         _drawOne = false;
         _drawTwo = true;
         var evt = new SoundEvent(DoomEventType.PlaySound, AnnouncerSoundTwo);
         MessagingSystem.DispatchEvent(evt, "MatchIntro");
     }
 }