Beispiel #1
0
        //-----------------------------------------------------------------------------------------------
        public void AddOperationInstruction(eInfluenceOpType operationType, float weight, string influenceID, string objectTag)
        {
            MapOperation instructionToAdd = new MapOperation();

            instructionToAdd.OpType      = operationType;
            instructionToAdd.Weight      = weight;
            instructionToAdd.InfluenceID = influenceID;
            instructionToAdd.ObjectTag   = objectTag;

            m_operationInstructions.Add(instructionToAdd);
        }
    //-----------------------------------------------------------------------------------------------
    private static void PopulateMapFormulaFromXmlNodelist(MapFormula formula, XmlNodeList operationList)
    {
        foreach (XmlNode operationInfo in operationList)
        {
            string opTypeAsString = "";
            if (!TryLoadRequiredAttributeFromXmlNode(operationInfo, "Type", ref opTypeAsString))
            {
                continue;
            }

            // Depending on the type, we may be able to early out
            eInfluenceOpType opType = MapOperation.GetOpTypeForString(opTypeAsString);

            if (opType == eInfluenceOpType.INVALID_INFLUENCE_OP)
            {
                Debug.Log("Operation has invalid type attribute.");
                continue;
            }

            // Don't need to grab a map for normalizing
            if (opType == eInfluenceOpType.INFLUENCE_OP_NORMALIZE)
            {
                formula.AddOperationInstruction(opType, 1f, null, null);
                continue;
            }

            string influenceID = "";
            string objectTag   = "";
            if (!TryLoadRequiredAttributeFromXmlNode(operationInfo, "InfluenceID", ref influenceID) ||
                !TryLoadRequiredAttributeFromXmlNode(operationInfo, "ObjectTag", ref objectTag))
            {
                continue;
            }

            float opWeight = TryLoadXmlAttribute(operationInfo, "Weight", MapOperation.DEFAULT_OPERATION_WEIGHT);

            string caseInsensitiveInfluenceID = influenceID.ToLower();
            string caseInsensitiveObjectTag   = objectTag.ToLower();
            formula.AddOperationInstruction(opType, opWeight, caseInsensitiveInfluenceID, caseInsensitiveObjectTag);
        }
    }