Example #1
0
File: Unit.cs Project: corefan/yad2
        public override void Render(Camera camera, GameTime gameTime, Houses.House house, Map map)
        {
            Vector4 pos = new Vector4();

            pos.X = position.X - camera.GetPosition().X;
            pos.Y = position.Y - camera.GetPosition().Y;
            pos.W = 1.0f;
            pos.Z = 1.0f;
            if (camera.Visible(pos))
            {
                if (!IsBeingBuilt)
                {
                    if (!map.fog[(int)position.X + map.size.X * (int)position.Y])
                    {
                        if (moving)
                        {
                            camera.spriteBatch.Draw(extendedTexture.Texture, camera.GetRenderPosition(pos), extendedTexture.GetSourceRectangle(direction, gameTime), Houses.GetColor(house));
                            if (turretTexture != null)
                            {
                                camera.spriteBatch.Draw(turretTexture.Texture, camera.GetRenderPosition(pos), extendedTexture.GetSourceRectangle(turretDirection, gameTime), Houses.GetColor(house));
                            }
                        }
                        else
                        {
                            camera.spriteBatch.Draw(extendedTexture.Texture, camera.GetRenderPosition(pos), extendedTexture.GetSourceRectangle(direction, 0.0f), Houses.GetColor(house));
                            if (turretTexture != null)
                            {
                                camera.spriteBatch.Draw(turretTexture.Texture, camera.GetRenderPosition(pos), extendedTexture.GetSourceRectangle(turretDirection, 0.0f), Houses.GetColor(house));
                            }
                        }
                        if (selected)
                        {
                            camera.spriteBatch.Draw(selectTexture.Texture, camera.GetRenderPosition(pos), selectTexture.GetSourceRectangle(direction, gameTime), new Color(0, 255, 0, 128));
                        }
                    }
                }
            }
        }