Exemplo n.º 1
0
    //gets the parsed infrormation from the default and dataStorage files and parses it to retrieve the flocking rule values.
    public void extractXmlValues(XmlParsedInformation rootNode)
    {
        //get the list of flockingRules and the speed parameter.
        List <XmlParsedInformation> flockingRules = rootNode.getElementsByName("flockingRule");
        XmlParsedInformation        speedElement  = rootNode.getFirstElementByName("speed");

        speed = parseAttribute("speed", "value", speedElement.getAttribute("value"));

        //parse the flocking rules and set the values.
        foreach (XmlParsedInformation element in flockingRules)
        {
            string elementName = element.getAttribute("name");

            switch (elementName)
            {
            case "Alignment":
                _alignment.minDist = parseAttribute(name, "minDist", element.getAttribute("minDist"));
                _alignment.maxDist = parseAttribute(name, "maxDist", element.getAttribute("maxDist"));
                _alignment.scalar  = parseAttribute(name, "scalar", element.getAttribute("scalar"));
                break;

            case "Cohesion":
                _cohesion.minDist = parseAttribute(name, "minDist", element.getAttribute("minDist"));
                _cohesion.maxDist = parseAttribute(name, "maxDist", element.getAttribute("maxDist"));
                _cohesion.scalar  = parseAttribute(name, "scalar", element.getAttribute("scalar"));
                break;

            case "Separation":
                _separation.minDist = parseAttribute(name, "minDist", element.getAttribute("minDist"));
                _separation.maxDist = parseAttribute(name, "maxDist", element.getAttribute("maxDist"));
                _separation.scalar  = parseAttribute(name, "scalar", element.getAttribute("scalar"));
                break;
            }
        }
    }
Exemplo n.º 2
0
    //gets the parsed infrormation from the default and dataStorage files and parses it to retrieve the flocking rule values.
    public void extractXmlValues(XmlParsedInformation rootNode)
    {
        //get the list of flockingRules and the speed parameter.
        List <XmlParsedInformation> flockingRules = rootNode.getElementsByName("flockingRule");
        XmlParsedInformation        speedElement  = rootNode.getFirstElementByName("speed");

        speed = parseAttribute("speed", "value", speedElement.getAttribute("value"));

        //parse the flocking rules and set the values.
        foreach (XmlParsedInformation element in flockingRules)
        {
            string elementName = element.getAttribute("name");

            switch (elementName)
            {
            case "Alignment":
                alignmentMinDist = parseAttribute(name, "minDist", element.getAttribute("minDist"));
                alignmentMaxDist = parseAttribute(name, "maxDist", element.getAttribute("maxDist"));
                alignmentScale   = parseAttribute(name, "scalar", element.getAttribute("scalar"));
                break;

            case "Cohesion":
                cohesionMinDist = parseAttribute(name, "minDist", element.getAttribute("minDist"));
                cohesionMaxDist = parseAttribute(name, "maxDist", element.getAttribute("maxDist"));
                cohesionScale   = parseAttribute(name, "scalar", element.getAttribute("scalar"));
                break;

            case "Separation":
                separationMinDist = parseAttribute(name, "minDist", element.getAttribute("minDist"));
                separationMaxDist = parseAttribute(name, "maxDist", element.getAttribute("maxDist"));
                separationScale   = parseAttribute(name, "scalar", element.getAttribute("scalar"));
                break;
            }
        }
        //set the sliders current values.
        slider_speed.value = speed;

        slider_alignmentMinDist.value = alignmentMinDist;
        slider_alignmentMaxDist.value = alignmentMaxDist;
        slider_alignmentScale.value   = alignmentScale;

        slider_cohesionMinDist.value = cohesionMinDist;
        slider_cohesionMaxDist.value = cohesionMaxDist;
        slider_cohesionScale.value   = cohesionScale;

        slider_separationMinDist.value = separationMinDist;
        slider_separationMaxDist.value = separationMaxDist;
        slider_separationScale.value   = separationScale;
    }