using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using SynthySound; using EvilSatellites.Screens; namespace EvilSatellites.Objects { public class Debris : AbstractGameObject { private ISoundEffect3D Sound; private Random rnd = new Random(); private Vector3 MovementVector; public Debris(IScreen screen, Vector3 pos) : base(screen) { Type = ObjectType.Debris; Sound = Screen.Manager.Sound.Load3D(@"sfx/debris/1/loop.wav"); Sound.Loop = true; Sound.Pitch = 0.9 + (float)rnd.NextDouble()*2; Position = pos; Dimensions = new Vector3(5, 5, 5); Sound.Position = new System.Numerics.Vector3(pos.X, pos.Y, pos.Z); MovementVector = new Vector3(-0.02f + (float)rnd.NextDouble() * 0.01f, -0.02f + (float)rnd.NextDouble() * 0.01f, -0.02f + (float) rnd.NextDouble() * 0.01f); Rotation = Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), 0); Sound.ConnectToEffect(Screen.Manager.EnvironmentEffect); Activate(); } public override void Activate() { Sound.Play(); Active = true; ShouldDestroy = false; } public override void Destroy() { Sound.Destroy(); ShouldDestroy = true; Active = false; } override public void Update(GameTime gameTime) { Move(MovementVector); Sound.Position = new System.Numerics.Vector3(Position.X+Dimensions.X/2, Position.Y+Dimensions.Y/2, Position.Z+Dimensions.Z/2); } public override void OnCollision(IGameObject obj) { if (obj.Type == ObjectType.Projectile) return; if (obj.Type == ObjectType.Player) { var player = (Player)obj; if (player.Vacuuming) { player.CurrentWeapon.Reload(rnd.Next(player.CurrentWeapon.MaxAmmo/4)); Destroy(); return; } player.TakeDamage(25); Destroy(); } } } }