示例#1
0
    bool isSmaller <T>(PrereqPair prereq)
    {
        IStattable stat            = StatsChecker.getPlayerStatByPrereq(prereq);
        bool       isApplicable    = false;
        T          comparisonValue = stat.getValue <T>();
        T          eventValue      = getValue <T>(prereq);

        isApplicable = (Comparer <T> .Default.Compare(comparisonValue, eventValue) < 0) ? true : false;
        return(isApplicable);
    }
 public static IStattable getPlayerStatByPrereq(PrereqPair pair)
 {
     for (int i = 0; i < currentStats.Count; i++)
     {
         if (currentStats[i].ThisStatType == pair.playerStat)
         {
             return(currentStats[i]);
         }
     }
     return(null);
 }
示例#3
0
    static T getValue <T>(PrereqPair prereq)

    {
        Type typeParameterType = typeof(T);

        if (typeParameterType == System.Type.GetType("string"))
        {
            return((T)Convert.ChangeType(prereq.StringComparatorValue, typeof(T)));
        }

        else
        {
            return((T)Convert.ChangeType(prereq.FloatComparatorValue, typeof(T)));
        }
    }