public bool Use(Character attacker, Vector2 position) { if (Global.random.Next(100) >= 100 - Accuracy) { //TODO: Move ContentManager to global because these workarounds are simply dumb //Also, move initializaition of this variable to constructor (for some reason it throws NullPointerException there) ProjectileTexture = Global.CombatManager.levelManager.Content.Load <Texture2D>("spells/Shuriken"); Attacker = attacker; float distanceX = position.X - attacker.Center.X; float distanceY = position.Y - attacker.Center.Y; float rotation = (float)Math.Atan2(distanceY, distanceX); Vector2 tempVelocity = new Vector2((float)Math.Cos(rotation) * 4f, ((float)Math.Sin(rotation)) * 4f); Vector2 tempPosition = attacker.Center + tempVelocity * 10; Projectile newProjectile = new RotatingPiercingProjectille(this, Attacker, tempVelocity, tempPosition, ProjectileTexture, rotation, Range, VanishDelay); Global.CombatManager.PutProjectile(newProjectile); return(true); //Attack hit } else { Global.Gui.WriteToConsole(attacker.Name + " missed " + Name); return(false); //Attack missed } }
public bool Use(Character attacker, Vector2 position) { //TODO: Move ContentManager to global because these workarounds are simply dumb //Also, move initializaition of this variable to constructor (for some reason it throws NullPointerException there) ProjectileTexture = Global.CombatManager.levelManager.Content.Load <Texture2D>("spells/ThrowingWeapon"); Attacker = attacker; float distanceX = position.X - attacker.Center.X; float distanceY = position.Y - attacker.Center.Y; float rotation = (float)Math.Atan2(distanceY, distanceX); Vector2 tempVelocity = new Vector2((float)Math.Cos(rotation) * 4f, ((float)Math.Sin(rotation)) * 4f) + attacker.Velocity / 3; Vector2 tempPosition = attacker.Center + tempVelocity * 10; Projectile newProjectile = new RotatingPiercingProjectille(this, Attacker, tempVelocity, tempPosition, ProjectileTexture, rotation, Range, VanishDelay); Global.CombatManager.PutProjectile(newProjectile); return(true); //Since accuracy of this attack is 100 and we want to implement this interface correctly.. maybe should change return type to void }