aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Viruses/BeeperVirus.cs
blob: 79299c98b7c0e232a6e06d80c72921efdd196bae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ShiftOS.Engine;
using System.Windows.Forms;

namespace ShiftOS.WinForms.Viruses
{
    [Virus("beeper", "Beeper", "Sends a few annoying beeps through the speaker repeatedly on a set interval. The threatlevel determines the interval.")]
    public class BeeperVirus : IVirus
    {
        private Timer _virusTimer = null;

        public void Disinfect()
        {
            _virusTimer.Stop();
            _virusTimer = null;
        }

        public void Infect(int threatlevel)
        {
            _virusTimer = new Timer();
            _virusTimer.Interval = 5000 / threatlevel;
            _virusTimer.Tick += (o, a) =>
            {
                Engine.AudioManager.PlayStream(Properties.Resources._3beepvirus);
            };
            _virusTimer.Start();
        }
    }
}