示例#1
0
        private static bool StartNewWriting(Computer ths, Writing writingSkill, BookData.BookGenres genre)
        {
            List <string> randomList = BookData.WrittenBookTitles[genre];

            if (writingSkill.WrittenBookDataList == null)
            {
                writingSkill.WrittenBookDataList = new Dictionary <string, WrittenBookData>();
            }

            int count = 0;

            string key = null;

            while (count < 25)
            {
                key = Common.LocalizeEAString("Gameplay/Excel/Books/WrittenBookTitles:" + RandomUtil.GetRandomObjectFromList(randomList));
                count++;

                if (!Exists(writingSkill, key))
                {
                    break;
                }
            }

            if (Exists(writingSkill, key))
            {
                string oldKey = key;

                int num = 0x1;
                do
                {
                    num++;
                    key = oldKey + " " + num;
                }while (Exists(writingSkill, key));
            }

            if ((SimTypes.IsSelectable(writingSkill.SkillOwner)) || (StoryProgression.Main.GetValue <PromptToTitleOption, bool>()))
            {
                string title = StringInputDialog.Show(Common.Localize("TitleBook:Header", writingSkill.SkillOwner.IsFemale), Common.Localize("TitleBook:Prompt", writingSkill.SkillOwner.IsFemale, new object[] { writingSkill.SkillOwner }), key);
                if (!string.IsNullOrEmpty(title))
                {
                    key = title;
                }
            }

            writingSkill.AddWritingToDataList(key, writingSkill.GetNumPagesForWriting(genre), genre, true, null);
            return(true);
        }
示例#2
0
        public override bool Run()
        {
            string msg = null;

            try
            {
                mStart = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Hours, 3);

                StandardEntry();
                if (!Target.StartComputing(this, SurfaceHeight.Table, true))
                {
                    StandardExit();

                    return(false);
                }

                msg += "A";

                mWritingSkill = Actor.SkillManager.AddElement(SkillNames.Writing) as Writing;

                Target.StartVideo(Computer.VideoType.WordProcessor);
                mStartWritingTime = SimClock.CurrentTime();
                BeginCommodityUpdates();

                bool playFilledEffect = false;
                try
                {
                    if (mWritingSkill.CurrentWriting == null)
                    {
                        msg += "B";

                        BookData.BookGenres choice = mWritingSkill.mNovelistGenre;

                        if (choice == BookData.BookGenres.None)
                        {
                            List <BookData.BookGenres> genres = new List <BookData.BookGenres>();

                            foreach (BookData.BookGenres genre in Enum.GetValues(typeof(BookData.BookGenres)))
                            {
                                if (genre == BookData.BookGenres.None)
                                {
                                    continue;
                                }

                                if (genre == BookData.BookGenres.Biography)
                                {
                                    continue;
                                }

                                if (genre == BookData.BookGenres.Autobiography)
                                {
                                    continue;
                                }

                                if (!Writing.CanWriteGenre(Actor, genre))
                                {
                                    continue;
                                }

                                switch (genre)
                                {
                                case BookData.BookGenres.Horror:
                                case BookData.BookGenres.Poetry:
                                    if (!GameUtils.IsInstalled(ProductVersion.EP7))
                                    {
                                        continue;
                                    }

                                    break;
                                }

                                genres.Add(genre);
                            }

                            if (genres.Count == 0)
                            {
                                return(false);
                            }

                            msg += "C";

                            if ((SimTypes.IsSelectable(mWritingSkill.SkillOwner)) || (StoryProgression.Main.GetValue <PromptForGenreOption, bool>()))
                            {
                                List <GenreOption> choices = new List <GenreOption>();
                                foreach (BookData.BookGenres genre in genres)
                                {
                                    int count = 0;

                                    if (mWritingSkill.WrittenBookGenreCount != null)
                                    {
                                        if (!mWritingSkill.WrittenBookGenreCount.TryGetValue(genre, out count))
                                        {
                                            count = 0;
                                        }
                                    }

                                    choices.Add(new GenreOption(genre, count));
                                }

                                GenreOption option = new CommonSelection <GenreOption>(Common.Localize("ChooseBookGenre:Header", mWritingSkill.SkillOwner.IsFemale), mWritingSkill.SkillOwner.FullName, choices).SelectSingle();
                                if (option != null)
                                {
                                    choice = option.Value;
                                }
                            }

                            msg += "D";

                            if (choice == BookData.BookGenres.None)
                            {
                                choice = RandomUtil.GetRandomObjectFromList(genres);
                            }
                        }

                        msg += "E";

                        if (!StartNewWriting(Target, mWritingSkill, choice))
                        {
                            AnimateSim("WorkTyping");
                            EndCommodityUpdates(false);
                            Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false);
                            StandardExit();

                            return(false);
                        }
                    }

                    msg += "F";

                    AnimateSim("WorkTyping");
                    ProgressMeter.ShowProgressMeter(Actor, 0f, ProgressMeter.GlowType.Weak);

                    playFilledEffect = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), LoopDel, null);
                    ProgressMeter.HideProgressMeter(Actor, playFilledEffect);
                    float points = SimClock.ElapsedTime(TimeUnit.Hours, mStartWritingTime) * Computer.kWritingNovelPointsPerHour;
                    mWritingSkill.AddPoints(points);
                }
                finally
                {
                    EndCommodityUpdates(playFilledEffect);
                }

                msg += "G";

                Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false);
                if (mWritingSkill.IsWritingComplete())
                {
                    WrittenBookData currentWriting = mWritingSkill.CurrentWriting;

                    if (!BookData.BookWrittenDataList.ContainsKey(currentWriting.Title + mWritingSkill.SkillOwner.FullName))
                    {
                        List <Lot> lots = new List <Lot>();

                        if ((!SimTypes.IsSelectable(Actor)) && (!StoryProgression.Main.GetValue <AddBooksToLibraryOption, bool>()))
                        {
                            foreach (Lot lot in LotManager.AllLots)
                            {
                                if (lot.GetMetaAutonomyType == Lot.MetaAutonomyType.Library)
                                {
                                    lots.Add(lot);

                                    lot.mMetaAutonomyType = Lot.MetaAutonomyType.None;
                                }
                            }
                        }

                        try
                        {
                            msg += "H";

                            Target.FinalizeWriting(mWritingSkill);
                        }
                        finally
                        {
                            foreach (Lot lot in lots)
                            {
                                lot.mMetaAutonomyType = Lot.MetaAutonomyType.Library;
                            }
                        }
                    }
                }

                msg += "I";

                StandardExit();

                return(playFilledEffect);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, msg, e);
                return(false);
            }
        }