2021-04-11 17:09:57 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using EvilSatellites.Objects;
|
|
|
|
|
using SynthySound;
|
|
|
|
|
using EvilSatellites.Screens;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
|
|
|
|
|
namespace EvilSatellites.Weapons
|
|
|
|
|
{
|
|
|
|
|
public class LaserMG : AbstractWeapon
|
|
|
|
|
{
|
|
|
|
|
public AudioAsset sfxShoot;
|
|
|
|
|
public ISoundEffect sfxReload;
|
|
|
|
|
public ISoundEffect sfxSpindown;
|
|
|
|
|
public ISoundEffect sfxSpinup;
|
|
|
|
|
public ISoundEffect sfxSpinning;
|
2021-04-11 18:42:22 +02:00
|
|
|
public GameScreen Screen;
|
|
|
|
|
public LaserMG(IGameObject wielder, GameScreen screen)
|
2021-04-11 17:09:57 +02:00
|
|
|
{
|
|
|
|
|
_wielder = wielder;
|
|
|
|
|
Screen = screen;
|
|
|
|
|
MaxAmmo = 250;
|
|
|
|
|
RemainingAmmo = MaxAmmo;
|
|
|
|
|
FireRate = 90;
|
|
|
|
|
State = WeaponState.Stopped;
|
|
|
|
|
LoadSounds();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadSounds()
|
|
|
|
|
{
|
|
|
|
|
sfxReload = Screen.Manager.Sound.Load(@"sfx/weapons/LaserMG/reload.wav", false);
|
|
|
|
|
sfxSpindown = Screen.Manager.Sound.Load(@"sfx/weapons/LaserMG/spindown.wav", false);
|
|
|
|
|
sfxSpinup = Screen.Manager.Sound.Load(@"sfx/weapons/LaserMG/spinup.wav", false);
|
|
|
|
|
sfxSpinning = Screen.Manager.Sound.Load(@"sfx/weapons/LaserMG/spinning.wav", false);
|
|
|
|
|
sfxSpinning.Loop = true;
|
|
|
|
|
sfxShoot = new AudioAsset(Screen.Manager.Sound, @"sfx/weapons/LaserMG/fire", 1, 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Shoot(GameTime time)
|
|
|
|
|
{
|
|
|
|
|
State = WeaponState.Starting;
|
|
|
|
|
sfxSpinup.Reset();
|
|
|
|
|
sfxSpinup.Play();
|
|
|
|
|
TimerStart = time.TotalGameTime.TotalMilliseconds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Stop()
|
|
|
|
|
{
|
|
|
|
|
if (State == WeaponState.Firing)
|
|
|
|
|
{
|
|
|
|
|
sfxSpinning.Pause();
|
|
|
|
|
sfxSpindown.Reset();
|
|
|
|
|
sfxSpindown.Play();
|
|
|
|
|
State = WeaponState.Stopped;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Update(GameTime time)
|
|
|
|
|
{
|
|
|
|
|
TimerEnd += time.ElapsedGameTime.TotalMilliseconds;
|
|
|
|
|
if (State == WeaponState.Starting)
|
|
|
|
|
{
|
|
|
|
|
if (TimerEnd - TimerStart > 800)
|
|
|
|
|
{
|
|
|
|
|
State = WeaponState.Firing;
|
|
|
|
|
sfxSpinning.Play();
|
|
|
|
|
TimerStart = TimerEnd;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (State == WeaponState.Firing)
|
|
|
|
|
{
|
|
|
|
|
if (TimerEnd - TimerStart > FireRate)
|
|
|
|
|
{
|
|
|
|
|
sfxShoot.Play();
|
|
|
|
|
TimerStart = TimerEnd;
|
2021-04-11 20:43:29 +02:00
|
|
|
Projectile proj = new Projectile(Screen, _wielder.Position, _wielder.Rotation);
|
2021-04-11 18:42:22 +02:00
|
|
|
Screen.AddObject(proj);
|
2021-04-11 17:09:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
base.Update(time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|