internal static void deleteCollidingRock(PiercingProjectile Projectile, Level level, GraphicsDevice graphicsDevice) { Rock tempRock; for (int i = 0; i < level.rocks.Count; i++) { tempRock = level.rocks[i]; if (Vector2.Distance(Projectile.Center, tempRock.Center) < level.cellSize) { if (checkCollision(Projectile, tempRock, graphicsDevice)) { int CellX = (int)Math.Floor(tempRock.Center.X / level.cellSize); int CellY = (int)Math.Floor(tempRock.Center.Y / level.cellSize); level.grid.SetCellCost(new Position(CellX, CellY), 1.0f); level.rocks.RemoveAt(i); break; } } } }
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/Fireball"); 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) * 5f, ((float)Math.Sin(rotation)) * 5f) + attacker.Velocity / 3; Vector2 tempPosition = attacker.Center + tempVelocity * 10; Projectile newProjectile = new PiercingProjectile(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 }