示例#1
0
            public override EventResult HandleEvent(EventContext context, MessageAnswerSelectedEvent @event)
            {
                context.PlayerInput.Suspend();

                ChainedCommand moveActorCommand = Commands
                                                  .Chain(Commands
                                                         .ActorInstanceMove(_actorInstance, MoveDirection.Right)
                                                         .Repeat(TimeSpan.FromMilliseconds(100), 9))
                                                  .And(Commands.Delay(TimeSpan.FromMilliseconds(100)))
                                                  .And(Commands.ActorInstanceMove(_actorInstance, MoveDirection.Down))
                                                  .And(Commands.Delay(TimeSpan.FromMilliseconds(500)))
                                                  .And(Commands.PlaySoundEffect(context.GetSoundEffectById(ExplodeSoundEffect.SoundEffectId), Volume.Full))
                                                  .And(Commands.RemoveSprite(context.CurrentBoard.ForegroundLayer, new Coordinate(50, 11)))
                                                  .And(Commands.ActorInstanceDestroy(_actorInstance))
                                                  .And(Commands.PlayerResumeInput());

                if (context.Player.Coordinate == new Coordinate(_actorInstance.Coordinate.X + 1, _actorInstance.Coordinate.Y))
                {
                    ChainedCommand command = Commands
                                             .Chain(Commands.Delay(TimeSpan.FromSeconds(1)))
                                             .And(Commands.PlaySoundEffect(context.GetSoundEffectById(SlapSoundEffect.SoundEffectId), Volume.Full))
                                             .And(Commands.PlayerMove(MoveDirection.Down))
                                             .And(Commands.Message(Message.Build(Color.DarkRed, new EventHandlerCollection(new SlapMessageClosedEventHandler(moveActorCommand))).Text(Color.Yellow, "WHAP!")))
                                             .And(Commands.Delay(TimeSpan.FromSeconds(1)));

                    context.EnqueueCommand(command);

                    return(EventResult.Completed);
                }

                context.EnqueueCommand(moveActorCommand);

                return(EventResult.Completed);
            }