Example #1
0
        void LoadAnimationState( TextBlock block )
        {
            TextBlock itemBlock = block.FindChild( "currentAnimationItem" );
            if( itemBlock != null )
            {
                string animationBaseName =
                    itemBlock.GetAttribute( "animationBaseName" );
                bool allowRandomAnimationNumber = bool.Parse(
                    itemBlock.GetAttribute( "allowRandomAnimationNumber", "true" ) );
                bool loop = bool.Parse( itemBlock.GetAttribute( "loop", "true" ) );

                currentAnimationItem = animationController.Add( animationBaseName,
                    allowRandomAnimationNumber, loop );
                if( currentAnimationItem != null )
                {
                    MeshObjectAnimationController.AnimationItem item = currentAnimationItem;

                    if( itemBlock.IsAttributeExist( "velocity" ) )
                        item.Velocity = float.Parse( itemBlock.GetAttribute( "velocity" ) );
                    if( itemBlock.IsAttributeExist( "weight" ) )
                        item.Weight = float.Parse( itemBlock.GetAttribute( "weight" ) );
                    if( itemBlock.IsAttributeExist( "timePosition" ) )
                        item.TimePosition = float.Parse( itemBlock.GetAttribute( "timePosition" ) );
                }
            }

            if( block.IsAttributeExist( "forceAnimationRemainingTime" ) )
            {
                forceAnimationRemainingTime = float.Parse(
                    block.GetAttribute( "forceAnimationRemainingTime" ) );
            }
        }
Example #2
0
File: Gun.cs Project: whztt07/SDK
        protected override bool OnSave( TextBlock block )
        {
            TextBlock normalModeBlock = block.FindChild( "normalMode" );
            if( normalModeBlock == null )
                Log.Fatal( "{0} : normalMode Block not exists", Name );
            if( !normalMode.Save( normalModeBlock ) )
                return false;

            TextBlock alternativeModeBlock = block.FindChild( "alternativeMode" );
            if( alternativeModeBlock == null )
                Log.Fatal( "{0} : alternativeMode Block not exists", Name );
            if( !alternativeMode.Save( alternativeModeBlock ) )
                return false;

            return base.OnSave( block );
        }
Example #3
0
File: Gun.cs Project: whztt07/SDK
            public bool Load( TextBlock block )
            {
                //fireObjects
                TextBlock fireObjectsBlock = block.FindChild( "fireObjects" );
                if( fireObjectsBlock != null )
                {
                    if( !fireObjects.Load( fireObjectsBlock ) )
                        return false;
                }

                return true;
            }
Example #4
0
            public void Load( TextBlock block )
            {
                if( block.IsAttributeExist( "scroll" ) )
                    scroll = Vec2.Parse( block.GetAttribute( "scroll" ) );
                if( block.IsAttributeExist( "scale" ) )
                    scale = Vec2.Parse( block.GetAttribute( "scale" ) );
                if( block.IsAttributeExist( "rotate" ) )
                    rotate = float.Parse( block.GetAttribute( "rotate" ) );
                if( block.IsAttributeExist( "dynamicParameters" ) )
                    dynamicParameters = bool.Parse( block.GetAttribute( "dynamicParameters" ) );

                TextBlock animationBlock = block.FindChild( "animation" );
                if( animationBlock != null )
                    animation.Load( animationBlock );
            }
Example #5
0
File: Gun.cs Project: whztt07/SDK
        protected override bool OnLoad( TextBlock block )
        {
            TextBlock normalModeBlock = block.FindChild( "normalMode" );
            if( normalModeBlock != null )
                if( !normalMode.Load( normalModeBlock ) )
                    return false;

            TextBlock alternativeModeBlock = block.FindChild( "alternativeMode" );
            if( alternativeModeBlock != null )
                if( !alternativeMode.Load( alternativeModeBlock ) )
                    return false;

            return base.OnLoad( block );
        }
Example #6
0
            public virtual void Load( TextBlock block )
            {
                if( block.IsAttributeExist( "texture" ) )
                    texture = block.GetAttribute( "texture" );

                if( block.IsAttributeExist( "texCoord" ) )
                    texCoord = (TexCoordIndexes)Enum.Parse( typeof( TexCoordIndexes ),
                        block.GetAttribute( "texCoord" ) );

                if( block.IsAttributeExist( "clamp" ) )
                    clamp = bool.Parse( block.GetAttribute( "clamp" ) );

                TextBlock transformBlock = block.FindChild( "transform" );
                if( transformBlock != null )
                    transform.Load( transformBlock );
            }
Example #7
0
        protected override bool OnLoad( TextBlock block )
        {
            if( !base.OnLoad( block ) )
                return false;

            //General
            {
                if( block.IsAttributeExist( "blending" ) )
                    blending = (MaterialBlendingTypes)Enum.Parse(
                        typeof( MaterialBlendingTypes ), block.GetAttribute( "blending" ) );

                if( block.IsAttributeExist( "lighting" ) )
                    lighting = bool.Parse( block.GetAttribute( "lighting" ) );

                if( block.IsAttributeExist( "ambientLighting" ) )
                    ambientLighting = bool.Parse( block.GetAttribute( "ambientLighting" ) );

                if( block.IsAttributeExist( "doubleSided" ) )
                    doubleSided = bool.Parse( block.GetAttribute( "doubleSided" ) );
                //old version compatibility
                if( block.IsAttributeExist( "culling" ) )
                    doubleSided = !bool.Parse( block.GetAttribute( "culling" ) );

                if( block.IsAttributeExist( "useNormals" ) )
                    useNormals = bool.Parse( block.GetAttribute( "useNormals" ) );

                if( block.IsAttributeExist( "receiveShadows" ) )
                    receiveShadows = bool.Parse( block.GetAttribute( "receiveShadows" ) );

                if( block.IsAttributeExist( "receiveSimpleShadows" ) )
                    receiveSimpleShadows = bool.Parse( block.GetAttribute( "receiveSimpleShadows" ) );

                if( block.IsAttributeExist( "alphaRejectFunction" ) )
                    alphaRejectFunction = (CompareFunction)Enum.Parse( typeof( CompareFunction ),
                        block.GetAttribute( "alphaRejectFunction" ) );

                if( block.IsAttributeExist( "alphaRejectValue" ) )
                    alphaRejectValue = byte.Parse( block.GetAttribute( "alphaRejectValue" ) );

                if( block.IsAttributeExist( "alphaToCoverage" ) )
                    alphaToCoverage = bool.Parse( block.GetAttribute( "alphaToCoverage" ) );

                if( block.IsAttributeExist( "fadingByDistanceRange" ) )
                    fadingByDistanceRange = Range.Parse( block.GetAttribute( "fadingByDistanceRange" ) );

                if( block.IsAttributeExist( "allowFog" ) )
                    allowFog = bool.Parse( block.GetAttribute( "allowFog" ) );

                if( block.IsAttributeExist( "depthWrite" ) )
                    depthWrite = bool.Parse( block.GetAttribute( "depthWrite" ) );

                if( block.IsAttributeExist( "depthTest" ) )
                    depthTest = bool.Parse( block.GetAttribute( "depthTest" ) );

                if( block.IsAttributeExist( "softParticles" ) )
                    softParticles = bool.Parse( block.GetAttribute( "softParticles" ) );

                if( block.IsAttributeExist( "softParticlesFadingLength" ) )
                    softParticlesFadingLength = float.Parse( block.GetAttribute( "softParticlesFadingLength" ) );

                if( block.IsAttributeExist( "depthOffset" ) )
                    depthOffset = float.Parse( block.GetAttribute( "depthOffset" ) );

                if( block.IsAttributeExist( "halfLambert" ) )
                    halfLambert = bool.Parse( block.GetAttribute( "halfLambert" ) );
            }

            //Diffuse
            {
                //old version compatibility
                if( block.IsAttributeExist( "diffuseScale" ) )
                {
                    diffuseColor = ColorValue.Parse( block.GetAttribute( "diffuseScale" ) );
                    float power = Math.Max( Math.Max( diffuseColor.Red, diffuseColor.Green ),
                        diffuseColor.Blue );
                    if( power > 1 )
                    {
                        diffuseColor.Red /= power;
                        diffuseColor.Green /= power;
                        diffuseColor.Blue /= power;
                        diffusePower = power;
                    }
                }

                if( block.IsAttributeExist( "diffuseColor" ) )
                    diffuseColor = ColorValue.Parse( block.GetAttribute( "diffuseColor" ) );
                if( block.IsAttributeExist( "diffusePower" ) )
                    diffusePower = float.Parse( block.GetAttribute( "diffusePower" ) );

                if( block.IsAttributeExist( "diffuseScaleDynamic" ) )
                    diffuseScaleDynamic = bool.Parse( block.GetAttribute( "diffuseScaleDynamic" ) );

                if( block.IsAttributeExist( "diffuseVertexColor" ) )
                    diffuseVertexColor = bool.Parse( block.GetAttribute( "diffuseVertexColor" ) );

                TextBlock diffuse1MapBlock = block.FindChild( "diffuse1Map" );
                if( diffuse1MapBlock != null )
                    diffuse1Map.Load( diffuse1MapBlock );

                TextBlock diffuse2MapBlock = block.FindChild( "diffuse2Map" );
                if( diffuse2MapBlock != null )
                    diffuse2Map.Load( diffuse2MapBlock );

                TextBlock diffuse3MapBlock = block.FindChild( "diffuse3Map" );
                if( diffuse3MapBlock != null )
                    diffuse3Map.Load( diffuse3MapBlock );

                TextBlock diffuse4MapBlock = block.FindChild( "diffuse4Map" );
                if( diffuse4MapBlock != null )
                    diffuse4Map.Load( diffuse4MapBlock );

                //old version compatibility
                if( block.IsAttributeExist( "diffuseMap" ) )
                    diffuse1Map.Texture = block.GetAttribute( "diffuseMap" );
            }

            //Reflection
            {
                if( block.IsAttributeExist( "reflectionScale" ) )
                {
                    reflectionColor = ColorValue.Parse( block.GetAttribute( "reflectionScale" ) );
                    float power = Math.Max( Math.Max( reflectionColor.Red, reflectionColor.Green ),
                        Math.Max( reflectionColor.Blue, reflectionColor.Alpha ) );
                    if( power > 1 )
                    {
                        reflectionColor /= power;
                        reflectionPower = power;
                    }
                }

                if( block.IsAttributeExist( "reflectionColor" ) )
                    reflectionColor = ColorValue.Parse( block.GetAttribute( "reflectionColor" ) );
                if( block.IsAttributeExist( "reflectionPower" ) )
                    reflectionPower = float.Parse( block.GetAttribute( "reflectionPower" ) );

                if( block.IsAttributeExist( "reflectionScaleDynamic" ) )
                    reflectionScaleDynamic = bool.Parse( block.GetAttribute( "reflectionScaleDynamic" ) );

                TextBlock reflectionMapBlock = block.FindChild( "reflectionMap" );
                if( reflectionMapBlock != null )
                    reflectionMap.Load( reflectionMapBlock );

                if( block.IsAttributeExist( "reflectionSpecificCubemap" ) )
                    reflectionSpecificCubemap = block.GetAttribute( "reflectionSpecificCubemap" );

                //old version compatibility
                if( block.IsAttributeExist( "reflectionMap" ) )
                    reflectionMap.Texture = block.GetAttribute( "reflectionMap" );

                if( block.IsAttributeExist( "reflectionBoxParallaxCorrectedCubemaps" ) )
                    reflectionBoxParallaxCorrectedCubemaps = bool.Parse( block.GetAttribute( "reflectionBoxParallaxCorrectedCubemaps" ) );
            }

            //Emission
            {
                if( block.IsAttributeExist( "emissionScale" ) )
                {
                    emissionColor = ColorValue.Parse( block.GetAttribute( "emissionScale" ) );
                    float power = Math.Max( Math.Max( emissionColor.Red, emissionColor.Green ),
                        Math.Max( emissionColor.Blue, emissionColor.Alpha ) );
                    if( power > 1 )
                    {
                        emissionColor /= power;
                        emissionPower = power;
                    }
                }

                if( block.IsAttributeExist( "emissionColor" ) )
                    emissionColor = ColorValue.Parse( block.GetAttribute( "emissionColor" ) );
                if( block.IsAttributeExist( "emissionPower" ) )
                    emissionPower = float.Parse( block.GetAttribute( "emissionPower" ) );

                if( block.IsAttributeExist( "emissionScaleDynamic" ) )
                    emissionScaleDynamic = bool.Parse( block.GetAttribute( "emissionScaleDynamic" ) );

                TextBlock emissionMapBlock = block.FindChild( "emissionMap" );
                if( emissionMapBlock != null )
                    emissionMap.Load( emissionMapBlock );

                //old version compatibility
                if( block.IsAttributeExist( "emissionMap" ) )
                    emissionMap.Texture = block.GetAttribute( "emissionMap" );
            }

            //Specular
            {
                if( block.IsAttributeExist( "specularScale" ) )
                {
                    specularColor = ColorValue.Parse( block.GetAttribute( "specularScale" ) );
                    float power = Math.Max( Math.Max( specularColor.Red, specularColor.Green ),
                        Math.Max( specularColor.Blue, specularColor.Alpha ) );
                    if( power > 1 )
                    {
                        specularColor /= power;
                        specularPower = power;
                    }
                }

                if( block.IsAttributeExist( "specularColor" ) )
                    specularColor = ColorValue.Parse( block.GetAttribute( "specularColor" ) );
                if( block.IsAttributeExist( "specularPower" ) )
                    specularPower = float.Parse( block.GetAttribute( "specularPower" ) );

                if( block.IsAttributeExist( "specularScaleDynamic" ) )
                    specularScaleDynamic = bool.Parse( block.GetAttribute( "specularScaleDynamic" ) );

                TextBlock specularMapBlock = block.FindChild( "specularMap" );
                if( specularMapBlock != null )
                    specularMap.Load( specularMapBlock );

                if( block.IsAttributeExist( "specularShininess" ) )
                    specularShininess = float.Parse( block.GetAttribute( "specularShininess" ) );

                //old version compatibility
                if( block.IsAttributeExist( "specularMap" ) )
                    specularMap.Texture = block.GetAttribute( "specularMap" );
            }

            //Translucency
            {
                if( block.IsAttributeExist( "translucencyColor" ) )
                    translucencyColor = ColorValue.Parse( block.GetAttribute( "translucencyColor" ) );
                if( block.IsAttributeExist( "translucencyPower" ) )
                    translucencyPower = float.Parse( block.GetAttribute( "translucencyPower" ) );

                if( block.IsAttributeExist( "translucencyDynamic" ) )
                    translucencyDynamic = bool.Parse( block.GetAttribute( "translucencyDynamic" ) );

                TextBlock translucencyMapBlock = block.FindChild( "translucencyMap" );
                if( translucencyMapBlock != null )
                    translucencyMap.Load( translucencyMapBlock );

                if( block.IsAttributeExist( "translucencyClearness" ) )
                    translucencyClearness = float.Parse( block.GetAttribute( "translucencyClearness" ) );
            }

            //Height
            {
                TextBlock normalMapBlock = block.FindChild( "normalMap" );
                if( normalMapBlock != null )
                    normalMap.Load( normalMapBlock );

                TextBlock heightMapBlock = block.FindChild( "heightMap" );
                if( heightMapBlock != null )
                    heightMap.Load( heightMapBlock );

                if( block.IsAttributeExist( "heightFromNormalMapAlpha" ) )
                    heightFromNormalMapAlpha = bool.Parse( block.GetAttribute( "heightFromNormalMapAlpha" ) );

                if( block.IsAttributeExist( "displacementTechnique" ) )
                {
                    displacementTechnique = (DisplacementTechniques)Enum.Parse( typeof( DisplacementTechniques ),
                        block.GetAttribute( "displacementTechnique" ) );
                }

                if( block.IsAttributeExist( "heightScale" ) )
                    heightScale = float.Parse( block.GetAttribute( "heightScale" ) );

                //old version compatibility
                if( block.IsAttributeExist( "normalMap" ) )
                    normalMap.Texture = block.GetAttribute( "normalMap" );
                if( block.IsAttributeExist( "heightMap" ) )
                    heightMap.Texture = block.GetAttribute( "heightMap" );
            }

            return true;
        }
Example #8
0
        protected override bool OnLoad(TextBlock block)
        {
            if (!base.OnLoad(block))
                return false;

            //hitObjects
            TextBlock hitObjectsBlock = block.FindChild("hitObjects");
            if (hitObjectsBlock != null)
            {
                if (!hitObjects.Load(hitObjectsBlock))
                    return false;
            }

            return true;
        }
        protected override bool OnLoad(TextBlock block)
        {
            if (!base.OnLoad(block))
                return false;

            //currentTask
            {
                TextBlock taskBlock = block.FindChild("currentTask");
                if (taskBlock != null)
                {
                    Task task = CreateTaskByClassName(taskBlock.GetAttribute("class"));
                    if (task._Load(taskBlock))
                        currentTask = task;
                }
            }

            //tasks
            TextBlock tasksBlock = block.FindChild("tasks");
            if (tasksBlock != null)
            {
                foreach (TextBlock taskBlock in tasksBlock.Children)
                {
                    if (taskBlock.Name == "item")
                    {
                        Task task = CreateTaskByClassName(taskBlock.GetAttribute("class"));
                        if (task._Load(taskBlock))
                            tasks.Enqueue(task);
                    }
                }
            }

            return true;
        }
Example #10
0
        protected override bool OnLoad( TextBlock block )
        {
            if( !base.OnLoad( block ) )
                return false;

            //dieObjects
            TextBlock dieObjectsBlock = block.FindChild( "dieObjects" );
            if( dieObjectsBlock != null )
            {
                if( !dieObjects.Load( dieObjectsBlock ) )
                    return false;
            }

            //old version compatibility
            if( block.IsAttributeExist( "lifeMax" ) )
                healthMax = float.Parse( block.GetAttribute( "lifeMax" ) );
            if( block.IsAttributeExist( "lifeMin" ) )
                healthMin = float.Parse( block.GetAttribute( "lifeMin" ) );

            return true;
        }