Okay the title might be wtf, so here is what my problem is:
I have created 2 classes, one is bullet.cs and one is enemy.cs, then in Game1.cs I created a bullet method(s) first to make a player shoot,
It wrked very well, and then I created enemy method to spawn enemys, which works just the way I want it.
Now what I am trying to do is to decrement enemy.Health (enemy is an element of List enemys) every time the bullet(bullet is an element of List bullets) hits it,
but I cant acces position values becouse they are in their own methods:
Enemy method:
public void Enemyss()
{
Enemy enemy = new Enemy(Content.Load<Texture2D>("Enemy"), new Vector2(e_x, 100), new int(), new int());
enemy.Health = 10;
if (enemys.Count() < 8)
{
enemys.Add(enemy);
e_x += 100;
}
}
One of the bullet methods:
public void Shoot()
{
Bullet newBullet = new Bullet(Content.Load<Texture2D>("b"));
newBullet.velocity = 10f;
newBullet.position.Y = ((pla.pla_pos.Y+20) + newBullet.velocity);
newBullet.position.X = pla.pla_pos.X + 28;
if (bullets.Count() < 30)
{
bullets.Add(newBullet);
}
}
So now I want to do something like
if(newbullet.positon.X == enemy.ePosition.X && newbullet.positon.Y == enemy.ePosition.Y)
{
bla
bla
bla
}
But as you might now I cant acces bullet position or enemy position out of their methods, so what should I do?