Передача значения из одного класса в другой
Есть первый класс GObject и наследуемый от него MoveObject. Как текущее значение EnemyRectangle.Y из MoveObject передать в какой-либо другой класс, допустим CA?
class GObject
{
public Texture2D EnemyTexture;
public Rectangle EnemyRectangle;
public Vector2 velocity;
virtual public void Update()
{
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(EnemyTexture, EnemyRectangle, Color.White);
}
}
class MoveObject : GObject
{
public MoveObject(Texture2D newEnemyTexture, Rectangle newEnemyRectangle)
{
EnemyTexture = newEnemyTexture;
base.EnemyRectangle = newEnemyRectangle;
}
public override void Update()
{
velocity.Y = 1F;
EnemyRectangle.Y = EnemyRectangle.Y + Convert.ToInt32(velocity.Y);
if (EnemyRectangle.Y >= 450)
EnemyRectangle.Y = 450;
}
}