Esempio n. 1
0
 public Particle2D( ITexture2D texture, Vector2 position, Vector2 velocity, float angle, float angularVelocity, Color overlayColor, float size, TimeSpan ttl )
 {
     sprite = new Sprite ( texture );
     world = new World2 ( position, new Vector2 ( size ), texture.Size () / 2, angle, texture.Size () / 2 );
     sprite.OverlayColor = overlayColor;
     Velocity = velocity;
     AngularVelocity = angularVelocity;
     TTL = ttl;
 }
Esempio n. 2
0
 public SpriteNode( Sprite sprite )
 {
     this.sprite = sprite;
     OverlayColor = Color.White;
     World = World2.Identity;
     tempWorld = World2.Identity;
     Alignment = SpriteAlignment.LeftTop;
     CalculateMoveUnit ();
 }
Esempio n. 3
0
 public FadeTransitor( Color fadeColor, float fadeUnit )
 {
     FadeColor = fadeColor;
     FadeUnit = fadeUnit;
     fadeTexture = Core.GraphicsDevice.CreateTexture2D ( 1, 1 );
     fadeTexture.Buffer = new Color [ 1 ] { Color.White };
     fadeSprite = new Sprite ( fadeTexture );
     fadeSpriteWorld = new World2 ();
     fadeSpriteWorld.Scale = Core.GraphicsDevice.BackBuffer.Size ();
 }
Esempio n. 4
0
        public Font()
        {
            spriteEngine = new Sprite ( null );
            fontWorld = new World2 ();

            SpacingOfChars = 1;
            SpacingOfLines = 2;

            IsPrerenderMode = false;
            cachedRenderBuffer = new Dictionary<string, IRenderBuffer> ();
        }
Esempio n. 5
0
 public override void Intro( params object [] args )
 {
     contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
     contentManager.AddDefaultContentLoader ();
     //Core.Launcher.InvokeInMainThread ( () =>
     //{
         titleFont = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 64 );
         menuFont = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 24 );
     //} );
     logo = new Sprite ( contentManager.Load<ITexture2D> ( "Resources/Dodge/logo.png" ) );
     logoWorld = new World2 ();
     base.Intro ( args );
 }
Esempio n. 6
0
        public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
        {
            try
            {
                return new Sprite ( textureContentLoader.Read ( stream, resourceTable, args ) as ITexture2D );
            }
            catch
            {
                JsonContainer data = new JsonContainer ( stream );

                Sprite sprite = new Sprite ( null );
                if ( data.Contains ( "colorkey" ) )
                {
                    JsonContainer colorKey = data [ "colorkey" ] as JsonContainer;
                    sprite.Texture = textureContentLoader.Read ( new MemoryStream ( Convert.FromBase64String ( data [ "image" ] as string ) ),
                        resourceTable,
                        new Color ( ( byte ) colorKey [ 0 ], ( byte ) colorKey [ 1 ], ( byte ) colorKey [ 2 ], ( byte ) colorKey [ 3 ] ) ) as ITexture2D;
                }
                else
                    sprite.Texture = textureContentLoader.Read ( new MemoryStream ( Convert.FromBase64String ( data [ "image" ] as string ) ),
                        resourceTable ) as ITexture2D;

                if ( data.Contains ( "cliparea" ) )
                {
                    JsonContainer clipArea = data [ "clipArea" ] as JsonContainer;
                    if ( clipArea.ContainerType == ContainType.Object )
                    {
                        sprite.ClippingArea = new Rectangle ( ( int ) clipArea [ "left" ], ( int ) clipArea [ "top" ],
                            ( int ) clipArea [ "right" ] - ( int ) clipArea [ "left" ], ( int ) clipArea [ "bottom" ] - ( int ) clipArea [ "top" ] );
                    }
                    else
                    {
                        sprite.ClippingArea = new Rectangle ( ( int ) clipArea [ 0 ], ( int ) clipArea [ 1 ],
                            ( int ) clipArea [ 2 ] - ( int ) clipArea [ 0 ], ( int ) clipArea [ 3 ] - ( int ) clipArea [ 1 ] );
                    }
                }

                if ( data.Contains ( "overlay" ) )
                {
                    JsonContainer overlay = data [ "overlay" ] as JsonContainer;
                    sprite.OverlayColor = new Color ( ( byte ) overlay [ 0 ], ( byte ) overlay [ 1 ], ( byte ) overlay [ 2 ], ( byte ) overlay [ 3 ] );
                }

                return sprite;
            }
        }
Esempio n. 7
0
        public override void Intro( params object [] args )
        {
            Core.GraphicsDevice.ImmediateContext.BlendState = BlendState.AlphaBlend;

            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            contentManager.AddDefaultContentLoader ();
            Texture2DContentLoader.AddDefaultDecoders ();
            sprite = contentManager.Load<Sprite> ( "Resources/test.jpg", Color.Magenta );
            font = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 24 );

            animate = new Animate ( TimeSpan.FromSeconds ( 4 ), 400 );
            loopAnimate = new Animate ( TimeSpan.FromSeconds ( 4 ), 400 ) { IsLoopingMode = true };
            loopAnimate.Start ();
            Add ( InputHelper.Instance );

            world = new World2 ();

            base.Intro ( args );
        }
Esempio n. 8
0
        protected override void Dispose( bool isDisposing )
        {
            if ( isDisposing )
            {
                foreach ( IRenderBuffer buffer in cachedRenderBuffer.Values )
                    buffer.Dispose ();
                cachedRenderBuffer = null;

                if ( spriteEngine != null )
                {
                    spriteEngine.Dispose ();
                    spriteEngine = null;
                }
            }
            base.Dispose ( isDisposing );
        }
Esempio n. 9
0
        public override void Intro( params object [] args )
        {
            Core.GraphicsDevice.ImmediateContext.CullMode = CullMode.ClockWise;

            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            contentManager.AddDefaultContentLoader ();

            texture1 = contentManager.Load<ITexture2D> ( "Resources/Terrain/terrain_02.png" );
            texture2 = contentManager.Load<ITexture2D> ( "Resources/Terrain/terrain_01.png" );
            Color [] colours = texture2.Buffer;
            effect = contentManager.Load<IEffect> ( "Resources/Terrain/TerrainShader.xml" );

            textureArgs = new SamplerState ( texture1, TextureFilter.Anisotropic, TextureAddressing.Clamp,
                Core.GraphicsDevice.Information.MaximumAnisotropicLevel );

            vertexBuffer = Core.GraphicsDevice.CreateBuffer ( BufferType.VertexBuffer, typeof ( TerrainVertex ), texture2.Width * texture2.Height );
            vertexDeclaration = Core.GraphicsDevice.CreateVertexDeclaration ( Utilities.CreateVertexElementArray<TerrainVertex> () );
            numOfIndices = ( texture2.Width - 1 ) * ( texture2.Height - 1 ) * 2;
            indexBuffer = Core.GraphicsDevice.CreateBuffer ( BufferType.IndexBuffer, typeof ( TerrainIndex ), numOfIndices );

            TerrainVertex [] vertices = new TerrainVertex [ texture2.Width * texture2.Height ];
            int index = 0;
            for ( int x = 0; x < texture2.Height; x++ )
            {
                for ( int z = 0; z < texture2.Width; z++ )
                {
                    int location = x * texture2.Width + z;
                    vertices [ index ] = new TerrainVertex ()
                    {
                        Position = new Vector3 (
                            ( x - texture2.Height / 2 ) * 5.0f,
                            colours [ location ].RedValue * 5.0f / 3,
                            ( z - texture2.Width / 2 ) * 5.0f
                        ),
                        UV = new Vector2 (
                            z / ( float ) texture2.Width,
                            x / ( float ) texture2.Height
                        )
                    };
                    ++index;
                }
            }
            vertexBuffer.SetBufferDatas<TerrainVertex> ( vertices );

            TerrainIndex [] indices = new TerrainIndex [ numOfIndices ];
            index = 0;
            for ( int z = 0; z < texture2.Height - 1; z++ )
            {
                for ( int x = 0; x < texture2.Width - 1; x++ )
                {
                    indices [ index ]._0 = z * texture2.Width + x;
                    indices [ index ]._1 = z * texture2.Width + ( x + 1 );
                    indices [ index ]._2 = ( z + 1 ) * texture2.Width + x;
                    ++index;
                    indices [ index ]._0 = ( z + 1 ) * texture2.Width + x;
                    indices [ index ]._1 = z * texture2.Width + ( x + 1 );
                    indices [ index ]._2 = ( z + 1 ) * texture2.Width + ( x + 1 );
                    ++index;
                }
            }
            indexBuffer.SetBufferDatas<TerrainIndex> ( indices );

            proj = new PerspectiveFieldOfViewProjection ( 3.141592f / 4, 4 / 3f, 1, 10000 );
            look = new LookAt ( new Vector3 ( 1000, 2000, 1000 ), new Vector3 ( 0, 0, 0 ), new Vector3 ( 0, 1, 0 ) );
            world = new World3 ();

            sprite = new Sprite ( null );
            spriteWorld = new World2 ();

            Add ( new FpsCalculator () );

            base.Intro ( args );
        }