public void Draw(SpriteBatch sB)
{
Vector2 origin = new Vector2(0, 8);
float RotationAngle = 0;
Texture2D drawnText = spearText;
if (spearOwner == null)
{
if (!atRest && thrownBy != null && thrownBy.blinked)
return;
origin.X = 32;
Vector2 screenPos = new Vector2(spear.X, spear.Y);
Vector2 dirVect = new Vector2(velocity.X, -velocity.Y);
dirVect.Normalize();
RotationAngle = VectorMath.rotationFromVector(dirVect) + (float)(Math.PI/2);
sB.Draw(drawnText, screenPos, null , Color.White , orientation, origin, 1.0f, SpriteEffects.None, 0f);
Vector2 dupePos;
if(spear.X > SCREENSIZE.X - spear.Width / 2) {
dupePos = new Vector2(screenPos.X-SCREENSIZE.X, screenPos.Y);
sB.Draw(drawnText, dupePos, null, Color.White, orientation, origin, 1.0f, SpriteEffects.None, 0f);
}
if (spear.Y > SCREENSIZE.Y - spear.Width / 2)
{
dupePos = new Vector2(screenPos.X , screenPos.Y - SCREENSIZE.Y);
sB.Draw(drawnText, dupePos, null, Color.White, orientation, origin, 1.0f, SpriteEffects.None, 0f);
}
}
else if (!isInUse && spearOwner!=null && !attackDown)
{
if (spearOwner.blinked)
return;
Vector2 screenPos = new Vector2(spearOwner.getPlayerRect().X, spearOwner.getPlayerRect().Y);
RotationAngle = (float)(MathHelper.Pi * .5);
//screenPos.Y += spearOwner.getPlayerRect().Height;
if(spearOwner.getDirectionFacing() == 1)
screenPos.X += spearOwner.getPlayerRect().Width+spear.Width/13;
else if (spearOwner.getDirectionFacing() == 0)
screenPos.X -= spear.Width/16;
//Drawing when the player is looping over
if (spearOwner.getDirectionFacing() == 1 && spearOwner.getPlayerRect().X + spearOwner.getPlayerRect().Width > SCREENSIZE.X)
{
screenPos.X = (spearOwner.getPlayerRect().X + spearOwner.getPlayerRect().Width) - SCREENSIZE.X;
//sB.Draw(drawnText, screenPos, null, Color.White, RotationAngle, origin, 1.0f, SpriteEffects.None, 0f);
}
//else
//sB.Draw(drawnText, screenPos, null, Color.White, RotationAngle, origin, 1.0f, SpriteEffects.None, 0f);
}
else if ((attackDown || isInUse) && spearOwner != null)
{
/*Vector2 screenPos = new Vector2(spearOwner.getPlayerRect().X, spearOwner.getPlayerRect().Y);
switch (spearOrientation) {
case 0:
RotationAngle = 0;
screenPos.X -= spearOwner.getPlayerRect().Width;
screenPos.Y += spearOwner.getPlayerRect().Height/2;
break;
case 2:
RotationAngle = (float)(MathHelper.Pi/2);
screenPos.X += spearOwner.getPlayerRect().Width / 2;
screenPos.Y -= 3*spearOwner.getPlayerRect().Height / 4;
break;
case 4:
RotationAngle = (float)(MathHelper.Pi);
screenPos.X += spearOwner.getPlayerRect().Width*2;
screenPos.Y += spearOwner.getPlayerRect().Height/2;
break;
case 6:
RotationAngle = (float)(3*MathHelper.Pi/2);
screenPos.X += spearOwner.getPlayerRect().Width/2;
screenPos.Y += 7*spearOwner.getPlayerRect().Height/4;
break;
}
sB.Draw(drawnText, screenPos, null, Color.White, RotationAngle, origin, 1.0f, SpriteEffects.None, 0f);
*/
//if (attackDown)
//{
RotationAngle = orientation + (float)Math.PI;
Vector2 normDir = spearVector;
normDir.X *= 10;
normDir.Y *= 10;
normDir.Normalize();
Vector2 screenPos = new Vector2(spear.X+16, spear.Y+8);//new Vector2(spear.Location, spearOwner.getPlayerRect().Center.Y+(normDir.Y*32));
//}
origin = new Vector2(16, 8);
if (attackDown)
{
drawnText = indicatorText;
}
sB.Draw(drawnText, screenPos, null, Color.White, RotationAngle, origin, 1.0f, SpriteEffects.None, 0f);
}
}