/// <summary> /// the direction of the fireball is taken from the mouse position in other words the projectile is launched towards the current mouse position /// </summary> private void addProjectile() { MouseState mouseState = Mouse.GetState(); Vector2 mousePosition = new Vector2(mouseState.X,mouseState.Y); MissileSpell projectile = new Fireball(_game,_gameState,Position); projectile.CastDirection(Input.getMouseWorldPosition(mousePosition,_gameState.camera,_game.Graphics.GraphicsDevice)); _game.Components.Add(projectile); }
private void UnserializeMissiles(List<MissileData> newMissilesData) { // delete current missiles foreach (var missile in _inGame._game.Components.OfType<MissileSpell>().ToArray()) { _inGame._game.Components.Remove(missile); } foreach (var missileData in newMissilesData) { MissileSpell missile = new Fireball(_inGame._game, _inGame, missileData.Position); missile.Direction = missileData.Direction; _inGame._game.Components.Add(missile); } }