示例#1
0
    /// <summary>
    /// Sets constantPlotpoints in dict for a load/save operation. Existing data deleted prior to new data input
    /// </summary>
    /// <param name="listOfStories"></param>
    public void SetConstantPlotpoints(List <ConstantPlotpoint> listOfConstants)
    {
        int counter = 0;

        if (listOfConstants != null)
        {
            dictOfConstantPlotpoints.Clear();
            for (int i = 0; i < listOfConstants.Count; i++)
            {
                ConstantPlotpoint constantPlotpoint = listOfConstants[i];
                if (constantPlotpoint != null)
                {
                    if (string.IsNullOrEmpty(constantPlotpoint.refTag) == false)
                    {
                        AddConstantPlotpoint(constantPlotpoint); counter++;
                    }
                    else
                    {
                        Debug.LogWarningFormat("Invalid constantPlotpoint.refTag (Null or Empty) for listOfConstants[{0}]", i);
                    }
                }
                else
                {
                    Debug.LogWarningFormat("Invalid constantPlotpoint (Null) for listOfConstants[{0}]", i);
                }
            }
            Debug.LogFormat("[Tst] ToolDataManager.cs -> SetConstantPlotpoints: listOfConstantPlotpoints has {0} records, {1} have been loaded into Dict{2}", listOfConstants.Count, counter, "\n");
        }
        else
        {
            Debug.LogError("Invalid listOfConstants (Null)");
        }
    }
示例#2
0
 /// <summary>
 /// deletes specified record from dictOfConstantPlotpoints and returns true if successful, false if not
 /// </summary>
 /// <param name="constant"></param>
 /// <returns></returns>
 public bool RemoveConstantPlotpoint(ConstantPlotpoint constant)
 {
     if (dictOfConstantPlotpoints.ContainsKey(constant.refTag) == true)
     {
         return(dictOfConstantPlotpoints.Remove(constant.refTag));
     }
     return(false);
 }
示例#3
0
 /// <summary>
 /// Add ConstantPlotpoint, overrides existing data in case of duplicates
 /// </summary>
 /// <param name="constant"></param>
 public void AddConstantPlotpoint(ConstantPlotpoint constant)
 {
     try
     { dictOfConstantPlotpoints.Add(constant.refTag, constant); }
     catch (ArgumentNullException)
     { Debug.LogError("Invalid ConstantPlotpoint (Null)"); }
     catch (ArgumentException)
     {
         //exists, override data
         dictOfConstantPlotpoints[constant.refTag] = constant;
         Debug.LogFormat("[Tst] ToolDataManager.cs -> AddConstantPlotpoint: Existing data overriden in dict for \"{0}\"", constant.refTag);
     }
 }
示例#4
0
    /// <summary>
    /// returns a random constant character/object/organisation from a frequency based random selection pool. Could be either game or campaign scope. Returns null if none present or a problem
    /// </summary>
    public ConstantPlotpoint GetRandomConstantCharacter()
    {
        ConstantPlotpoint constantCharacter = null;
        var selection = dictOfConstantPlotpoints.Values.Where(x => x.type != ConstantSummaryType.Plotpoint).ToList();

        if (selection.Count > 0)
        {
            List <ConstantPlotpoint> listOfPool = new List <ConstantPlotpoint>();
            for (int i = 0; i < selection.Count; i++)
            {
                ConstantPlotpoint constantSelection = selection[i];
                if (constantSelection != null)
                {
                    //add entries to the pool based on frequency
                    switch (selection[i].frequency)
                    {
                    case ConstantDistribution.High:
                        listOfPool.Add(constantSelection);
                        listOfPool.Add(constantSelection);
                        listOfPool.Add(constantSelection);
                        break;

                    case ConstantDistribution.Medium:
                        listOfPool.Add(constantSelection);
                        listOfPool.Add(constantSelection);
                        break;

                    case ConstantDistribution.Low:
                        listOfPool.Add(constantSelection);
                        break;
                    }
                }
                else
                {
                    Debug.LogWarningFormat("Invalid constantSelection (Null) for selection[{0}]", i);
                }
            }
            //randomly select from the pool
            constantCharacter = listOfPool[Random.Range(0, listOfPool.Count)];
        }
        return(constantCharacter);
    }