コード例 #1
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, "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);
            }