Example #1
0
        private String toXml()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
            sb.Append("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n");
            sb.Append("<plist version=\"1.0\">\n");
            sb.Append("<dict>\n");
            // angle
            AppendKV(sb, 1, "angle", emitAngle.getValue().ToString(), "real");
            // angleVariance
            AppendKV(sb, 1, "angleVariance", emitAngleVar.getValue().ToString(), "real");
            // ??? blendFuncDestination
            AppendKV(sb, 1, "blendFuncDestination", GLBlendFactorForm.transGlBlendFactor((EBlendFactor)Enum.Parse(typeof(EBlendFactor), btnBlendDst.Text)).ToString(), "integer");
            // ??? blendFuncSource
            AppendKV(sb, 1, "blendFuncSource", GLBlendFactorForm.transGlBlendFactor((EBlendFactor)Enum.Parse(typeof(EBlendFactor), btnBlendSrc.Text)).ToString(), "integer");
            // duration
            AppendKV(sb, 1, "duration", emDuration.getValue().ToString(), "real");
            // ??? emitterType TODO confirm 1.0 and 0.0
            AppendKV(sb, 1, "emitterType", (radioEmitterGravity.Checked ? 0.0f : 1.0f).ToString(), "real");
            // finishColorAlpha
            AppendKV(sb, 1, "finishColorAlpha", ((float)(endColor.getA() / 255.0f)).ToString(), "real");
            // finishColorBlue
            AppendKV(sb, 1, "finishColorBlue", ((float)(endColor.getB() / 255.0f)).ToString(), "real");
            // finishColorGreen
            AppendKV(sb, 1, "finishColorGreen", ((float)(endColor.getG() / 255.0f)).ToString(), "real");
            // finishColorRed
            AppendKV(sb, 1, "finishColorRed", ((float)(endColor.getR() / 255.0f)).ToString(), "real");
            // finishColorVarianceAlpha
            AppendKV(sb, 1, "finishColorVarianceAlpha", ((float)(endColorVar.getA() / 255.0f)).ToString(), "real");
            // finishColorVarianceBlue
            AppendKV(sb, 1, "finishColorVarianceBlue", ((float)(endColorVar.getB() / 255.0f)).ToString(), "real");
            // finishColorVarianceGreen
            AppendKV(sb, 1, "finishColorVarianceGreen", ((float)(endColorVar.getG() / 255.0f)).ToString(), "real");
            // finishColorVarianceRed
            AppendKV(sb, 1, "finishColorVarianceRed", ((float)(endColorVar.getR() / 255.0f)).ToString(), "real");
            // finishParticleSize
            AppendKV(sb, 1, "finishParticleSize", finishSize.getValue().ToString(), "real");
            // finishParticleSizeVariance
            AppendKV(sb, 1, "finishParticleSizeVariance", finishSizeVar.getValue().ToString(), "real");
            // gravityx
            AppendKV(sb, 1, "gravityx", emGravityX.getValue().ToString(), "real");
            // gravityy
            AppendKV(sb, 1, "gravityy", emGravityY.getValue().ToString(), "real");
            // maxParticles
            AppendKV(sb, 1, "maxParticles", maxParticles.getValue().ToString(), "real");
            // maxRadius
            AppendKV(sb, 1, "maxRadius", emRadialMaxRadius.getValue().ToString(), "real");
            // maxRadiusVariance
            AppendKV(sb, 1, "maxRadiusVariance", emRadialMaxRadiusVar.getValue().ToString(), "real");
            // minRadius
            AppendKV(sb, 1, "minRadius", emRadialMinRadius.getValue().ToString(), "real");
            // particleLifespan
            AppendKV(sb, 1, "particleLifespan", lifeSpan.getValue().ToString(), "real");
            // particleLifespanVariance
            AppendKV(sb, 1, "particleLifespanVariance", lifeSpanVar.getValue().ToString(), "real");
            // radialAccelVariance
            AppendKV(sb, 1, "radialAccelVariance", emGravityRadialAccelVar.getValue().ToString(), "real");
            // radialAcceleration
            AppendKV(sb, 1, "radialAcceleration", emGravityRadialAccel.getValue().ToString(), "real");
            // rotatePerSecond
            AppendKV(sb, 1, "rotatePerSecond", emRadialDegPerSecond.getValue().ToString(), "real");
            // rotatePerSecondVariance
            AppendKV(sb, 1, "rotatePerSecondVariance", emRadialDegPerSecondVar.getValue().ToString(), "real");
            // rotationEnd
            AppendKV(sb, 1, "rotationEnd", rotationEnd.getValue().ToString(), "real");
            // rotationEndVariance
            AppendKV(sb, 1, "rotationEndVariance", rotationEndVar.getValue().ToString(), "real");
            // rotationStart
            AppendKV(sb, 1, "rotationStart", rotationStart.getValue().ToString(), "real");
            // rotationStartVariance
            AppendKV(sb, 1, "rotationStartVariance", rotationStartVar.getValue().ToString(), "real");
            // sourcePositionVariancex
            AppendKV(sb, 1, "sourcePositionVariancex", emPosXVar.getValue().ToString(), "real");
            // sourcePositionVariancey
            AppendKV(sb, 1, "sourcePositionVariancey", emPosYVar.getValue().ToString(), "real");
            // sourcePositionx
            AppendKV(sb, 1, "sourcePositionx", emPosX.getValue().ToString(), "real");
            // sourcePositiony
            AppendKV(sb, 1, "sourcePositiony", emPosY.getValue().ToString(), "real");
            // speed
            AppendKV(sb, 1, "speed", emGravitySpeed.getValue().ToString(), "real");
            // speedVariance
            AppendKV(sb, 1, "speedVariance", emGravitySpeedVar.getValue().ToString(), "real");
            // startColorAlpha
            AppendKV(sb, 1, "startColorAlpha", ((float)(startColor.getA() / 255.0f)).ToString(), "real");
            // startColorBlue
            AppendKV(sb, 1, "startColorBlue", ((float)(startColor.getB() / 255.0f)).ToString(), "real");
            // startColorGreen
            AppendKV(sb, 1, "startColorGreen", ((float)(startColor.getG() / 255.0f)).ToString(), "real");
            // startColorRed
            AppendKV(sb, 1, "startColorRed", ((float)(startColor.getR() / 255.0f)).ToString(), "real");
            // startColorVarianceAlpha
            AppendKV(sb, 1, "startColorVarianceAlpha", ((float)(startColorVar.getA() / 255.0f)).ToString(), "real");
            // startColorVarianceBlue
            AppendKV(sb, 1, "startColorVarianceBlue", ((float)(startColorVar.getB() / 255.0f)).ToString(), "real");
            // startColorVarianceGreen
            AppendKV(sb, 1, "startColorVarianceGreen", ((float)(startColorVar.getG() / 255.0f)).ToString(), "real");
            // startColorVarianceRed
            AppendKV(sb, 1, "startColorVarianceRed", ((float)(startColorVar.getR() / 255.0f)).ToString(), "real");
            // startParticleSize
            AppendKV(sb, 1, "startParticleSize", startSize.getValue().ToString(), "real");
            // startParticleSizeVariance
            AppendKV(sb, 1, "startParticleSizeVariance", startSizeVar.getValue().ToString(), "real");
            // tangentialAccelVariance
            AppendKV(sb, 1, "tangentialAccelVariance", emGravityTangentAccelVar.getValue().ToString(), "real");
            // tangentialAcceleration
            AppendKV(sb, 1, "tangentialAcceleration", emGravityTangentAccel.getValue().ToString(), "real");
            // textureFileName
            AppendKV(sb, 1, "textureFileName", textureFileName, "string");

            sb.Append("</dict>\n");
            sb.Append("</plist>\n");

            return(sb.ToString());
        }
Example #2
0
        private void readFromXml(XmlDocument doc)
        {
            XmlElement        eDict   = ((XmlElement)doc.SelectNodes("plist")[0].SelectNodes("dict")[0]);
            List <XmlElement> eChilds = new List <XmlElement>();

            for (XmlNode node = eDict.FirstChild; node != null; node = node.NextSibling)
            {
                if (!(node is XmlElement))
                {
                    continue;
                }

                eChilds.Add((XmlElement)node);
            }

            for (int i = 0; i < eChilds.Count; ++i)
            {
                XmlElement e = eChilds[i];
                if (e.ChildNodes[0].Value == "angle")
                {
                    emitAngle.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "angleVariance")
                {
                    emitAngleVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "blendFuncDestination")
                {
                    btnBlendDst.Text = Enum.GetName(typeof(EBlendFactor), GLBlendFactorForm.transGlBlendFactor(int.Parse(eChilds[++i].ChildNodes[0].Value)));
                }
                else if (e.ChildNodes[0].Value == "blendFuncSource")
                {
                    btnBlendSrc.Text = Enum.GetName(typeof(EBlendFactor), GLBlendFactorForm.transGlBlendFactor(int.Parse(eChilds[++i].ChildNodes[0].Value)));
                }
                else if (e.ChildNodes[0].Value == "duration")
                {
                    emDuration.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "emitterType")
                {
                    // ??? emitterType TODO confirm 1.0 and 0.0
                    if (float.Parse(eChilds[++i].ChildNodes[0].Value) == 0)
                    {
                        radioEmitterGravity.Checked = true;
                    }
                    else
                    {
                        radioEmitterRadial.Checked = true;
                    }
                }
                else if (e.ChildNodes[0].Value == "finishColorAlpha")
                {
                    endColor.setA((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorBlue")
                {
                    endColor.setB((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorGreen")
                {
                    endColor.setG((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorRed")
                {
                    endColor.setR((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorVarianceAlpha")
                {
                    endColorVar.setA((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorVarianceBlue")
                {
                    endColorVar.setB((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorVarianceGreen")
                {
                    endColorVar.setG((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorVarianceRed")
                {
                    endColorVar.setR((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishParticleSize")
                {
                    finishSize.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "finishParticleSizeVariance")
                {
                    finishSizeVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "gravityx")
                {
                    emGravityX.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "gravityy")
                {
                    emGravityY.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "maxParticles")
                {
                    maxParticles.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "maxRadius")
                {
                    emRadialMaxRadius.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "maxRadiusVariance")
                {
                    emRadialMaxRadiusVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "minRadius")
                {
                    emRadialMinRadius.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "particleLifespan")
                {
                    lifeSpan.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "particleLifespanVariance")
                {
                    lifeSpanVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "radialAccelVariance")
                {
                    emGravityRadialAccelVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "radialAcceleration")
                {
                    emGravityRadialAccel.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotatePerSecond")
                {
                    emRadialDegPerSecond.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotatePerSecondVariance")
                {
                    emRadialDegPerSecondVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotationEnd")
                {
                    rotationEnd.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotationEndVariance")
                {
                    rotationEndVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotationStart")
                {
                    rotationStart.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotationStartVariance")
                {
                    rotationStartVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "sourcePositionVariancex")
                {
                    emPosXVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "sourcePositionVariancey")
                {
                    emPosYVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "sourcePositionx")
                {
                    emPosX.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "sourcePositiony")
                {
                    emPosY.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "speed")
                {
                    emGravitySpeed.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "speedVariance")
                {
                    emGravitySpeedVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "startColorAlpha")
                {
                    startColor.setA((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorBlue")
                {
                    startColor.setB((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorGreen")
                {
                    startColor.setG((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorRed")
                {
                    startColor.setR((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorVarianceAlpha")
                {
                    startColorVar.setA((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorVarianceBlue")
                {
                    startColorVar.setB((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorVarianceGreen")
                {
                    startColorVar.setG((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorVarianceRed")
                {
                    startColorVar.setR((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startParticleSize")
                {
                    startSize.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "startParticleSizeVariance")
                {
                    startSizeVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "tangentialAccelVariance")
                {
                    emGravityTangentAccelVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "tangentialAcceleration")
                {
                    emGravityTangentAccel.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "textureFileName")
                {
                    setTextureFileName(eChilds[++i].ChildNodes[0].Value);
                }
            }
        }