Beispiel #1
0
        public virtual void ProcessArtifact(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            artifact.SetInRoom(gActorRoom);

            if (gActorMonster.Weapon == artifact.Uid)
            {
                Debug.Assert(artifact.GeneralWeapon != null);

                var rc = artifact.RemoveStateDesc(artifact.GetReadyWeaponDesc());

                Debug.Assert(gEngine.IsSuccess(rc));

                gActorMonster.Weapon = -1;
            }

            PrintDropped(artifact);
        }
Beispiel #2
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null);

            DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false);

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

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Wearable)
            {
                NextState = Globals.CreateInstance <IWearCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            if (!DobjArtifact.IsReadyableByCharacter())
            {
                PrintNotReadyableWeapon(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (!DobjArtifact.IsCarriedByCharacter())
            {
                if (!GetCommandCalled)
                {
                    RedirectToGetCommand <IReadyCommand>(DobjArtifact);
                }
                else if (DobjArtifact.DisguisedMonster == null)
                {
                    NextState = Globals.CreateInstance <IStartState>();
                }

                goto Cleanup;
            }

            // can't use two-handed weapon while wearing shield

            if (gGameState.Sh > 0 && DobjArtAc.Field5 > 1)
            {
                ShieldArtifact = gADB[gGameState.Sh];

                Debug.Assert(ShieldArtifact != null);

                PrintCantReadyWeaponWithShield(DobjArtifact, ShieldArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            ActorWeapon = gADB[ActorMonster.Weapon];

            if (ActorWeapon != null)
            {
                rc = ActorWeapon.RemoveStateDesc(ActorWeapon.GetReadyWeaponDesc());

                Debug.Assert(gEngine.IsSuccess(rc));
            }

            ActorMonster.Weapon = DobjArtifact.Uid;

            rc = DobjArtifact.AddStateDesc(DobjArtifact.GetReadyWeaponDesc());

            Debug.Assert(gEngine.IsSuccess(rc));

            gOut.Print("{0} readied.", DobjArtifact.GetNoneName(true, false));

            ProcessEvents(EventType.AfterReadyArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Beispiel #3
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(Direction == 0 || Enum.IsDefined(typeof(Direction), Direction));

            Globals.PlayerMoved = true;

            gCommandParser.LastHimNameStr = "";

            gCommandParser.LastHerNameStr = "";

            gCommandParser.LastItNameStr = "";

            gCommandParser.LastThemNameStr = "";

            gGameState.R3 = gGameState.Ro;

            gGameState.Ro = gGameState.R2;

            if (MoveMonsters)
            {
                gEngine.MoveMonsters();
            }

            ProcessEvents(EventType.AfterMoveMonsters);

            Debug.Assert(gCharMonster != null);

            gCharMonster.Location = gGameState.Ro;

            if (gGameState.Ls > 0 && gGameState.Ro != gGameState.R3)
            {
                LsArtifact = gADB[gGameState.Ls];

                Debug.Assert(LsArtifact != null);

                if (!LsArtifact.IsCarriedByCharacter())
                {
                    rc = LsArtifact.RemoveStateDesc(LsArtifact.GetProvidingLightDesc());

                    Debug.Assert(gEngine.IsSuccess(rc));

                    gGameState.Ls = 0;
                }
            }

            NewRoom = gRDB[gGameState.Ro];

            Debug.Assert(NewRoom != null);

            if (NewRoom.LightLvl > 0 && gGameState.Ls > 0)
            {
                gEngine.CheckToExtinguishLightSource();
            }

            ProcessEvents(EventType.AfterExtinguishLightSourceCheck);

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

            Globals.NextState = NextState;
        }