예제 #1
0
        public override void Execute()
        {
            RetCode rc;

            if (GoToMainHall)
            {
                gOut.Write("{0}Return to the Main Hall (Y/N): ", Environment.NewLine);

                Globals.Buf.Clear();

                rc = Globals.In.ReadField(Globals.Buf, Constants.BufSize02, null, ' ', '\0', false, null, gEngine.ModifyCharToUpper, gEngine.IsCharYOrN, null);

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

                if (Globals.Buf.Length > 0 && Globals.Buf[0] == 'Y')
                {
                    gGameState.Die = -1;

                    Globals.ExitType = ExitType.GoToMainHall;

                    Globals.MainLoop.ShouldShutdown = false;

                    goto Cleanup;
                }

                goto Cleanup;
            }

            if (Globals.Database.GetFilesetsCount() == 0)
            {
                gOut.Print("[You haven't saved a game yet but {0} will be left here should you choose to return.  Use \"quit hall\" if you don't want {1} to stay.]",
                           ActorMonster.Name,
                           ActorMonster.EvalGender("him", "her", "it"));
            }

            gOut.Write("{0}Do you really want to quit (Y/N): ", Environment.NewLine);

            Globals.Buf.Clear();

            rc = Globals.In.ReadField(Globals.Buf, Constants.BufSize02, null, ' ', '\0', false, null, gEngine.ModifyCharToUpper, gEngine.IsCharYOrN, null);

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

            if (Globals.Buf.Length > 0 && Globals.Buf[0] == 'Y')
            {
                Globals.ExitType = ExitType.Quit;

                Globals.MainLoop.ShouldShutdown = false;

                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IStartState>();
            }
        }
예제 #2
0
        public override void Execute()
        {
            RetCode rc;

            ArmorArtifactUids = new long[] { gGameState.Ar, gGameState.Sh };

            CharArmorClass = Armor.SkinClothes;

            foreach (var armorArtifactUid in ArmorArtifactUids)
            {
                if (armorArtifactUid > 0)
                {
                    ArmorArtifact = gADB[armorArtifactUid];

                    Debug.Assert(ArmorArtifact != null);

                    ArmorArtifactAc = ArmorArtifact.Wearable;

                    Debug.Assert(ArmorArtifactAc != null);

                    CharArmorClass += ArmorArtifactAc.Field1;
                }
            }

            CharArmor = gEngine.GetArmors(CharArmorClass);

            Debug.Assert(CharArmor != null);

            Globals.Buf.SetFormat("{0}", CharArmor.Name);

            CharInventoryWeight = 0;

            rc = ActorMonster.GetFullInventoryWeight(ref _charInventoryWeight, recurse: true);

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

            StatDisplayArgs = Globals.CreateInstance <IStatDisplayArgs>(x =>
            {
                x.Monster        = ActorMonster;
                x.ArmorString    = Globals.Buf.ToString();
                x.SpellAbilities = gGameState.Sa;
                x.Speed          = gGameState.Speed;
                x.CharmMon       = gEngine.GetCharismaFactor(gCharacter.GetStats(Stat.Charisma));
                x.Weight         = CharInventoryWeight;
            });

            rc = gCharacter.StatDisplay(StatDisplayArgs);

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

            ProcessEvents(EventType.AfterPrintPlayerStatus);

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

            Debug.Assert(DobjArtifact != null);

            if (DobjArtifact.IsReadyableByMonster(ActorMonster) && DobjArtifact.IsCarriedByMonster(ActorMonster))
            {
                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));

                Debug.Assert(gCharMonster != null);

                if (gCharMonster.IsInRoom(ActorRoom))
                {
                    if (ActorRoom.IsLit())
                    {
                        MonsterName = ActorMonster.EvalPlural(ActorMonster.GetTheName(true), ActorMonster.GetArticleName(true, true, false, true, Globals.Buf01));

                        gOut.Print("{0} readies {1}.", MonsterName, DobjArtifact.GetArticleName());
                    }
                    else
                    {
                        MonsterName = string.Format("An unseen {0}", ActorMonster.CheckNBTLHostility() ? "offender" : "entity");

                        gOut.Print("{0} readies {1}.", MonsterName, "a weapon");
                    }

                    if (ActorMonster.CheckNBTLHostility())
                    {
                        Globals.Thread.Sleep(gGameState.PauseCombatMs);
                    }
                }
            }

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IErrorState>(x =>
                {
                    x.ErrorMessage = string.Format("{0}: NextState == null", Name);
                });
            }
        }
예제 #4
0
        public override void Execute()
        {
            if (ActorMonster.ShouldFleeRoom())
            {
                gEngine.MoveMonsterToRandomAdjacentRoom(ActorRoom, ActorMonster, true, true);
            }

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IErrorState>(x =>
                {
                    x.ErrorMessage = string.Format("{0}: NextState == null", Name);
                });
            }
        }
예제 #5
0
        private void AttachBuildingModel()
        {
            GearParent[] gears = (GearParent[])GameObject.FindObjectsOfType(typeof(GearParent));
            foreach (GearParent gear in gears)
            {
                if (gear.ID == (uint)clientTrapId)
                {
                    Transform     = gear.transform;
                    GameObject    = gear.gameObject;
                    Transform.tag = "Monster";

                    Debug.Log("CreateBuildingModel Position: " + Transform.position);

                    // motor = GameObject.AddComponent<MogoMotorServer>();
                    animator = GameObject.GetComponent <Animator>();

                    ActorMonster ap = GameObject.GetComponent <ActorMonster>();
                    if (ap == null)
                    {
                        ap = GameObject.AddComponent <ActorMonster>();
                    }

                    ap.theEntity = this;
                    this.Actor   = ap;

                    golem   = gear.gameObject.GetComponentInChildren <GolemAnimation>();
                    golemFx = gear.gameObject.GetComponentInChildren <GolemFx>();

                    // golem = gear as GolemAnimation;

                    if (golem != null)
                    {
                        golem.Activate();
                    }
                    if (golemFx != null)
                    {
                        golemFx.Activate();
                    }

                    BornedHandler();

                    // base.CreateModel();
                }
            }
        }
예제 #6
0
        public override void CreateDeafaultModel()
        {
            AvatarModelData data = AvatarModelData.dataMap[999];

            Debug.Log("monster create:" + ID + ",name:" + data.prefabName);
            GameObject go = AssetCacheMgr.GetLocalInstance(data.prefabName) as GameObject;

            Transform            = go.transform;
            Transform.localScale = scale;
            Transform.tag        = "Monster";
            motor    = go.AddComponent <MogoMotorServer>();
            animator = go.GetComponent <Animator>();
            ActorMonster ap = go.AddComponent <ActorMonster>();

            ap.theEntity = this;
            this.Actor   = ap;
            UpdatePosition();
            base.CreateModel();
        }
예제 #7
0
    protected override void OnCreateModel()
    {
        data = MonsterData.GetByID(serverInfo.dataId);
        if (data == null)
        {
            Debuger.LogError("怪物数据Error null" + serverInfo.dataId);
            return;
        }
        AvatarModelData modelData = AvatarModelData.GetByID(data.modelId);

        gameObject = Res.ResourceManager.Instance.Instantiate <GameObject>(GameCommonUtils.GetResourceData(modelData.prefabName).resourcePath);

        transform     = gameObject.transform;
        transform.tag = "Monster";
        transform.gameObject.layer = 11;

        ActorMonster ap = gameObject.AddComponent <ActorMonster>();

        ap.theEntity = this;
        animator     = gameObject.GetComponent <Animator>();
        this.Actor   = ap;

        this.Motor           = gameObject.AddComponent <MotorParent>();
        this.Motor.theEntity = this;
        UpdatePosition();
        if (modelData != null && modelData.scale > 0)
        {
            gameObject.transform.localScale = new Vector3(modelData.scale, modelData.scale, modelData.scale);
            if (modelData.scaleRadius > 0 && ap.GetComponent <CharacterController>() != null)
            {
                ap.GetComponent <CharacterController>().radius = modelData.scaleRadius;
            }
        }

        animator.applyRootMotion = false;
    }
예제 #8
0
        public override void ProcessEvents(EventType eventType)
        {
            if (eventType == EventType.AfterCastSpellCheck)
            {
                var hammerArtifact = gADB[24];

                Debug.Assert(hammerArtifact != null);

                // Thor's hammer appears in Norse Mural room

                if (ActorRoom.Uid == 22 && !gGameState.ThorsHammerAppears)
                {
                    hammerArtifact.SetInRoom(ActorRoom);

                    gEngine.PrintEffectDesc(7);

                    gGameState.ThorsHammerAppears = true;

                    NextState = Globals.CreateInstance <IStartState>();

                    GotoCleanup = true;

                    goto Cleanup;
                }

                var rl = gEngine.RollDice(1, 100, 0);

                // 20% chance of gender change

                if (rl < 21 && gGameState.GenderChangeCounter < 2)
                {
                    ActorMonster.Gender = ActorMonster.EvalGender(Gender.Female, Gender.Male, Gender.Neutral);

                    gCharacter.Gender = ActorMonster.Gender;

                    gOut.Print("You feel different... more {0}.", ActorMonster.EvalGender("masculine", "feminine", "androgynous"));

                    gGameState.GenderChangeCounter++;

                    GotoCleanup = true;

                    goto Cleanup;
                }

                // 40% chance Charisma up (one time only)

                if (rl < 41 && !gGameState.CharismaBoosted)
                {
                    gCharacter.ModStats(Stat.Charisma, 2);

                    gOut.Print("You suddenly feel more {0}.", gCharacter.EvalGender("handsome", "beautiful", "androgynous"));

                    gGameState.CharismaBoosted = true;

                    GotoCleanup = true;

                    goto Cleanup;
                }

                // 5% Chance of being hit by lightning!

                if (rl > 94)
                {
                    gEngine.PrintEffectDesc(33);

                    var combatSystem = Globals.CreateInstance <ICombatSystem>(x =>
                    {
                        x.SetNextStateFunc = s => NextState = s;

                        x.DfMonster = ActorMonster;

                        x.OmitArmor = true;
                    });

                    combatSystem.ExecuteCalculateDamage(1, 10);

                    GotoCleanup = true;

                    goto Cleanup;
                }

                PrintSonicBoom();

                GotoCleanup = true;

                goto Cleanup;
            }
            else
            {
                base.ProcessEvents(eventType);
            }

Cleanup:

            ;
        }
예제 #9
0
        public virtual void Execute()
        {
            Debug.Assert(ActorMonster != null);

            ActorRoom = ActorMonster.GetInRoom();

            Debug.Assert(ActorRoom != null);

            if (InputBuf.Length == 0)
            {
                InputBuf.SetFormat("{0}", LastInputStr);

                if (InputBuf.Length > 0 && ActorMonster.IsCharacterMonster())
                {
                    if (Environment.NewLine.Length == 1 && Globals.CursorPosition.Y > -1 && Globals.CursorPosition.Y + 1 >= gOut.GetBufferHeight())
                    {
                        Globals.CursorPosition.Y--;
                    }

                    gOut.SetCursorPosition(Globals.CursorPosition);

                    if (Globals.LineWrapUserInput)
                    {
                        gEngine.LineWrap(InputBuf.ToString(), Globals.Buf, Globals.CommandPrompt.Length);
                    }
                    else
                    {
                        Globals.Buf.SetFormat("{0}", InputBuf.ToString());
                    }

                    gOut.WordWrap = false;

                    gOut.WriteLine(Globals.Buf);

                    gOut.WordWrap = true;
                }
            }

            LastInputStr = InputBuf.ToString();

            InputBuf = ReplacePrepositions(InputBuf);

            Tokens = InputBuf.ToString().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

            if (CurrToken < Tokens.Length)
            {
                if (Tokens.Length == 1)
                {
                    Globals.Buf.SetFormat("{0}", Tokens[CurrToken]);

                    Tokens[CurrToken] = Globals.Buf.TrimEndPunctuationMinusPound().ToString().Trim();
                }

                if (Tokens[CurrToken].Length == 0)
                {
                    Tokens[CurrToken] = "???";
                }
                else if (string.Equals(Tokens[CurrToken], "at", StringComparison.OrdinalIgnoreCase))
                {
                    Tokens[CurrToken] = "a";
                }

                var command = Globals.CommandList.FirstOrDefault(x => x.Verb != null && string.Equals(x.Verb, Tokens[CurrToken], StringComparison.OrdinalIgnoreCase) && x.IsEnabled(ActorMonster));

                if (command == null)
                {
                    command = Globals.CommandList.FirstOrDefault(x => x.Synonyms != null && x.Synonyms.FirstOrDefault(s => string.Equals(s, Tokens[CurrToken], StringComparison.OrdinalIgnoreCase)) != null && x.IsEnabled(ActorMonster));
                }

                if (command == null)
                {
                    command = Globals.CommandList.FirstOrDefault(x => x.Verb != null && (x.Verb.StartsWith(Tokens[CurrToken], StringComparison.OrdinalIgnoreCase) || x.Verb.EndsWith(Tokens[CurrToken], StringComparison.OrdinalIgnoreCase)) && x.IsEnabled(ActorMonster));
                }

                if (command == null)
                {
                    command = Globals.CommandList.FirstOrDefault(x => x.Synonyms != null && x.Synonyms.FirstOrDefault(s => s.StartsWith(Tokens[CurrToken], StringComparison.OrdinalIgnoreCase) || s.EndsWith(Tokens[CurrToken], StringComparison.OrdinalIgnoreCase)) != null && x.IsEnabled(ActorMonster));
                }

                if (command != null)
                {
                    CurrToken++;

                    NextState = Activator.CreateInstance(command.GetType()) as IState;

                    command = NextState as ICommand;

                    Debug.Assert(command != null);

                    command.CommandParser = this;

                    command.ActorMonster = ActorMonster;

                    command.ActorRoom = ActorRoom;

                    command.Dobj = DobjData.Obj;

                    command.Iobj = IobjData.Obj;

                    if (command.ShouldStripTrailingPunctuation() && Tokens.Length > 1)
                    {
                        Globals.Buf.SetFormat("{0}", Tokens[Tokens.Length - 1]);

                        Tokens[Tokens.Length - 1] = Globals.Buf.TrimEndPunctuationMinusPound().ToString().Trim();
                    }

                    if (ActorMonster.IsCharacterMonster())
                    {
                        CheckPlayerCommand(command, false);

                        if (NextState == command)
                        {
                            if (ActorRoom.IsLit() || command.IsDarkEnabled)
                            {
                                command.FinishParsing();

                                if (NextState == command)
                                {
                                    CheckPlayerCommand(command, true);
                                }
                            }
                            else
                            {
                                NextState = null;
                            }
                        }
                    }
                    else
                    {
                        command.FinishParsing();
                    }

                    if (NextState == null)
                    {
                        NextState = Globals.CreateInstance <IStartState>();
                    }
                }
            }
        }
예제 #10
0
        public virtual void ParseName()
        {
            RetCode rc;

            var command = NextState as ICommand;

            Debug.Assert(command != null);

            if (ObjData.Name == null)
            {
                ObjData.Name = "";

                while (string.IsNullOrWhiteSpace(ObjData.Name))
                {
                    if (CurrToken < Tokens.Length && PrepTokenIndex < 0)
                    {
                        PrepTokenIndex = command.IsDobjPrepEnabled || command.IsIobjEnabled ? gEngine.FindIndex(Tokens, token => gEngine.Preps.FirstOrDefault(prep => string.Equals(prep.Name, token, StringComparison.OrdinalIgnoreCase) && command.IsPrepEnabled(prep)) != null) : -1;

                        Prep = PrepTokenIndex >= 0 ? gEngine.Preps.FirstOrDefault(prep => string.Equals(prep.Name, Tokens[PrepTokenIndex], StringComparison.OrdinalIgnoreCase) && command.IsPrepEnabled(prep)) : null;

                        if (((ObjData == DobjData && command.IsDobjPrepEnabled) || (ObjData == IobjData && command.IsIobjEnabled)) && PrepTokenIndex == CurrToken)
                        {
                            command.Prep = Globals.CloneInstance(Prep);

                            command.ContainerType = Prep.ContainerType;

                            var numTokens = Tokens.Length - CurrToken;

                            ObjData.Name = string.Join(" ", Tokens.Skip((int)(CurrToken + 1)).Take((int)(numTokens - 1)));

                            CurrToken += numTokens;
                        }
                        else if ((ObjData == DobjData && command.IsIobjEnabled) && PrepTokenIndex > CurrToken)
                        {
                            command.Prep = Globals.CloneInstance(Prep);

                            command.ContainerType = Prep.ContainerType;

                            var numTokens = PrepTokenIndex - CurrToken;

                            ObjData.Name = string.Join(" ", Tokens.Skip((int)CurrToken).Take((int)numTokens));

                            CurrToken += numTokens;
                        }
                        else
                        {
                            PrepTokenIndex = -1;

                            Prep = null;

                            ObjData.Name = string.Join(" ", Tokens.Skip((int)CurrToken));

                            CurrToken = Tokens.Length;
                        }
                    }

                    if (ObjData == IobjData && CurrToken < Tokens.Length && PrepTokenIndex >= 0)
                    {
                        CurrToken = PrepTokenIndex + 1;
                    }

                    if (CurrToken < Tokens.Length && string.IsNullOrWhiteSpace(ObjData.Name))
                    {
                        ObjData.Name = string.Join(" ", Tokens.Skip((int)CurrToken));

                        CurrToken = Tokens.Length;
                    }

                    if (string.IsNullOrWhiteSpace(ObjData.Name))
                    {
                        Debug.Assert(ActorMonster.IsCharacterMonster());

                        if (ObjData == DobjData)
                        {
                            if (ObjData.QueryDescFunc == null)
                            {
                                ObjData.QueryDescFunc = () => string.Format("{0}{1} {2}who or what? ", Environment.NewLine, command.Verb.FirstCharToUpper(), command.IsDobjPrepEnabled && command.Prep != null && Enum.IsDefined(typeof(ContainerType), command.Prep.ContainerType) ? gEngine.EvalContainerType(command.Prep.ContainerType, "inside ", "on ", "under ", "behind ") : "");
                            }
                        }
                        else
                        {
                            Debug.Assert(ObjData.QueryDescFunc != null);
                        }

                        gOut.Write(ObjData.QueryDescFunc());

                        Globals.Buf.SetFormat("{0}", Globals.In.ReadLine());

                        Globals.Buf = ReplacePrepositions(Globals.Buf);

                        if (command.ShouldStripTrailingPunctuation())
                        {
                            Globals.Buf.SetFormat("{0}", Globals.Buf.TrimEndPunctuationMinusPound().ToString().Trim());
                        }

                        Tokens = Tokens.Concat(Globals.Buf.ToString().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)).ToArray();
                    }
                    else
                    {
                        var mySeen = false;

                        Globals.Buf.SetFormat("{0}", ObjData.Name);

                        rc = gEngine.StripPrepsAndArticles(Globals.Buf, ref mySeen);

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

                        ObjData.Name = Globals.Buf.ToString().Trim();
                    }
                }
            }
        }
예제 #11
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null);

            DobjArtAc = DobjArtifact.LightSource;

            if (DobjArtAc == null)
            {
                if (ActorMonster.IsInRoomLit() || DobjArtifact.IsCarriedByCharacter())
                {
                    PrintCantVerbObj(DobjArtifact);
                }

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

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

                    goto Cleanup;
                }
            }

            if (DobjArtAc.Field1 == 0)
            {
                PrintWontLight(DobjArtifact);

                NextState = Globals.CreateInstance <IMonsterStartState>();

                goto Cleanup;
            }

            if (gGameState.Ls == DobjArtifact.Uid)
            {
                gOut.Write("{0}Extinguish {1} (Y/N): ", Environment.NewLine, DobjArtifact.GetTheName());

                Globals.Buf.Clear();

                rc = Globals.In.ReadField(Globals.Buf, Constants.BufSize02, null, ' ', '\0', false, null, gEngine.ModifyCharToUpper, gEngine.IsCharYOrN, null);

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

                if (Globals.Buf.Length > 0 && Globals.Buf[0] == 'Y')
                {
                    rc = DobjArtifact.RemoveStateDesc(DobjArtifact.GetProvidingLightDesc());

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

                    gGameState.Ls = 0;

                    PrintLightExtinguished(DobjArtifact);
                }

                NextState = Globals.CreateInstance <IMonsterStartState>();

                goto Cleanup;
            }

            if (gGameState.Ls > 0)
            {
                LsArtifact = gADB[gGameState.Ls];

                Debug.Assert(LsArtifact != null && LsArtifact.LightSource != null);

                gEngine.LightOut(LsArtifact);
            }

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

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

            gGameState.Ls = DobjArtifact.Uid;

            PrintLightObj(DobjArtifact);

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
예제 #12
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>();
            }
        }
예제 #13
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null);

            ArtTypes = new ArtifactType[] { ArtifactType.DisguisedMonster, ArtifactType.DeadBody, ArtifactType.BoundMonster, ArtifactType.Weapon, ArtifactType.MagicWeapon };

            DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false);

            if (DobjArtAc == null)
            {
                DobjArtAc = DobjArtifact.GetCategories(0);
            }

            if (DobjArtAc != null && DobjArtAc.Type != ArtifactType.DisguisedMonster && DobjArtifact.Weight <= 900 && !DobjArtifact.IsUnmovable01() && (DobjArtAc.Type != ArtifactType.DeadBody || DobjArtAc.Field1 == 1) && DobjArtAc.Type != ArtifactType.BoundMonster)
            {
                OmitWeightCheck = DobjArtifact.IsCarriedByMonster(ActorMonster, true);

                DobjArtifactCount = 0;

                DobjArtifactWeight = DobjArtifact.Weight;

                if (DobjArtifact.GeneralContainer != null)
                {
                    rc = DobjArtifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.In, true);

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

                    rc = DobjArtifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.On, true);

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

                ActorMonsterInventoryWeight = 0;

                rc = ActorMonster.GetFullInventoryWeight(ref _actorMonsterInventoryWeight, recurse: true);

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

                if (!gEngine.EnforceMonsterWeightLimits || OmitWeightCheck || (DobjArtifactWeight <= ActorMonster.GetWeightCarryableGronds() && DobjArtifactWeight + ActorMonsterInventoryWeight <= ActorMonster.GetWeightCarryableGronds() * ActorMonster.CurrGroupCount))
                {
                    DobjArtifact.SetCarriedByMonster(ActorMonster);

                    Debug.Assert(gCharMonster != null);

                    if (gCharMonster.IsInRoom(ActorRoom))
                    {
                        if (ActorRoom.IsLit())
                        {
                            MonsterName = ActorMonster.EvalPlural(ActorMonster.GetTheName(true), ActorMonster.GetArticleName(true, true, false, true, Globals.Buf01));

                            gOut.Print("{0} picks up {1}.", MonsterName, DobjArtifact.GetTheName());
                        }
                        else
                        {
                            MonsterName = string.Format("An unseen {0}", ActorMonster.CheckNBTLHostility() ? "offender" : "entity");

                            gOut.Print("{0} picks up {1}.", MonsterName, "a weapon");
                        }
                    }

                    // when a weapon is picked up all monster affinities to that weapon are broken

                    FumbleMonsterList = gEngine.GetMonsterList(m => m.Weapon == -DobjArtifact.Uid - 1 && m != ActorMonster);

                    foreach (var monster in FumbleMonsterList)
                    {
                        monster.Weapon = -1;
                    }
                }
            }

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IErrorState>(x =>
                {
                    x.ErrorMessage = string.Format("{0}: NextState == null", Name);
                });
            }
        }
예제 #14
0
        public override void CreateActualModel()
        {
            AvatarModelData data = AvatarModelData.dataMap.GetValueOrDefault(model, null);

            if (data == null)
            {
                Debug.LogError("Model not found: " + model);
                return;
            }
            SubAssetCacheMgr.GetCharacterInstance(data.prefabName,
                                                  (prefab, guid, gameObject) =>
            {
                if (this.Actor)
                {
                    this.Actor.Release();
                }
                if (Transform)
                {
                    AssetCacheMgr.ReleaseLocalInstance(Transform.gameObject);
                }
                GameObject = (gameObject as GameObject);

                Transform                  = GameObject.transform;
                Transform.localScale       = scale;
                Transform.tag              = "Monster";
                Transform.gameObject.layer = 11;    //monster

                sfxHandler = GameObject.AddComponent <SfxHandler>();
                motor      = GameObject.AddComponent <MogoMotorServer>();

                audioSource             = GameObject.AddComponent <AudioSource>();
                audioSource.rolloffMode = AudioRolloffMode.Custom;

                if (m_monsterData.notTurn == 0)
                {
                    motor.SetAngularSpeed(360f);
                }
                else
                {
                    motor.canMove = false;
                    motor.canTurn = false;
                }
                Debug.Log(" m_monsterData.scaleRadius:" + m_monsterData.scaleRadius);
                CharacterController controller = GameObject.GetComponent <CharacterController>();
                controller.radius = m_monsterData.scaleRadius / 100f;
                controller.height = EntityColiderHeight;
                float centerY     = (controller.height > controller.radius * 2) ? (controller.height * 0.5f) : (controller.radius);
                controller.center = new Vector3(0, centerY, 0);
                animator          = GameObject.GetComponent <Animator>();
                //animator.speed = 0.3f;
                ActorMonster ap = GameObject.AddComponent <ActorMonster>();
                ap.theEntity    = this;
                this.Actor      = ap;
                UpdatePosition();
                if (data.originalRotation != null && data.originalRotation.Count == 3)
                {
                    Transform.eulerAngles = new Vector3(data.originalRotation[0], data.originalRotation[1], data.originalRotation[2]);
                }
                else
                {
                    Vector3 targetToLookAt = MogoWorld.thePlayer.Transform.position;
                    Transform.LookAt(new Vector3(targetToLookAt.x, Transform.position.y, targetToLookAt.z));
                }
                base.CreateModel();
                animator.applyRootMotion = false;

                #region Shader
                if (ShaderData.dataMap.ContainsKey(m_monsterData.shader) &&
                    (GameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true) != null || GameObject.GetComponentsInChildren <MeshRenderer>(true) != null))
                {
                    MogoFXManager.Instance.SetObjShader(GameObject, ShaderData.dataMap[m_monsterData.shader].name, ShaderData.dataMap[m_monsterData.shader].color);
                    MogoFXManager.Instance.AlphaFadeIn(GameObject, 0.3f);
                }
                #endregion

                if (data.scale > 0)
                {
                    Transform.localScale = new Vector3(data.scale, data.scale, data.scale);
                }
                try
                {
                    if (m_monsterData != null && m_monsterData.bornFx != null && PlayBornFX)
                    {
                        foreach (var item in m_monsterData.bornFx)
                        {
                            sfxHandler.HandleFx(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
                uint waitTime = (uint)m_monsterData.bornTime;
                if (waitTime <= 1)    //容错
                {
                    waitTime = 3000;
                }
                BornedHandler();
                Actor.ActChangeHandle = ActionChange;
            }
                                                  );
        }
예제 #15
0
        public virtual void ProcessArtifact(IArtifact artifact, IArtifactCategory ac, ref bool nlFlag)
        {
            RetCode rc;

            Debug.Assert(artifact != null);

            Debug.Assert(ac != null);

            if (ac.Type == ArtifactType.DisguisedMonster)
            {
                ProcessAction(() => gEngine.RevealDisguisedMonster(ActorRoom, artifact), ref nlFlag);
            }
            else if (artifact.Weight > 900)
            {
                ProcessAction(() => PrintDontBeAbsurd(), ref nlFlag);
            }
            else if (artifact.IsUnmovable01())
            {
                ProcessAction(() => PrintCantVerbThat(artifact), ref nlFlag);
            }
            else
            {
                DobjArtifactCount = 0;

                DobjArtifactWeight = artifact.Weight;

                if (artifact.GeneralContainer != null)
                {
                    rc = artifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.In, true);

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

                    rc = artifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.On, true);

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

                ActorMonsterInventoryWeight = 0;

                rc = ActorMonster.GetFullInventoryWeight(ref _actorMonsterInventoryWeight, recurse: true);

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

                if (ac.Type == ArtifactType.DeadBody && ac.Field1 != 1)
                {
                    ProcessAction(() => PrintBestLeftAlone(artifact), ref nlFlag);
                }
                else if (!OmitWeightCheck && (DobjArtifactWeight + ActorMonsterInventoryWeight > ActorMonster.GetWeightCarryableGronds()))
                {
                    ProcessAction(() => PrintTooHeavy(artifact), ref nlFlag);
                }
                else if (ac.Type == ArtifactType.BoundMonster)
                {
                    ProcessAction(() => PrintMustBeFreed(artifact), ref nlFlag);
                }
                else
                {
                    WeaponAffinityMonster = gEngine.GetMonsterList(m => m.IsInRoom(ActorRoom) && m.Weapon == -artifact.Uid - 1 && m != ActorMonster).FirstOrDefault();

                    if (WeaponAffinityMonster != null)
                    {
                        ProcessAction(() => PrintObjBelongsToActor(artifact, WeaponAffinityMonster), ref nlFlag);
                    }
                    else
                    {
                        IsCarriedByContainer = artifact.IsCarriedByContainer();

                        artifact.SetCarriedByCharacter();

                        if (NextState is IRequestCommand)
                        {
                            PrintReceived(artifact);
                        }
                        else if (NextState is IRemoveCommand || IsCarriedByContainer)
                        {
                            PrintRetrieved(artifact);
                        }
                        else
                        {
                            PrintTaken(artifact);
                        }

                        nlFlag = true;
                    }
                }
            }
        }
예제 #16
0
        public override void Execute()
        {
            Debug.Assert(DropAll || DobjArtifact != null);

            if (DobjArtifact != null)
            {
                if (DobjArtifact.IsWornByCharacter())
                {
                    PrintWearingRemoveFirst(DobjArtifact);

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

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

                    goto Cleanup;
                }
            }

            ProcessLightSource();

            DroppedArtifactList = DropAll ? ActorMonster.GetCarriedList() : new List <IArtifact>()
            {
                DobjArtifact
            };

            if (DroppedArtifactList.Count <= 0)
            {
                gOut.Print("There's nothing for you to drop.");

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            foreach (var artifact in DroppedArtifactList)
            {
                ProcessArtifact(artifact);
            }

            gOut.WriteLine();

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
예제 #17
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;
                });
            }
        }
예제 #18
0
        public override void ProcessEvents(EventType eventType)
        {
            if (eventType == EventType.AfterCastSpellCheck)
            {
                Func <IArtifact, bool> findDeadBodiesFunc = a => a.DeadBody != null && (a.IsCarriedByCharacter() || a.IsInRoom(ActorRoom));

                var artifactList = gEngine.GetArtifactList(findDeadBodiesFunc);

                do
                {
                    PowerEventRoll = gEngine.RollDice(1, 6, 0);
                }while (PowerEventRoll == 1 && artifactList.Count <= 0);

                var rl = gEngine.RollDice(1, 100, 0);

                switch (PowerEventRoll)
                {
                case 1:

                    gEngine.ResurrectDeadBodies(ActorRoom, findDeadBodiesFunc);

                    break;

                case 2:

                    var processed = false;

                    artifactList = ActorMonster.GetCarriedList();

                    foreach (var artifact in artifactList)
                    {
                        if (rl > 80)
                        {
                            gOut.Print("{0} disappear{1}!", artifact.GetTheName(true), artifact.EvalPlural("s", ""));

                            gOut.EnableOutput = false;

                            var dropCommand = Globals.CreateInstance <IDropCommand>(x =>
                            {
                                x.ActorMonster = ActorMonster;

                                x.ActorRoom = ActorRoom;

                                x.Dobj = artifact;
                            });

                            dropCommand.Execute();

                            gOut.EnableOutput = true;

                            artifact.SetInLimbo();

                            processed = true;

                            break;
                        }

                        rl = gEngine.RollDice(1, 100, 0);
                    }

                    if (!processed)
                    {
                        for (var i = 0; i < gGameState.ImportedArtUidsIdx; i++)
                        {
                            var artifact = gADB[gGameState.ImportedArtUids[i]];

                            Debug.Assert(artifact != null);

                            if (artifact.GeneralWeapon != null)
                            {
                                if (rl > 50)
                                {
                                    Globals.Buf.SetFormat("{0}", artifact.GetTheName(true));

                                    gEngine.GetPossessiveName(Globals.Buf);

                                    gOut.Print("{0} complexity goes down!", Globals.Buf.ToString());

                                    var dec = gEngine.RollDice(1, 5, 4);

                                    artifact.GeneralWeapon.Field1 -= dec;

                                    if (artifact.GeneralWeapon.Field1 < Constants.MinWeaponComplexity)
                                    {
                                        artifact.GeneralWeapon.Field1 = Constants.MinWeaponComplexity;
                                    }

                                    processed = true;

                                    break;
                                }

                                rl = gEngine.RollDice(1, 100, 0);
                            }
                        }
                    }

                    if (!processed)
                    {
                        var weaponValues = EnumUtil.GetValues <Weapon>();

                        foreach (var wv in weaponValues)
                        {
                            var weapon = gEngine.GetWeapons(wv);

                            Debug.Assert(weapon != null);

                            if (rl > 50)
                            {
                                gOut.Print("Your {0} ability went down!", weapon.Name);

                                var dec = gEngine.RollDice(1, 5, 4);

                                gCharacter.ModWeaponAbilities(wv, -dec);

                                if (gCharacter.GetWeaponAbilities(wv) < weapon.MinValue)
                                {
                                    gCharacter.SetWeaponAbilities(wv, weapon.MinValue);
                                }

                                processed = true;

                                break;
                            }

                            rl = gEngine.RollDice(1, 100, 0);
                        }
                    }

                    if (!processed)
                    {
                        gOut.Print("A large flame erupts from nowhere, which burns you badly.");

                        var combatSystem = Globals.CreateInstance <ICombatSystem>(x =>
                        {
                            x.SetNextStateFunc = s => NextState = s;

                            x.DfMonster = ActorMonster;

                            x.OmitArmor = true;
                        });

                        combatSystem.ExecuteCalculateDamage(1, 6);
                    }

                    break;

                case 3:

                    if (rl > 80)
                    {
                        gOut.Print("You have been healed!");

                        ActorMonster.DmgTaken = 0;
                    }
                    else
                    {
                        gOut.Print("You are knocked to the ground by a strong gust of wind.");

                        var combatSystem = Globals.CreateInstance <ICombatSystem>(x =>
                        {
                            x.SetNextStateFunc = s => NextState = s;

                            x.DfMonster = ActorMonster;

                            x.OmitArmor = true;
                        });

                        combatSystem.ExecuteCalculateDamage(1, 5);
                    }

                    break;

                case 4:

                    gOut.Print("You feel a small gust of wind hit your face, but nothing else.");

                    break;

                case 5:

                    if (rl > 80)
                    {
                        gOut.Print("All your weapon abilities went up!");

                        var weaponValues = EnumUtil.GetValues <Weapon>();

                        foreach (var wv in weaponValues)
                        {
                            var weapon = gEngine.GetWeapons(wv);

                            Debug.Assert(weapon != null);

                            var inc = gEngine.RollDice(1, 5, 0);

                            gCharacter.ModWeaponAbilities(wv, inc);

                            if (gCharacter.GetWeaponAbilities(wv) > weapon.MaxValue)
                            {
                                gCharacter.SetWeaponAbilities(wv, weapon.MaxValue);
                            }
                        }
                    }
                    else
                    {
                        gOut.Print("A flash of light appears in the distance but nothing happens.");
                    }

                    break;

                default:

                    if (rl > 90)
                    {
                        gOut.Print("You just forgot all of your spells!");

                        var spellValues = EnumUtil.GetValues <Spell>();

                        foreach (var spell in spellValues)
                        {
                            gCharacter.SetSpellAbilities(spell, 0);

                            gGameState.SetSa(spell, 0);
                        }
                    }
                    else
                    {
                        gOut.Print("A puff of smoke rises from nowhere.");
                    }

                    break;
                }

                GotoCleanup = true;

                goto Cleanup;
            }
            else
            {
                base.ProcessEvents(eventType);
            }

Cleanup:

            ;
        }