Shooting satellites works

This commit is contained in:
2021-04-11 18:42:22 +02:00
parent 2f7759d190
commit c989202d93
10 changed files with 116 additions and 13 deletions
+5 -1
View File
@@ -24,7 +24,7 @@ namespace EvilSatellites.Objects
public Vector3 Movement;
private Vector3 _Orientation;
public Vector3 Orientation
{
{
get => _Orientation;
set => _Orientation = value;
}
@@ -38,10 +38,14 @@ namespace EvilSatellites.Objects
public IScreen Screen;
public ObjectType Type { get; set; }
public bool IsDynamic { get => true; }
public bool ShouldDestroy { get; set; }
public bool Active { get; set; }
public AbstractGameObject(IScreen screen)
{
Screen = screen;
Type = ObjectType.Generic;
ShouldDestroy = false;
}
public void RotateX(float angle)
+2 -1
View File
@@ -19,6 +19,7 @@ namespace EvilSatellites.Objects
ObjectType Type { get; set; }
void Move(Vector3 pose);
void OnCollision(IGameObject obj);
bool ShouldDestroy { get; }
bool Active { get; set; }
}
}
+3 -1
View File
@@ -7,6 +7,8 @@ namespace EvilSatellites.Objects
public enum ObjectType
{
Generic,
Player
Player,
Satellite,
Projectile
}
}
+3 -1
View File
@@ -18,13 +18,15 @@ namespace EvilSatellites.Objects
public IWeapon CurrentWeapon;
public Player(IScreen screen): base(screen)
{
ShouldDestroy = false;
Active = true;
Type = ObjectType.Player;
Position = new Vector3(10, 0, 0);
Dimensions = new Vector3(5, 5, 5);
Movement = new Vector3(0, 0, 0);
Rotation = Matrix.Identity;
Orientation = Rotation.Forward;
CurrentWeapon = new LaserMG(this, Screen);
CurrentWeapon = new LaserMG(this, (GameScreen)Screen);
Activate();
}
+56
View File
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SynthySound;
using Microsoft.Xna.Framework;
using EvilSatellites.Screens;
namespace EvilSatellites.Objects
{
public class Projectile : AbstractGameObject
{
private ISoundEffect3D Sound;
private Vector3 Direction;
private Vector3 StartPos;
private float Range;
public Projectile(IScreen screen, Vector3 pos, Vector3 direction) : base(screen)
{
StartPos = pos;
Position = pos;
Dimensions = new Vector3(5, 5, 5);
Direction = direction;
Range = 500;
Type = ObjectType.Projectile;
Activate();
}
public override void Activate()
{
ShouldDestroy = false;
Active = true;
}
public override void Destroy()
{
ShouldDestroy = true;
Active = false;
}
override public void Update(GameTime gameTime)
{
Position += Direction;
if (Vector3.Distance(StartPos, Position) > Range)
{
Destroy();
}
}
public override void OnCollision(IGameObject obj)
{
if (obj.Type == ObjectType.Player) return;
Screen.Manager.Sound.PlayOneshot(@"sfx/physics/impacts/bullet/1.wav", new System.Numerics.Vector3(Position.X, Position.Y, Position.Z), Screen.Manager.EnvironmentEffect);
Destroy();
}
}
}
+4 -1
View File
@@ -14,6 +14,7 @@ namespace EvilSatellites.Objects
private ISoundEffect3D Sound;
public Satellite(IScreen screen, Vector3 pos) : base(screen)
{
Type = ObjectType.Satellite;
Sound = Screen.Manager.Sound.Load3D(@"sfx/satellite/1/loop.wav");
Sound.Loop = true;
Position = pos;
@@ -26,6 +27,8 @@ namespace EvilSatellites.Objects
public override void Activate()
{
Sound.Play();
Active = true;
ShouldDestroy = false;
}
public override void Destroy()
{
@@ -39,7 +42,7 @@ namespace EvilSatellites.Objects
public override void OnCollision(IGameObject obj)
{
Sound.Stop();
// Sound.Stop();
}
}
}