Final-Bomber  0.1
Bomberman/Dynablaster remake in C# using XNA.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
Timer.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Diagnostics;
4 using System.Linq;
5 using System.Text;
6 
7 namespace FBServer
8 {
9  public class Timer
10  {
11  int ticks = 0;
12  Stopwatch timer;
13  bool isStarted = false;
14 
15  public bool IsStarted
16  {
17  get { return isStarted; }
18  }
19 
20  public Timer(bool start)
21  {
22  timer = new Stopwatch();
23  if (start)
24  Start();
25  }
26 
27  public void Start()
28  {
29  if (!isStarted)
30  {
31  timer.Start();
32  isStarted = true;
33  }
34  }
35 
36  public void Stop()
37  {
38  if (isStarted)
39  {
40  timer.Stop();
41  isStarted = false;
42  }
43  }
44 
45  public void Reset()
46  {
47  if (isStarted)
48  {
49  timer.Reset();
50  timer.Start();
51  }
52  }
53 
54  public long ElapsedMilliseconds
55  {
56  get { return timer.ElapsedMilliseconds; }
57  }
58 
59  public bool Each(int time)
60  {
61  if (isStarted)
62  {
63  if (timer.ElapsedMilliseconds > time)
64  {
65  Reset();
66  ticks++;
67  return true;
68  }
69  }
70  return false;
71  }
72  }
73 }
void Reset()
Definition: Timer.cs:45
long ElapsedMilliseconds
Definition: Timer.cs:55
bool Each(int time)
Definition: Timer.cs:59
Timer(bool start)
Definition: Timer.cs:20
void Start()
Definition: Timer.cs:27
bool IsStarted
Definition: Timer.cs:16
void Stop()
Definition: Timer.cs:36