示例#1
0
        internal void ToXML(XmlWriter writer)
        {
            writer.WriteStartElement("Profile");
            foreach (string key in m_profile.Keys)
            {
                writer.WriteStartElement("TrackedValue");
                TrackedValue value = m_profile[key];
                writer.WriteAttributeString("Name", key);
                writer.WriteAttributeString("Minimum", value.m_min.ToString("G"));
                writer.WriteAttributeString("Maximum", value.m_max.ToString("G"));
                writer.WriteAttributeString("Value", value.m_currentValue.ToString("G"));
                writer.WriteAttributeString("Type", value.m_type.ToString());
                writer.WriteAttributeString("AdditionCount", value.m_additionCount.ToString());
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteStartElement("LockedValues");
            foreach (string key in m_lockedOutputs.Keys)
            {
                writer.WriteStartElement("Query");
                writer.WriteStartAttribute("Name", key);
                foreach (string lockedName in m_lockedOutputs[key])
                {
                    writer.WriteElementString("Lock", lockedName);
                }
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
示例#2
0
        internal CFProfile(XmlNode node)
        {
            m_profile = new Dictionary <string, TrackedValue>();
            XmlNode profileNodes = node.SelectSingleNode("Profile");

            foreach (XmlNode skill in profileNodes.ChildNodes)
            {
                float        min       = float.Parse(skill.Attributes["Minimum"].InnerText);
                float        max       = float.Parse(skill.Attributes["Maximum"].InnerText);
                string       name      = skill.Attributes["Name"].InnerText;
                ValueType    valueType = (ValueType)Enum.Parse(typeof(ValueType), skill.Attributes["Type"].InnerText, true);
                TrackedValue value     = new TrackedValue(min, max, name, valueType)
                {
                    m_currentValue  = float.Parse(skill.Attributes["Value"].InnerText),
                    m_additionCount = int.Parse(skill.Attributes["AdditionCount"].InnerText)
                };
                m_profile.Add(name, value);
            }
            m_lockedOutputs = new Dictionary <string, List <string> >();
            XmlNode lockNodes = node.SelectSingleNode("LockedValues");

            foreach (XmlNode query in lockNodes.ChildNodes)
            {
                string name = query.Attributes["Name"].InnerText;
                m_lockedOutputs.Add(name, new List <string>());
                foreach (XmlNode locke in query.ChildNodes)
                {
                    m_lockedOutputs[name].Add(locke.InnerText);
                }
            }
        }
示例#3
0
            public float CalculateDifficulty(TrackedValue[] currentValues, StringBuilder sb)
            {
                sb.Append(returnString);
                sb.Append(":\n");
                float sharedValues    = 0f;
                float totalDifficulty = 0.0f;                 //How many shared keys are used in the average

                for (int j = 0; j < currentValues.Length; j++)
                {
                    TrackedValue val = currentValues[j];
                    if (!queryValues.ContainsKey(val.m_name))
                    {
                        continue;
                    }
                    Weight weight = queryValues[val.m_name];
                    sharedValues += weight.multiplier;
                    //Get the associated queryValues key based on the currentValue[j]
                    float delta = val.m_currentValue - weight.value;
                    //Get this delta as a percentage based on min and max
                    float difficulty         = delta / (val.m_max - val.m_min);
                    float weightedDifficulty = (difficulty * Math.Abs(difficulty)) * weight.multiplier;
                    totalDifficulty += weightedDifficulty;

                    sb.Append('\t');
                    sb.Append(val.m_name);
                    sb.Append(':');
                    sb.Append((difficulty).ToString("G"));
                    sb.Append('/');
                    sb.Append((weightedDifficulty).ToString("G"));
                    sb.Append('\n');
                }
                float averageDifficulty = totalDifficulty / sharedValues;

                lastDifficulty = averageDifficulty;

                sb.Append("\tTotal: ");
                sb.Append(totalDifficulty.ToString("G"));
                sb.Append(" Average: ");
                sb.Append(averageDifficulty.ToString("G"));
                sb.Append(' ');
                return(averageDifficulty);
            }