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 FBClient.Network
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()
21  {
22  timer = new Stopwatch();
23  }
24 
25  public void Start()
26  {
27  if (!isStarted)
28  {
29  timer.Start();
30  isStarted = true;
31  }
32  }
33 
34  public void Stop()
35  {
36  if (isStarted)
37  {
38  timer.Stop();
39  isStarted = false;
40  }
41  }
42 
43  public void Reset()
44  {
45  if (isStarted)
46  {
47  timer.Reset();
48  timer.Start();
49  }
50  }
51 
52  public long ElapsedMilliseconds
53  {
54  get { return timer.ElapsedMilliseconds; }
55  }
56 
57  public bool Each(int time)
58  {
59  if (timer.ElapsedMilliseconds > time)
60  {
61  timer.Reset();
62  timer.Start();
63  ticks++;
64  return true;
65  }
66  return false;
67  }
68  }
69 }
bool Each(int time)
Definition: Timer.cs:57