public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Timer timer = context.GetTimerById(TimerId);

                if (!_running)
                {
                    context.EnqueueCommand(Commands.PerformTimerAction(timer, TimerAction.Restart));

                    Color          indent0        = Color.Yellow;
                    Color          indent1        = Color.White;
                    MessageBuilder messageBuilder = Message
                                                    .Build(Color.DarkCyan)
                                                    .Text(indent0, "Timers", 1)
                                                    .Text(indent1, "  - Raise an event at a predetermined interval");

                    context.EnqueueCommand(Commands.Message(messageBuilder));
                }
                else
                {
                    context.EnqueueCommand(Commands.PerformTimerAction(timer, TimerAction.Stop));
                }

                _running = !_running;

                return(EventResult.Completed);
            }
Пример #2
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);
            }
Пример #3
0
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(Color.DarkBlue)
                                                .Text(indent0, "Introduction", 1)
                                                .Text(indent1, "  - Who am I?", 1)
                                                .Text(indent0, "What is ZZT?", 1)
                                                .Text(indent1, "  - Created by Tim Sweeney (of Unreal fame) in 1991", 1)
                                                .Text(indent1, "  - ZZT is accessible -- you don't have to be an artist or sound engineer to create a game", 1)
                                                .Text(indent0, "Why recreate an old DOS game?", 1)
                                                .Text(indent1, "  - Rekindle the awesomeness of ZZT using modern tools and graphics capabilities", 1)
                                                .Text(indent1, "  - For the challenge and learning experience", 1)
                                                .Text(indent1, "  - For fun!");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                messageBuilder = Message
                                 .Build(Color.DarkRed)
                                 .Question(
                    "Unlock the next board?",
                    Color.Yellow,
                    Color.White,
                    Color.Yellow,
                    Color.Gray,
                    MessageAnswer.Build("Yes", new EventHandlerCollection(new YesAnswerSelectedEventHandler(@event.Target))),
                    MessageAnswer.Build("No"));

                context.EnqueueCommand(Commands.Message(messageBuilder));

                return(EventResult.Completed);
            }
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                context.EnqueueCommand(Commands.PlaySoundEffect(new WindowsUserAccountControlSoundEffect()));

                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(Color.DarkCyan)
                                                .Text(indent0, "Sound Effects", 1)
                                                .Text(indent1, "  - Use FMOD instead of XNA's SoundEffect class");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                return(EventResult.Completed);
            }
Пример #5
0
            public override EventResult HandleEvent(EventContext context, MessageClosedEvent @event)
            {
                ActorInstance actorInstance = context.GetActorInstanceById(BoardExitsActorInstanceId);

                context.EnqueueCommand(Commands.ActorInstanceDestroy(actorInstance));

                return(EventResult.Completed);
            }
Пример #6
0
        protected override EventResult OnEntered(EventContext context, BoardEnteredEvent @event)
        {
            foreach (Timer timer in Timers)
            {
                context.EnqueueCommand(Commands.PerformTimerAction(timer, TimerAction.Start));
            }

            return(base.OnEntered(context, @event));
        }
Пример #7
0
        protected override EventResult OnElapsed(EventContext context, TimerElapsedEvent @event)
        {
            IEnumerable <ActorInstance> actorInstances = context.CurrentBoard.ActorInstanceLayer.ActorInstances.Where(arg => arg.ActorId == BoardsActor.ActorId);

            foreach (ActorInstanceRandomMoveCommand command in actorInstances.Select(arg => Commands.ActorInstanceRandomMove(arg)))
            {
                context.EnqueueCommand(command);
            }

            return(EventResult.Completed);
        }
Пример #8
0
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(Color.DarkBlue, new EventHandlerCollection(new PlayerTouchedBoardExitsActorInstanceMessageClosedEventHandler()))
                                                .Text(indent0, "Board Exits", 1)
                                                .Text(indent1, "  - Travel points to other boards");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                return(EventResult.Completed);
            }
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(Color.DarkBlue)
                                                .Text(indent0, "Actors", 1)
                                                .Text(indent1, "  - Provide a template for actor instances", 1)
                                                .Text(indent1, "  - Don't have any behavior or event handlers");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                if (_handledOnce)
                {
                    return(EventResult.Canceled);
                }

                _handledOnce = true;

                Actor         actor         = context.GetActorById(@event.Target.ActorId);
                ActorInstance actorInstance = actor.CreateActorInstance(BoardId, ExitCoordinates[0], new EventHandlerCollection(new PlayerTouchedActorsActorCopyEventHandler()));
                ActorInstanceCreateCommand actorInstanceCreateCommand = Commands.ActorInstanceCreate(context.GetBoardById(BoardId), actorInstance);

                context.EnqueueCommand(actorInstanceCreateCommand);

                ChainedCommand chainedCommand = Commands
                                                .Chain(Commands.Delay(TimeSpan.FromMilliseconds(200)))
                                                .And(Commands
                                                     .ActorInstanceMove(actorInstance, MoveDirection.Down)
                                                     .Repeat(TimeSpan.FromMilliseconds(200), 2))
                                                .And(Commands.Delay(TimeSpan.FromMilliseconds(200)))
                                                .And(Commands
                                                     .ActorInstanceMove(actorInstance, MoveDirection.Right)
                                                     .Repeat(TimeSpan.FromMilliseconds(200), 5));

                context.EnqueueCommand(chainedCommand);

                return(EventResult.Completed);
            }
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(Color.DarkCyan)
                                                .Text(indent0, "Player", 1)
                                                .Text(indent1, "  - You!");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                return(EventResult.Completed);
            }
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                if (!_playing)
                {
                    context.EnqueueCommand(Commands.PlaySong(new FlourishSong(), 0.5f));

                    Color          indent0        = Color.Yellow;
                    Color          indent1        = Color.White;
                    MessageBuilder messageBuilder = Message
                                                    .Build(Color.DarkCyan)
                                                    .Text(indent0, "Songs", 1)
                                                    .Text(indent1, "  - Use FMOD instead of XNA's MediaPlayer class");

                    context.EnqueueCommand(Commands.Message(messageBuilder));
                }
                else
                {
                    context.EnqueueCommand(Commands.StopSong());
                }

                _playing = !_playing;

                return(EventResult.Completed);
            }
            public override EventResult HandleEvent(EventContext context, TimerElapsedEvent @event)
            {
                ActorInstance           timerActorInstance      = context.GetActorInstanceById(TimerActorInstanceId);
                SetTileCharacterCommand setTileCharacterCommand = Commands.SetTileCharacter(
                    timerActorInstance,
                    new Character(_symbols[_symbolIndex], timerActorInstance.Character.ForegroundColor, timerActorInstance.Character.BackgroundColor));

                context.EnqueueCommand(setTileCharacterCommand);

                if (++_symbolIndex == _symbols.Length)
                {
                    _symbolIndex = 0;
                }

                return(EventResult.Completed);
            }
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(Color.DarkBlue)
                                                .Text(indent0, "Objects", 1)
                                                .Text(indent1, "  - Any class that helps compose a world -- actors, boards, timers, etc.", 1)
                                                .Text(indent1, "  - Most objects have unique IDs (GUIDs)", 1)
                                                .Text(indent1, "  - Some objects can respond to events", 1)
                                                .Text(indent1, "  - Serialized and deserialized");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                return(EventResult.Completed);
            }
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(Color.DarkBlue)
                                                .Text(indent0, "Actor Instances", 1)
                                                .Text(indent1, "  - Provide the player something with which to interact", 1)
                                                .Text(indent1, "    - Monsters, smileys (NPCs), items, etc.", 1)
                                                .Text(indent1, "  - Event handlers make them useful", 1)
                                                .Text(indent1, "  - Can also interact with other actor instances");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                return(EventResult.Completed);
            }
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(new Color(43, 96, 80))
                                                .Text(indent0, "Messages", 1)
                                                .Text(indent1, "  - Display scrollable text to the player", 1)
                                                .Text(indent1, "  - Text, colors, line breaks", 1)
                                                .Text(indent1, "  - Questions and answers", 1)
                                                .Text(indent1, "L", 1)
                                                .Text(indent1, "o", 1)
                                                .Text(indent1, "r", 1)
                                                .Text(indent1, "e", 1)
                                                .Text(indent1, "m", 2)
                                                .Text(indent1, "i", 1)
                                                .Text(indent1, "p", 1)
                                                .Text(indent1, "s", 1)
                                                .Text(indent1, "u", 1)
                                                .Text(indent1, "m", 2)
                                                .Text(indent1, "L", 1)
                                                .Text(indent1, "o", 1)
                                                .Text(indent1, "r", 1)
                                                .Text(indent1, "e", 1)
                                                .Text(indent1, "m", 2)
                                                .Text(indent1, "i", 1)
                                                .Text(indent1, "p", 1)
                                                .Text(indent1, "s", 1)
                                                .Text(indent1, "u", 1)
                                                .Text(indent1, "m", 2)
                                                .Question(
                    "The only guarantee in life is...",
                    Color.White,
                    Color.Gray,
                    Color.White,
                    Color.DarkMagenta,
                    MessageAnswer.Build("Death"),
                    MessageAnswer.Build("Taxes"),
                    MessageAnswer.Build("XNA"));

                context.EnqueueCommand(Commands.Message(messageBuilder));

                return(EventResult.Completed);
            }
Пример #16
0
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(Color.DarkBlue)
                                                .Text(indent0, "Boards", 1)
                                                .Text(indent1, "  - An area within a world", 1)
                                                .Text(indent1, "    - Background layer", 1)
                                                .Text(indent1, "      - Sprites that can be walked over", 1)
                                                .Text(indent1, "    - Foreground layer", 1)
                                                .Text(indent1, "      - Sprites that can't be walked over", 1)
                                                .Text(indent1, "    - Actor instance layer", 1)
                                                .Text(indent1, "      - Player lives here also");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                return(EventResult.Completed);
            }
            public override EventResult HandleEvent(EventContext context, PlayerTouchedActorInstanceEvent @event)
            {
                Color          indent0        = Color.Yellow;
                Color          indent1        = Color.White;
                MessageBuilder messageBuilder = Message
                                                .Build(Color.DarkMagenta)
                                                .Text(indent0, "Commands", 1)
                                                .Text(indent1, "  - Control how the world changes", 1)
                                                .Text(indent1, "  - Game designers use commands to modify object state instead of modifying objects directly", 1)
                                                .Text(indent1, "  - Can be chained, repeated and retried", 2)
                                                .Text(indent0, "Events", 1)
                                                .Text(indent1, "  - Raised when something interesting happens", 1)
                                                .Text(indent1, "  - Provide context to event handlers", 2)
                                                .Text(indent0, "Serialization and Deserialization", 1)
                                                .Text(indent1, "  - XML", 1)
                                                .Text(indent1, "  - Binary");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                messageBuilder = Message
                                 .Build(Color.DarkRed)
                                 .Text(indent0, "Replacing XnaGame", 1)
                                 .Text(indent1, "  - Game class has too many responsibilities", 1)
                                 .Text(indent1, "  - XnaGame updates and draws", 1)
                                 .Text(indent1, "    - Doesn't handle Windows message pump", 1)
                                 .Text(indent1, "    - Doesn't act as a game loop", 1)
                                 .Text(indent1, "    - No game component concept", 1)
                                 .Text(indent1, "  - TimedXnaGame manages game time", 1)
                                 .Text(indent1, "  - XnaControl manages the GraphicsDevice", 1)
                                 .Text(indent1, "  - Updaters and renderers", 1)
                                 .Text(indent1, "    - Replaces XNA's game components", 1)
                                 .Text(indent1, "    - Given only the information they need", 1)
                                 .Text(indent1, "      - UpdateParameters, RenderParameters and state objects", 1)
                                 .Text(indent1, "    - Update/draw order controlled by order in which instances are added to collections", 1)
                                 .Text(indent1, "  - Windows message pump and game loop", 1)
                                 .Text(indent1, "  - GameForm");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                messageBuilder = Message
                                 .Build(Color.DarkBlue)
                                 .Text(indent0, "Managing Input", 1)
                                 .Text(indent1, "  - Keyboard helpers", 1)
                                 .Text(indent1, "  - Focus");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                messageBuilder = Message
                                 .Build(Color.DarkGreen)
                                 .Text(indent0, "Windows", 1)
                                 .Text(indent1, "  - Abstractions for a rectangular area", 1)
                                 .Text(indent1, "  - Bordered and textured", 1)
                                 .Text(indent1, "  - Support basic alignment");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                messageBuilder = Message
                                 .Build(Color.DarkGray)
                                 .Text(indent0, "Text Adventure Editor", 1)
                                 .Text(indent1, "  - Also uses XnaGame", 1)
                                 .Text(indent1, "  - Not much done yet");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                messageBuilder = Message
                                 .Build(Color.DarkBlue)
                                 .Text(indent0, "That's all!", 1)
                                 .Text(indent1, "  - Questions?", 2)
                                 .Text(indent0, "Text Adventure code: ")
                                 .Text(Color.White, "https://github.com/NathanAlden/TextAdventure", 2)
                                 .Text(indent0, "My blog: ")
                                 .Text(Color.White, "http://blog.TheCognizantCoder.com", 2)
                                 .Text(Color.LightMagenta, "Thank you for your time!");

                context.EnqueueCommand(Commands.Message(messageBuilder));

                return(EventResult.Completed);
            }
Пример #18
0
            public override EventResult HandleEvent(EventContext context, MessageClosedEvent @event)
            {
                context.EnqueueCommand(_command);

                return(EventResult.Completed);
            }