Example #1
0
        //private QuizFactory quizFactory = new QuizFactory();

        public IEnumerable <Story> FetchStoriesOrImagines(StorySet storySet)
        {
            if (storySet == StorySet.Imagines)
            {
                return(GenerateOrGetImagines());
            }
            else if (storySet == StorySet.StorySet1)
            {
                return(GenerateOrGetStories());
            }
            else
            {
                //return an empty set if this happens, but it shouldn't ever get here
                return(new List <Story>());
            }
        }
    // Use this for initialization
    void Start()
    {
        StoryGenerator gen          = GameObject.Find("StoryStuff").GetComponent <StoryGenerator>();
        int            story_number = PlayerPrefs.GetInt("StoryNumber");

        Debug.Log("Story Number " + story_number);
        story = gen.generate_story();
        string[] pieces = { story.story_1, story.story_2, story.story_3, story.story_4 };
        Debug.Log("Story Number " + story_number);
        story_string = pieces[story_number];
        Debug.Log("Story Number " + story_number);
        PlayerPrefs.SetInt("StoryNumber", story_number + 1);
        text            = GameObject.Find("StoryText").GetComponent <Text>();
        story_sentences = get_sentences(story_string);
        text.text       = story_sentences[cur_sentence] as string;
        Crosstales.RTVoice.Speaker.Speak(text.text, GetComponent <AudioSource>(), null, true, 1f, 1, "", 2f);
    }
Example #3
0
 // Use this for initialization
 void Start()
 {
     //PlayerPrefs.SetInt("NumPlayers", 4);
     numPlayers    = PlayerPrefs.GetInt("NumPlayers");
     players       = GameObject.FindGameObjectsWithTag("Player");
     story         = GameObject.Find("StoryStuff").GetComponent <StoryGenerator>().generate_story();
     question_text = GameObject.Find("QuestionText").GetComponent <Text>();
     answer_a      = GameObject.Find("button_A_text").GetComponent <Text>();
     answer_b      = GameObject.Find("button_B_text").GetComponent <Text>();
     answer_x      = GameObject.Find("button_X_text").GetComponent <Text>();
     answer_y      = GameObject.Find("button_Y_text").GetComponent <Text>();
     questions     = new Question[4];
     questions[0]  = story.question_1;
     questions[1]  = story.question_2;
     questions[2]  = story.question_3;
     questions[3]  = story.question_4;
     set_cur_question();
 }
Example #4
0
        //private IEnumerable<Story> ListOfImagines;

        /// <summary>
        /// This class is shared between the stories and the imagines. Stories have one number set, and imagines have another
        /// </summary>
        /// <param name="storySet">Pass in the number corresponding to the imagine or story set</param>
        public Imagines(StorySet storySet)
        {
            //NavigationPage.SetHasNavigationBar(this, false);

            var imaginesData = new StoryFactory().FetchStoriesOrImagines(storySet);

            InitializeComponent();

            if (storySet == StorySet.Imagines)
            {
                StoryMenuLabel.Text = "Imagines";
            }
            else if (storySet == StorySet.StorySet1)
            {
                StoryMenuLabel.Text = "Stories";
            }

            ListOfImagines.ItemsSource = imaginesData;
        }
    StorySet make_story()
    {
        StorySet story = new StorySet();

        story.title = make_title();
        // These are the various options for all of the things.
        string[] adjectives = { "pubescent",   "omnivorous",      "vegetarian",   "aloof",     "forgetful", "absurd",
                                "carnivorous", "powerful",        "frightening",  "religious", "sweaty",    "demonic","first",
                                "second",      "10,000 year old", "fourty third", "prime",     "hungry" };

        string[] occupations = { "explorer",   "author", "king", "general", "inventor", "explorer", "professor", "president", "plantation owner",
                                 "researcher", "computer" };

        // options for the names of the main character.
        string[] names_one        = { "Schwifty Von Amrack", "his", "he", "him" };
        string[] names_two        = { "Indiana Jones", "his", "he", "him" };
        string[] names_thr        = { "Amelia Earhart", "her", "she", "her" };
        string[] names_fou        = { "Ada Lovelace", "her", "she", "her" };
        string[] names_fiv        = { "Arsene Cagliostro", "his", "he", "him" };
        string[] names_six        = { "Michelle Obama", "her", "she", "her" };
        string[] names_sev        = { "Matthew Hibbs", "his", "he", "him" };
        string[] names_eig        = { "Hilary Clinton", "her", "she", "her" };
        string[] names_nin        = { "Jesus Christ", "his", "he", "him" };
        string[] names_ten        = { "Kazi Azrul", "her", "she", "her" };
        string[] names_non_object = { "HAL 9000", "its", "it", "it" };

        string[][] names = { names_one, names_two, names_thr, names_fou, names_fiv, names_six,
                             names_sev, names_eig, names_nin, names_ten, names_non_object };
        string[]   items  = { "medallion", "staff", "statute", "ark", "scepter", "sword", "necklace" };
        string[]   gods   = { "Amadeus", "Amaduso", "God", "Shiba", "Shiba Uno", "Pan", "Balphegor", "Hitler" };
        string[]   curses = { "burned alive", "crippled",  "mummified",
                              "stoned",         "calcified", "poked",    "put to sleep","drowned",  "befuddled", "staked", "killed", "abandoned",
                              "forgotten",      "cleaned",   "absorbed", "swallowed",  "pacified", "breast fed by a huge angry god" };
        string[]   minions   = { "minions", "priests", "servants", "zombies", "secret police", "foot-soliders", "altar boys", "vampires", "nazis" };
        string[]   values    = { "millions", "thousands", "tens", "billions", "trillions", "oodles", "piles", "baker's dozens" };
        string[]   locations = { "great desert of mushu",                 "terrible islands of the Skitz",           "magnificent puddles of Elusis",
                                 "temple of Apollo",                        "grave of Jesus",                          "grave of Isaac Newton",                 "one bar in Wyoming with good liquor",
                                 "grave of " + get_random(gods) as string,  "grave of " + get_random(gods) as string,  "grave of " + get_random(gods) as string,
                                 "temple of " + get_random(gods) as string, "temple of " + get_random(gods) as string, "statute to " + get_random(gods) as string };
        string[]   servants  = { "man-bear servant", "shark-headed assistant", "long-nosed manservant", "large headed maid", "submarine the Constitution", "demon" };
        string[]   god_types = { "gods", "devils", "eldtrich horrors" };

        string[] hobbies = { "chess session", "running session", "yoga class", "me time", "underwater basket weaving session" };

        string[] deaths = { "burned alive",                                              "fed to wild dogs",                                            "buried alive in hot, acidic sand", "eaten", "curb stomped", "decapitated", "drowned",
                            "beaten to the music of Mozart",                             "sacrificed to the great god " + get_random(gods) as string,
                            "sacrificed to the great god " + get_random(gods) as string, "slaughtered for the great god " + get_random(gods) as string,
                            "murder for the great god " + get_random(gods) as string,    "mummified for the great god " + get_random(gods) as string,
                            "fed to some random " + get_random(minions) as string,       "beaten by some random " + get_random(minions) as string,
                            "eaten by some random " + get_random(minions) as string };
        string[] abandoned = { "on a deserted island",                    "inside a large volcano",                  "on top a huge mountain", "inside of a pyramid", "in the middle of the desert",
                               "near " + get_random(locations) as string, "near " + get_random(locations) as string, "near " + get_random(locations) as string };
        // Thus ends the options
        string[]      story_pieces = new string[4];
        string[][]    questions    = new string[5][];
        MainCharacter mc           = build_main_character(adjectives, occupations, names, servants, items, gods, locations, hobbies);
        GodReq        god_req      = build_god_req(adjectives, god_types);
        Relic         rel          = build_relic(adjectives, items, gods, curses, minions, values, locations);

        story.artifact = rel.item;
        story.story_1  = generate_opening(mc, rel);
        // Questions and answers possibilities for the first question.
        Question[] questions_opening = { build_question_and_answers("What adjective would you use to describe " + mc.name + "?",      mc.adjective,  adjectives),
                                         build_question_and_answers("What did " + mc.he + " discover?",                               rel.item,      items),
                                         build_question_and_answers("What adjective would you use to describe the " + rel.item + "?", rel.adjective, adjectives) };
        story.question_1 = get_random(questions_opening) as Question;
        if (get_bool())
        {
            story.story_2 = generate_cursed(mc, rel);
            Question[] questions_cursed = { build_question_and_answers("How was the " + mc.servant + " cursed?",    rel.c3,     curses),
                                            build_question_and_answers("Who was most trusted by " + mc.name + " ?", mc.servant, servants) };
            story.question_2 = get_random(questions_cursed) as Question;
            if (get_bool())
            {
                Question[] questions_old = { build_question_and_answers("What kind of " + god_req.gods + " did " + mc.name + " pray to?", god_req.adj,  adjectives),
                                             build_question_and_answers("What did " + mc.he + " pray to?",                                god_req.gods, god_types), };
                story.question_3 = get_random(questions_old) as Question;
                story.story_3    = generate_old(mc, rel, god_req);
            }
            else
            {
                Question[] questions_horrible = { build_question_and_answers("What killed " + mc.name + "?", rel.minions, minions),
                                                  build_question_and_answers("How did " + mc.name + " die?", rel.cf,      curses) };
                story.question_3 = get_random(questions_horrible) as Question;
                story.story_3    = generate_horrible(mc, rel);
            }
            // NEED TO MAKE QUESTION FOR ABANDONED.
            string     minion = get_random(minions) as string;
            string     god    = get_random(gods) as string;
            Question[] questions_abandoned = { build_question_and_answers("What were the servants of " + god + "?",  minion, minions),
                                               build_question_and_answers("Who is in charge of the " + minion + "?", god,    gods) };
            story.question_4 = get_random(questions_abandoned) as Question;

            story.story_4 = generate_abandoned(mc, rel, minion, god, story.title[1]);
        }
        else
        {
            //
            // Putting him in a hole in the ground should be replaced with something.
            //
            story.story_2 = generate_scorned(mc, rel, "putting him in a hole in the ground");
            Question[] questions_scorned = { build_question_and_answers("What hobby does " + mc.name + " have?",          mc.hobby, hobbies),
                                             build_question_and_answers("How much money does the " + rel.item + " cost?", rel.val,  values) };
            story.question_2 = get_random(questions_scorned) as Question;
            if (get_bool())
            {
                string first  = get_random(deaths) as string;
                string second = get_random(deaths) as string;
                int    i      = 0;
                while (second == first)
                {
                    second = get_random(deaths) as string;
                    i     += 1;
                    if (i > 1000)
                    {
                        break;
                    }
                }
                string third = get_random(deaths) as string;
                i = 0;
                while (third == second || third == first)
                {
                    third = get_random(deaths) as string;
                    i    += 1;
                    if (i > 1000)
                    {
                        break;
                    }
                }
                story.story_3 = generate_killed(mc, rel, first, second, third);
                Question[] questions_killed = { build_question_and_answers("Who was most trusted by " + mc.name + " ?", mc.servant, servants),
                                                build_question_and_answers("What fate did " + mc.name + " suffer?",     third,      deaths),
                                                build_question_and_answers("What fate was suggested first?",            first,      deaths),
                                                build_question_and_answers("What fate was suggested second?",           second,     deaths) };
                story.question_3 = get_random(questions_killed) as Question;
            }
            else
            {
                string loc = get_random(abandoned) as string;
                story.story_3 = generate_stranded(mc, rel, loc);
                Question[] questions_stranded = { build_question_and_answers("Where was " + mc.name + " left behind?", loc, abandoned) };
                story.question_3 = get_random(questions_stranded) as Question;
            }
            story.story_4 = generate_lost(mc, rel, story.title[1]);
            Question[] questions_lost = { build_question_and_answers("Where was the " + rel.item + " lost?",                     rel.location, locations),
                                          build_question_and_answers("Where was the " + rel.item + "of " + rel.owner + " lost?", rel.location, locations) };
            story.question_4 = get_random(questions_lost) as Question;
        }
        return(story);
    }
Example #6
0
        public StoryPage(Story story)
        {
            Story    = story;
            StoryId  = story.StoryId;
            StorySet = story.StorySetAsEnum;
            //pull the corresponding images out of the database
            var realmFile = Realm.GetInstance(RealmConfiguration.DefaultConfiguration);

            StoryPages = realmFile.All <RealmObjects.StoryPart>().Where(x => x.StoryId.Equals(story.StoryId))
                         .OrderBy(x => x.Order).ToList();
            //get the current user's ID - if we ever want multiple users per device, we'll have to store the user's id in RAM
            var userId = realmFile.All <User>().FirstOrDefault().UserId;

            //init user story transaction
            using (var writer = realmFile.BeginWrite())
            {
                UserStoryTransaction               = new UserStoryReads();
                UserStoryTransaction.StoryId       = StoryId;
                UserStoryTransaction.UserId        = userId;
                UserStoryTransaction.StartReadTime = DateTime.UtcNow;

                //add to the db
                realmFile.Add <UserStoryReads>(UserStoryTransaction);

                writer.Commit();
            }

            InitializeComponent();

            PlayButton.Source          = PAUSE_ICON; //set at the pause icon because this page auto-starts
            PlayButton.HeightRequest   = 40;
            PlayButton.WidthRequest    = 50;
            PlayButton.BorderColor     = Color.Transparent;
            PlayButton.BackgroundColor = Color.Transparent;
            PlayButton.Margin          = 20;

            QuizButton.Source          = "Quizzes.png";
            QuizButton.BackgroundColor = Color.Green;
            QuizButton.IsVisible       = false;

            DurationLabel.Text       = "0:00";
            DurationLabel.FontFamily = Device.RuntimePlatform == Device.Android ? "Comic.ttf#Comic" : "Comic";
            DurationLabel.Margin     = 20;

            CurrentStoryPage = StoryPages.First();
            //story content
            StoryImage.Source = CurrentStoryPage.Image;
            StoryImage.MinimumWidthRequest = DeviceDisplay.MainDisplayInfo.Width;
            StoryImage.Aspect = Aspect.AspectFit;

            player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
            player.Load(story.AudioClip);

            //find the story duration if we haven't already
            if (story.DurationInSeconds <= 0)
            {
                using (var transaction = realmFile.BeginWrite())
                {
                    story.DurationInSeconds = player.Duration;
                    transaction.Commit();
                }
            }

            //kill the realm file to help with memory consumption
            realmFile.Dispose();
            realmFile = null;

            //slider init
            StoryPageSlider.Maximum           = story.DurationInSeconds;
            StoryPageSlider.Minimum           = 0;
            StoryPageSlider.Value             = 0;
            StoryPageSlider.HorizontalOptions = LayoutOptions.FillAndExpand;
            //StoryPageSlider.MinimumWidthRequest = DeviceDisplay.MainDisplayInfo.Width - (PlayButton.Width * 4);
            StoryPageSlider.HeightRequest = 50; // Controls size of area that can grab the slider
            //use drag completed instead of value changed to avoid "stuttering" audio
            StoryPageSlider.DragCompleted += UserDraggedSlider;

            //register action to be taken once the story ends
            player.PlaybackEnded += EndPlayback;
            player.Loop           = false;

            //start the player in a different thread
            var playerThread = new Thread(new ThreadStart(() =>
            {
                //this starts the audio
                player.Play();
            }));

            playerThread.Start();

            PlayButton.Clicked += (sender, args) =>
            {
                //toggle play/pause
                if (player.IsPlaying)
                {
                    player.Pause();
                    PlayButton.Source = PLAY_ICON;
                }
                else
                {
                    player.Play();
                    PlayButton.Source = PAUSE_ICON;
                }
            };

            RefreshStoryPagesTimer();

            QuizButton.Clicked += (sender, args) =>
            {
                //Navigation.PushAsync(new QuizPage(story.Quizzes[quizNum], story.AudioClip));
            };
        }
Example #7
0
    // Use this for initialization
    void Start()
    {
        StoryGenerator gen  = GameObject.Find("TitleMaker").GetComponent <StoryGenerator>();
        int            seed = (int)System.DateTime.Now.Ticks;

        PlayerPrefs.SetInt("RandomSeedStory", seed);
        PlayerPrefs.SetInt("StoryNumber", 0);
        string[] games = { "TitleJacketSmackIt", "IntroScene", "BallsTitleScreen" };
        //string[] games = { "TitleJacketSmackIt", "MainScene", "UsingTilesStory" };
        int f;
        int s;
        int t;

        f = Random.Range(0, 3);
        s = Random.Range(0, 3);
        while (f == s)
        {
            s = Random.Range(0, 3);
        }
        t = Random.Range(0, 3);
        while (s == t || f == t)
        {
            t = Random.Range(0, 3);
        }
        // Show story part 1 before this
        PlayerPrefs.SetString("GameNumber1", games[f]);
        Debug.Log(PlayerPrefs.GetString("GameNumber1"));
        //PlayerPrefs.SetString ("GameNumber1", "UsingTiles");
        // Show story part 2 before this
        PlayerPrefs.SetString("GameNumber2", games[s]);
        Debug.Log(PlayerPrefs.GetString("GameNumber2"));
        // Show story part 3 before this
        PlayerPrefs.SetString("GameNumber3", games[t]);
        Debug.Log(PlayerPrefs.GetString("GameNumber3"));
        // Show story part 4 before this, final piece
        PlayerPrefs.SetString("GameNumber4", "UsingTiles");
        Debug.Log(PlayerPrefs.GetString("GameNumber4"));

        story = gen.generate_story();
        PlayerPrefs.SetString("HiddenTemple", story.title[1]);
        PlayerPrefs.SetString("ArtifactName", story.artifact);
        nounText          = GameObject.Find("NounText").GetComponent <Text>();
        nounText.text     = story.title [0].Substring(0, story.title [0].IndexOf(' '));
        locationText      = GameObject.Find("LocationText").GetComponent <Text> ();
        locationText.text = story.title [1].Replace(" ", "\n");

        Crosstales.RTVoice.Speaker.Speak(nounText.text + " of the " + locationText.text, GetComponent <AudioSource>(), null, true, 0.26f, 1, "", 2f);
        string[] fonts = { "BlackCastleMF", "burrito",
                           "dum1",          "JUNGLEFE","lightmorning",
                           "Luminari",      "Mayan",   "Taibaijan",
                           "Trattatello" };
        string   random_font = get_random(fonts) as string;

        PlayerPrefs.SetString("font_name", random_font);

        Font locationFont = Resources.Load("Fonts/" + random_font) as Font;

        locationText.font = locationFont;
        Font nounFont = Resources.Load("Fonts/" + fonts [(int)Random.Range(0, fonts.Length)]) as Font;

        nounText.font = nounFont;

        Color textColor = Color.HSVToRGB(Random.value, Random.value, Random.Range(0.8f, 1.0f));

        locationText.color = textColor;
        nounText.color     = textColor;
        GameObject.Find("OfTheText").GetComponent <Text> ().color = textColor;
        GameObject.Find("Text").GetComponent <Text> ().color      = textColor;

        GameObject.Find("Image").GetComponent <Image> ().color = Color.HSVToRGB(Random.value, Random.value, 1f);

        PlayerPrefs.Save();
    }