Exemplo n.º 1
0
 private static void ExecActionInFilteredListOfPost(IEnumerable <Post> posts, PostCondition AnyCondition, ActionInPost AnyAction)
 {
     foreach (Post post in posts)
     {
         if (AnyCondition(post))
         {
             AnyAction(post);
         }
     }
 }
Exemplo n.º 2
0
    void StorySetup()
    {
        Storylet      introduction = new Storylet("Introduction", StoryArc.ACTI);
        PostCondition introPost    = new PostCondition();

        introPost.position = "Kids Room";
        introduction.AddTileDisplayText("Introduction");
        introduction.SetText("'Huf.. huf... huf..', You wake up sweating inside your room. You look at the walls and feel them closing in.");
        introduction.AddPostcondition(introPost);


        PreConditions part1aPre = new PreConditions("Kids Room");
        Storylet      part1a    = new Storylet("Escape1", StoryArc.ACTI);

        part1a.AddTileDisplayText("Crawl deeper in your blanket");
        part1a.SetText("You cover yourself with your blanket, and start counting down from 100." +
                       " Trying to calm yourself.\n You suddenly hear a loud boom sound. Curious to what is happening, You grab your flashlight and step outside, your room to see what's happening ");


        PostCondition part1aPostC = new PostCondition();

        part1aPostC.updateToInventory.Add("FlashLight", 1);
        part1aPostC.position = "Outside";
        part1aPostC.charachterAttributes.Add("Adventurous", 2);
        part1a.AddPostcondition(part1aPostC);


        //Completed Part1A: -> Crawl Deeper in your blanker -> Outside with FlashLight
        part1a.AddPreconditions(part1aPre);
        part1a.AddPostcondition(part1aPostC);

        PreConditions part1bPre = new PreConditions("Kids Room");
        Storylet      part1b    = new Storylet("Escape2", StoryArc.ACTI);

        part1b.AddTileDisplayText("Run to your parents room");
        part1b.SetText("You grab your flashlight and run to your parents room, feeling safe only when you reach there, you climb on their bed and drift off to sleep. " +
                       "\n You are woken up to commotion and see your dad walking outside with your flashlight, \n" +
                       "curious you follow him outside.");

        PostCondition part1bPostC = new PostCondition();

        part1bPostC.actors.Add("Dad");
        part1bPostC.position = "Outside";

        //Completed Part1B: -> Run to Parents -> Outside with Dad without FlashLight
        part1b.AddPreconditions(part1bPre);
        part1b.AddPostcondition(part1bPostC);

        storylets.Add(introduction.GetName(), introduction);
        storylets.Add(part1a.GetName(), part1a);
        storylets.Add(part1b.GetName(), part1b);
    }
Exemplo n.º 3
0
 public RoutineDeclaration(
     Identifier name,
     bool isForeign,
     IEnumerable <Parameter> parameters,
     UnitRef returnType,
     IEnumerable <Entity> body,
     PreCondition preCondition   = null,
     PostCondition postCondition = null
     )
     : base(name)
 {
     IsForeign = isForeign;
     Parameters.AddRange(parameters);
     ReturnType = returnType;
     Body.AddRange(body);
     PreCondition  = preCondition ?? new PreCondition();
     PostCondition = postCondition ?? new PostCondition();
 }
Exemplo n.º 4
0
    //Loads Asset Text at the beginning of the Game Start from a .csv file
    void AssetLoad()
    {
        var file = Resources.Load <TextAsset>("sdata");

        string[] data = file.text.Split(new char[] { '\n' });

        for (int i = 1; i < data.Length - 1; i++)
        {
            string[]      row            = data[i].Split(new char[] { ',' });
            Storylet      storylet       = new Storylet();
            PreConditions preConditions  = new PreConditions();
            PostCondition postConditions = new PostCondition();
            storylet.SetName(row[1]);

            row[2] = row[2].Replace(";", ",");
            row[2] = row[2].Replace("new-l", "\n");
            storylet.SetText(row[2]);
            storylet.AddTileDisplayText(row[3]);
            preConditions.position = row[4];

            int pre_mood;
            if (int.TryParse(row[5], out pre_mood))
            {
                preConditions.SetCharachterMood(pre_mood);
            }
            if (row[6].Contains(";") || row[6].Contains(":"))
            {
                string[] storyReq = row[6].Split(new char[] { ';' });
                foreach (string req in storyReq)
                {
                    string[] point = req.Split(new char[] { ':' });
                    int      value;
                    if (int.TryParse(point[1], out value))
                    {
                        KeyValuePair <string, int> pair = new KeyValuePair <string, int>(point[0], value);
                        preConditions.AddStoryletReq(pair);
                    }
                }
            }
            postConditions.position = row[7];

            int post_mood;
            if (int.TryParse(row[8], out post_mood))
            {
            }

            if (row[9].Contains(";") || row[9].Contains(":"))
            {
                string[] charAttib = row[9].Split(new char[] { ';' });
                foreach (string attrib in charAttib)
                {
                    string[] point = attrib.Split(new char[] { ':' });
                    int      value;
                    if (int.TryParse(point[1], out value))
                    {
                        postConditions.charachterAttributes.Add(point[0], value);
                    }
                }
            }

            if (row[10].Contains(";") || row[10].Contains(":"))
            {
                string[] inventory = row[10].Split(new char[] { ';' });
                foreach (string item in inventory)
                {
                    string[] point = item.Split(new char[] { ':' });

                    int value;
                    if (int.TryParse(point[1], out value))
                    {
                        charachter.UpdateInventory(point[0], value);
                    }
                }
            }

            string[] actors = row[11].Split(new char[] { ';' });
            foreach (string actor in actors)
            {
                string result = actor.Trim();
                if (!result.Equals("*"))
                {
                    postConditions.actors.Add(result);
                }
            }

            storylet.AddPreconditions(preConditions);
            storylet.AddPostcondition(postConditions);
            storylets.Add(storylet.GetName(), storylet);
        }

        Debug.Log(storylets.Count);
        foreach (KeyValuePair <string, Storylet> pair in storylets)
        {
            Debug.Log(pair.Key);
        }
    }
Exemplo n.º 5
0
 public void AddPostcondition(PostCondition postCondition)
 {
     this.postCondition = postCondition;
 }
Exemplo n.º 6
0
    public void AssetLoad()
    {
        var file = Resources.Load <TextAsset>(inputFile);

        string[] data = file.text.Split(new char[] { '\n' });


        for (int i = 3; i < data.Length - 1; i++)
        {
            string[]      row            = data[i].Split(new char[] { ',' });
            Storylet1     storylet       = new Storylet1();
            PreConditions preConditions  = new PreConditions();
            PostCondition postConditions = new PostCondition();
            //Display Text
            storylet.TileDisplayText = row[1];

            //Story Text
            row[2] = row[2].Replace(";", ",");
            row[2] = row[2].Replace("new-l", "\n");
            row[2] = row[2].Replace("DQ", "\"");
            row[2] = row[2].Replace("INSERT_NAME", scene.player_name);
            storylet.StoryletText = row[2];

            //Precondition Level
            if (int.TryParse(row[3], out int pre_level))
            {
                preConditions.level = pre_level;
            }

            //Morality Level
            if (int.TryParse(row[4], out int val))
            {
                storylet.MoralityScale = val;
            }

            //Affected Charachteristics
            if (row[5].Contains(";") || row[5].Contains(":"))
            {
                string[] attributes = row[5].Split(new char[] { ';' });
                foreach (string attribute in attributes)
                {
                    string[] value = attribute.Split(new char[] { ':' });
                    KeyValuePair <string, int> pair = new KeyValuePair <string, int>(value[0], int.Parse(value[1]));
                    storylet.AddCharachterUpdates(pair);
                }
            }

            //Precondition Actor
            string[] actors = row[6].Split(new char[] { ';' });
            foreach (string actor in actors)
            {
                if (!string.IsNullOrEmpty(actor) && !actor.Equals("*"))
                {
                    preConditions.AddActor(actor);
                }
            }


            // Pre Required Player Conditions
            if (row[7].Contains(";") || row[7].Contains(":"))
            {
                string[] reqd_qualities = row[7].Split(new char[] { ';' });
                foreach (string quality in reqd_qualities)
                {
                    string[] value = quality.Split(new char[] { ':' });
                    KeyValuePair <string, int> pair = new KeyValuePair <string, int>(value[0], int.Parse(value[1]));
                    preConditions.AddStoryletReq(pair);
                }
            }

            // Pre Required Position
            row[8] = row[8].Trim();
            preConditions.position = row[8];


            // Post Actors
            if ((row[9].Contains(";") || row[9].Contains(":")) && !row[9].Contains("*"))
            {
                string[] updateActors = row[9].Split(new char[] { ';' });
                foreach (string update in updateActors)
                {
                    if (!string.IsNullOrEmpty(update) && !update.Contains("*"))
                    {
                        postConditions.actors.Add(update);
                    }
                }
            }

            //Post Condition Position
            row[10] = row[10].Trim();
            postConditions.position = row[10];

            //Post Level
            if (int.TryParse(row[11], out int post_level))
            {
                postConditions.level_post = post_level;
            }

            //Dead People
            if ((row[12].Contains(";") || row[12].Contains(":")) && !row[12].Contains("*"))
            {
                string[] updateDeadActors = row[12].Split(new char[] { ';' });
                postConditions.deadActor = updateDeadActors[0];
            }

            //Interactable Obj
            if ((row[13].Contains(";") || row[13].Contains(":")) && !row[13].Contains("*"))
            {
                string[] obj = row[13].Split(new char[] { ';' });
                postConditions.interactableObj = obj[0];
            }

            storylet.Precondition  = preConditions;
            storylet.Postcondition = postConditions;
            storylets.Add(storylet.TileDisplayText, storylet);
        }

        //foreach (KeyValuePair<string, Storylet1> storylet in storylets)
        //{
        //    Debug.Log(storylet.Key);
        //}
    }