I want my arrow to chase the minion that I just rightclicked on. I have a Minion Class and an Arrow Class. These are the constructors:
/// <summary>
/// Constructs a minion
/// </summary>
public Minion(Texture2D sprite, int x, int y, int windowWidth, int windowHeight, bool isFriendly, int minionHealth)
/// <summary>
/// Constructor of the bullet from champion to minion
/// </summary>
public Arrow(Texture2D sprite, Vector2 sourceEntity, Vector2 targetEntity, float arrowSpeed, int arrowAttackSpeed, int damageDone, bool isArrowActive)
In the Game1 I have the standard if-click structure and I check if the click is on the minions. But I check this with
foreach (Minion minion in enemyMinions)
So - I want to mark somehow the minion I clicked on and then to send the arrow directly to its moving location.
How to do that?
Update:
//checks if rightmouse button was clicked to activate the arrow
if (mouse.RightButton == ButtonState.Released && previousButtonState == ButtonState.Pressed)
{
//checks if the right mouse click was on a minion and the minion is in champion's range
for (int i = 0; i < enemyMinions.Count; i++)
{
if (enemyMinions[i].CollisionRectangle.Contains(mouse.X, mouse.Y)
&& (Math.Abs(mouse.X - enemyMinions[i].X) < vayne.ChampionRange) ||
Math.Abs(mouse.Y - enemyMinions[i].Y) < vayne.ChampionRange)
{
//mark the minion that the click was made on
theCurrentTarget = enemyMinions[i];
//sets the arrow.targetEntity to that particular minion
arrow.TargetX = theCurrentTarget.X;
arrow.TargetY = theCurrentTarget.Y;
arrow.IsArrowActive = true;
}
}
}
previousButtonState = mouse.RightButton;
Vector2
for thetargetEntity
pass a reference to the entity, then you can just get the position at any time straight from the entity. \$\endgroup\$ – MichaelHouse♦ Feb 19 '14 at 22:13