Example #1
0
File: Unit.cs Project: corefan/yad2
 public Unit(Houses.House race, int userID, Vector3 position, int maxHealth, float viewRange, ExtendedTexture extendedTexture, int buildSpeed, float speed, string name, Vector2 direction) : base(race, userID, position, maxHealth, viewRange, extendedTexture, buildSpeed, name)
 {
     this.speed     = Houses.CalculateSpeed(race, speed);
     this.direction = direction;
     moving         = false;
     selected       = false;
 }
Example #2
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));
                        }
                    }
                }
            }
        }