Ejemplo n.º 1
0
        //-----------------------------------------------------------------------------------------------
        public void PerformOperation(MapOperation operation, WorkingMap workingMap)
        {
            if (operation.OpType == eInfluenceOpType.INFLUENCE_OP_NORMALIZE)
            {
                workingMap.Normalize();
                return;
            }

            string  operandMapID     = operation.InfluenceID;
            string  operandObjectTag = operation.ObjectTag;
            BaseMap operandMap       = InfluenceSystem.GetInstance().GetInfluenceMapByIDWithTag(operandMapID, operandObjectTag);

            switch (operation.OpType)
            {
            case eInfluenceOpType.INFLUENCE_OP_ADD:
            {
                workingMap.AddMap(operandMap, operation.Weight);
                break;
            }

            case eInfluenceOpType.INFLUENCE_OP_ADD_INVERSE:
            {
                workingMap.AddMapInverse(operandMap, operation.Weight);
                break;
            }

            case eInfluenceOpType.INFLUENCE_OP_MULTIPLY:
            {
                workingMap.MultiplyMap(operandMap, operation.Weight);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        //-----------------------------------------------------------------------------------------------
        private InfluenceFunction GetInfluenceFunctionFromInfluenceSystem()
        {
            InfluenceSystem   influenceSystemRef       = InfluenceSystem.GetInstance();
            InfluenceFunction functionToUseForTemplate = influenceSystemRef.GetInfluenceFunctionByID(m_influenceID);

            if (functionToUseForTemplate == null)
            {
                throw new ArgumentNullException("influenceIDForTemplate");
            }

            return(functionToUseForTemplate);
        }
Ejemplo n.º 3
0
        // #TODO - does this make sense here?
        //-----------------------------------------------------------------------------------------------
        private void InitializeInfluenceTemplates()
        {
            InfluenceSystem influenceSystemRef = InfluenceSystem.GetInstance();
            Dictionary <string, List <InfluenceTemplate> > templatesToInitialize = influenceSystemRef.InfluenceTemplates;

            foreach (KeyValuePair <string, List <InfluenceTemplate> > namedTemplateList in templatesToInitialize)
            {
                List <InfluenceTemplate> templateList = namedTemplateList.Value;
                foreach (InfluenceTemplate templateToInitialize in templateList)
                {
                    templateToInitialize.InitializeData();
                }
            }
        }
Ejemplo n.º 4
0
        //-----------------------------------------------------------------------------------------------
        public void GenerateInfluenceMaps()
        {
            InfluenceSystem influenceSystemRef = InfluenceSystem.GetInstance();
            List <BaseMap>  baseMapsToGenerate = influenceSystemRef.InfluenceMaps;

            foreach (BaseMap baseMap in baseMapsToGenerate)
            {
                baseMap.Reset();

                List <IInfluenceObject> objectsForMap = influenceSystemRef.GetAllObjectsWithTag(baseMap.ObjectTag);
                if (objectsForMap == null)
                {
                    continue;
                }

                List <InfluenceTemplate> templatesForMap = influenceSystemRef.GetInfluencesTemplatesWithID(baseMap.InfluenceID);
                if (templatesForMap == null)
                {
                    throw new ArgumentNullException("templatesForMap");
                }

                foreach (IInfluenceObject influenceObject in objectsForMap)
                {
                    uint influenceSize = influenceObject.GetTemplateSizeForInfluenceType(baseMap.InfluenceID);
                    InfluenceTemplate templateToApply = GetInfluenceTemplateForSize(templatesForMap, influenceSize);
                    if (templateToApply == null)
                    {
                        throw new ArgumentNullException("templateToApply");
                    }

                    InfluenceObjectWorldPoint objWorldPos = influenceObject.WorldPosition;
                    InfluenceMapPoint         mapPos      = ConvertWorldPosToMapPos(objWorldPos);
                    baseMap.ApplyTemplate(templateToApply, mapPos.x, mapPos.y);
                }
            }
        }