Пример #1
0
 public void SetStoryAll(StoryHolderScript s)
 {
     SetStory(s);
     if (clone != null)
     {
         clone.SetStory(s);
     }
     if (parentText != null)
     {
         parentText.SetStory(s);
     }
 }
Пример #2
0
    // returns an array of GameObjects that have StoryHandlerScript components
    // these components are used to populate the new stories for any given week
    public StoryHolderScript[] GetRandomStories(int numberToGet)
    {
        // if there are not enough stories, reduce the number of required stories
        // set script variable last to true, denoting that there are no more
        // updates to be given
        if (numberToGet >= stories.Count)
        {
            numberToGet = stories.Count - 1;
            last        = true;
        }
        StoryHolderScript[] returnObjects = new StoryHolderScript[numberToGet];
        GameObject          obj;
        bool isStillDependent = false;

        // get random stories
        for (int i = 0; i < numberToGet; i++)
        {
            int index = Random.Range(0, stories.Count);
            obj = stories[index];
            // check dependencies, if the dependency is 0, no dependency exists

            /*	int[] dependencies = obj.GetComponent<StoryHolderScript>().dependencies;
             *      // if this is the last set, ignore dependencies
             *      if(!last){
             *              for(int j = 0; j < dependencies.Length; j++){
             *                      if(dependencies[j] != 0){
             *                              if(!givenIndexList.Contains (dependencies[j])){
             *                                      isStillDependent = true;
             *                                      j = dependencies.Length;
             *                              }
             *                      }
             *              }
             *      }*/
            // if there are no remaining dependencies or this is the last set
            if (!isStillDependent)
            {
                returnObjects[i] = obj.GetComponent <StoryHolderScript>();
                givenStories.Add(obj);
                givenIndexList.Add(obj.GetComponent <StoryHolderScript>().index);
                stories.RemoveAt(index);
            }
            else                 // otherwise decrement count and search again
            {
                i--;
            }
        }
        return(returnObjects);
    }
Пример #3
0
    public void SetStory(StoryHolderScript s)
    {
        storyText    = s.storyText;
        credibility  = s.credibility;        //credibility effect of the story in the range (-1, 1)
        ratingEffect = s.ratingEffect;       //this can either add to a % rating or to a total rating against fake stations or a score
        //we can store the world effects as an array with set positions, as a dictionary with name lookup, or as a list of variables
        //range of (-1, 1) added to the current country effects
        nAmericaEffect   = s.nAmericaEffect;
        sAmericaEffect   = s.sAmericaEffect;
        europeEffect     = s.europeEffect;
        africaEffect     = s.africaEffect;
        asiaEffect       = s.asiaEffect;
        oceaniaEffect    = s.oceaniaEffect;
        middleEastEffect = s.middleEastEffect;
        antarcticaEffect = s.antarcticaEffect;

        int index = s.index;

        int[] dependencies = s.dependencies;
        init();
    }
Пример #4
0
    // Imports news stories from the stories.txt file and palces them each as
    // a StoryHandlerScript on a GameObject in an array of GameObjects
    public void Load()
    {
        StreamReader reader   = new StreamReader(path);
        string       line     = "";
        string       text     = "";
        string       category = "";
        int          ratings  = 0;

        int[] worldState  = new int[8];
        int   credibility = 0;
        int   index       = 0;

        int[] dependencies = new int[5];
        bool  first        = true;

        // while line exists and is not the first line
        do
        {
            line = reader.ReadLine();
            if (line != null && !first)
            {
                GameObject obj = new GameObject();
                obj.AddComponent <StoryHolderScript> ();
                StoryHolderScript story = obj.GetComponent <StoryHolderScript> ();
                // split the line into substring segments
                string[] subs = line.Split('|');

                // assign story variables
                text     = subs[0];
                category = subs[1];
                int.TryParse(subs[2], out ratings);
                string[] worldStateS = subs[3].Split(',');
                for (int i = 0; i < 8; i++)
                {
                    int.TryParse(worldStateS[i], out worldState[i]);
                }
                int.TryParse(subs[4], out credibility);
                int.TryParse(subs[5], out index);
                //	string[] dependenciesS = subs[6].Split (',');
                //	for(int j = 0; j < dependenciesS.Length; j++){
                //		int.TryParse (dependenciesS[j], out dependencies[j]);
                //dependencies[j];
                //	}

                // set story variables
                story.storyText    = text;
                story.credibility  = credibility;
                story.ratingEffect = ratings;

                story.nAmericaEffect   = worldState[0];
                story.sAmericaEffect   = worldState[1];
                story.europeEffect     = worldState[2];
                story.africaEffect     = worldState[3];
                story.asiaEffect       = worldState[4];
                story.oceaniaEffect    = worldState[5];
                story.middleEastEffect = worldState[6];
                story.antarcticaEffect = worldState[7];

                story.index = index;
                //	story.dependencies = dependencies;

                // add the object to stories list
                Debug.Log(dependencies[0]);
                stories.Add(obj);
            }
            first = false;
        }while(line != null);
    }