コード例 #1
0
        public override void Execute()
        {
            Debug.Assert(Direction == 0 || Enum.IsDefined(typeof(Direction), Direction));

            if (DobjArtifact != null && DobjArtifact.DoorGate == null)
            {
                PrintDontFollowYou();

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (!ActorMonster.CheckNBTLHostility())
            {
                PrintCalmDown();

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtifact == null)
            {
                NumExits = 0;

                gEngine.CheckNumberOfExits(ActorRoom, ActorMonster, true, ref _numExits);

                if (NumExits == 0)
                {
                    PrintNoPlaceToGo();

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }
            }

            ProcessEvents(EventType.AfterNumberOfExitsCheck);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            if (DobjArtifact == null)
            {
                if (Direction == 0)
                {
                    RandomDirection = 0;

                    gEngine.GetRandomMoveDirection(ActorRoom, ActorMonster, true, ref _randomDirection);

                    Direction = RandomDirection;
                }

                Debug.Assert(Enum.IsDefined(typeof(Direction), Direction));
            }

            if (DobjArtifact != null)
            {
                Globals.Buf.SetFormat("{0}", DobjArtifact.GetDoorGateFleeDesc());
            }
            else if (Direction == Direction.Up || Direction == Direction.Down || Direction == Direction.In || Direction == Direction.Out)
            {
                Globals.Buf.SetFormat(" {0}ward", Direction.ToString().ToLower());
            }
            else
            {
                Globals.Buf.SetFormat(" to the {0}", Direction.ToString().ToLower());
            }

            gOut.Print("Attempting to flee{0}.", Globals.Buf);

            gGameState.R2 = DobjArtifact != null ? 0 : ActorRoom.GetDirs(Direction);

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IPlayerMoveCheckState>(x =>
                {
                    x.Direction = Direction;

                    x.DoorGateArtifact = DobjArtifact;

                    x.Fleeing = true;
                });
            }
        }