65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using System;
|
|||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using SynthySound;
|
||
|
|
using Microsoft.Xna.Framework;
|
||
|
|
|
||
|
|
namespace EvilSatellites
|
||
|
|
{
|
||
|
|
public class SoundPatch
|
||
|
|
{
|
||
|
|
public Synthy _engine;
|
||
|
|
public ISoundEffect sndStart;
|
||
|
|
public ISoundEffect sndLoop;
|
||
|
|
public ISoundEffect sndStop;
|
||
|
|
public double StartTime;
|
||
|
|
public double currTime;
|
||
|
|
public double StartSoundTime;
|
||
|
|
public bool Starting;
|
||
|
|
public SoundPatch(Synthy engine, string path, float startSoundTime)
|
||
|
|
{
|
||
|
|
_engine = engine;
|
||
|
|
sndStart = _engine.Load(path + "/start.wav", false);
|
||
|
|
sndLoop = engine.Load(path + "/loop.wav", false);
|
||
|
|
sndStop = engine.Load(path + "/end.wav", false);
|
||
|
|
sndLoop.Loop = true;
|
||
|
|
Starting = false;
|
||
|
|
StartSoundTime = startSoundTime;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Start(GameTime time)
|
||
|
|
{
|
||
|
|
sndStart.Reset();
|
||
|
|
sndStart.Play();
|
||
|
|
currTime = time.TotalGameTime.TotalMilliseconds;
|
||
|
|
StartTime = time.TotalGameTime.TotalMilliseconds;
|
||
|
|
Starting = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Update(GameTime time)
|
||
|
|
{
|
||
|
|
currTime += time.ElapsedGameTime.TotalMilliseconds;
|
||
|
|
if (Starting)
|
||
|
|
{
|
||
|
|
if (currTime - StartTime > StartSoundTime)
|
||
|
|
{
|
||
|
|
|
||
|
|
Starting = false;
|
||
|
|
sndLoop.Play();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Stop()
|
||
|
|
{
|
||
|
|
Starting = false;
|
||
|
|
sndStart.Pause();
|
||
|
|
sndLoop.Pause();
|
||
|
|
sndStop.Reset();
|
||
|
|
sndStop.Play();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|