示例#1
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            InContainerAc = DobjArtifact.InContainer;

            DoorGateAc = DobjArtifact.DoorGate;

            DrinkableAc = DobjArtifact.Drinkable;

            EdibleAc = DobjArtifact.Edible;

            ReadableAc = DobjArtifact.Readable;

            DobjArtAc = InContainerAc != null ? InContainerAc :
                        DoorGateAc != null ? DoorGateAc :
                        DrinkableAc != null ? DrinkableAc :
                        EdibleAc != null ? EdibleAc :
                        ReadableAc;

            if (DobjArtAc == null)
            {
                PrintCantVerbIt(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Drinkable || DobjArtAc.Type == ArtifactType.Edible || DobjArtAc.Type == ArtifactType.Readable || DobjArtAc.GetKeyUid() == -1)
            {
                PrintDontNeedTo();

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.DoorGate)
            {
                if (DobjArtifact.Seen)
                {
                    DobjArtAc.Field4 = 0;
                }

                if (DobjArtAc.Field4 == 1)
                {
                    PrintDontFollowYou();

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }
            }

            if (DobjArtAc.GetKeyUid() == -2)
            {
                PrintBrokeIt(DobjArtifact);

                goto Cleanup;
            }

            if (!DobjArtAc.IsOpen())
            {
                PrintNotOpen(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            PrintClosed(DobjArtifact);

            DobjArtAc.SetOpen(false);

            ProcessEvents(EventType.AfterCloseArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
示例#2
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            DrinkableAc = DobjArtifact.Drinkable;

            EdibleAc = DobjArtifact.Edible;

            DobjArtAc = DrinkableAc != null ? DrinkableAc : EdibleAc;

            if (DobjArtAc == null)
            {
                PrintCantVerbObj(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Edible)
            {
                NextState = Globals.CreateInstance <IEatCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            if (!DobjArtAc.IsOpen())
            {
                PrintMustFirstOpen(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Field2 < 1)
            {
                PrintNoneLeft(DobjArtifact);

                goto Cleanup;
            }

            if (DobjArtAc.Field2 != Constants.InfiniteDrinkableEdible)
            {
                DobjArtAc.Field2--;
            }

            ProcessEvents(EventType.BeforeNowEmptyArtifactCheck);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            if (DobjArtAc.Field2 < 1)
            {
                DobjArtifact.Value = 0;

                DobjArtifact.AddStateDesc(DobjArtifact.GetEmptyDesc());

                PrintVerbItAll(DobjArtifact);
            }
            else if (DobjArtAc.Field1 == 0)
            {
                PrintOkay(DobjArtifact);
            }

            if (DobjArtAc.Field1 != 0)
            {
                ActorMonster.DmgTaken -= DobjArtAc.Field1;

                if (ActorMonster.DmgTaken < 0)
                {
                    ActorMonster.DmgTaken = 0;
                }

                if (DobjArtAc.Field1 > 0)
                {
                    PrintFeelBetter(DobjArtifact);
                }
                else
                {
                    PrintFeelWorse(DobjArtifact);
                }

                Globals.Buf.SetFormat("{0}You are ", Environment.NewLine);

                ActorMonster.AddHealthStatus(Globals.Buf);

                gOut.Write("{0}", Globals.Buf);

                if (ActorMonster.IsDead())
                {
                    gGameState.Die = 1;

                    NextState = Globals.CreateInstance <IPlayerDeadState>(x =>
                    {
                        x.PrintLineSep = true;
                    });

                    goto Cleanup;
                }
            }

            ProcessEvents(EventType.AfterDrinkArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }