Initial debris

This commit is contained in:
2021-04-18 00:27:13 +02:00
parent d99cbe3211
commit cc3df2e2a5
15 changed files with 150 additions and 2 deletions
+48
View File
@@ -0,0 +1,48 @@
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;
public Debris(IScreen screen, Vector3 pos) : base(screen)
{
Sound = Screen.Manager.Sound.Load3D(@"sfx/debris/1/loop.wav");
Sound.Loop = true;
Position = pos;
Dimensions = new Vector3(5, 5, 5);
Sound.Position = new System.Numerics.Vector3(pos.X, pos.Y, pos.Z);
Sound.ConnectToEffect(Screen.Manager.EnvironmentEffect);
Activate();
}
public override void Activate()
{
Sound.Play();
Active = true;
ShouldDestroy = false;
}
public override void Destroy()
{
Sound.Destroy();
}
override public void Update(GameTime gameTime)
{
Sound.Position = new System.Numerics.Vector3(Position.X, Position.Y, Position.Z);
}
public override void OnCollision(IGameObject obj)
{
Sound.Stop();
}
}
}
+8
View File
@@ -14,6 +14,7 @@ namespace EvilSatellites.Objects
private ISoundEffect3D Sound;
private int Health;
private int SatelliteID;
private Random rnd = new Random();
public Satellite(IScreen screen, Vector3 pos, int satelliteID = 1) : base(screen)
{
Type = ObjectType.Satellite;
@@ -52,8 +53,15 @@ namespace EvilSatellites.Objects
if (Health <= 0)
{
Screen.Manager.Sound.PlayOneshot(@"sfx/satellite/"+SatelliteID.ToString()+"/explode.wav", new System.Numerics.Vector3(Position.X, Position.Y, Position.Z));
SpawnDebris();
Destroy();
}
}
public void SpawnDebris()
{
var screen = (GameScreen)Screen;
screen.AddObject(new Debris(screen, Position));
}
}
}