本文整理汇总了C#中Timer.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# Timer.Reset方法的具体用法?C# Timer.Reset怎么用?C# Timer.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer.Reset方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
dialogueTimer = new Timer(StartTime);
dialogueTimer.Reset();
dialogueTimer.Reset();
mainCamera = GameObject.Find("Main Camera");
text = GetComponent<Transform>().Find("Text").gameObject;
}
示例2: TestReset
public void TestReset()
{
double duration = 0.79;
double subtract = 0.5;
Timer t = new Timer(duration);
t.Update(subtract);
t.Reset();
Assert.AreEqual(t.GetTimeLeft(), duration);
t.Update(duration);
t.Reset();
Assert.IsFalse(t.IsDone());
}
示例3: Start
// Use this for initialization
void Start () {
circles = GetComponentsInChildren<Circle>();
inputField = GameObject.Find("Canvas/InputField").GetComponent<InputField>();
stressBar = GameObject.Find("Canvas/Stress").GetComponent<Slider>();
audios = GetComponents<AudioSource>();
blackBackground = GameObject.Find("Canvas/BlackBackground");
gameOver = GameObject.Find("Canvas/BlackBackground/GameOver");
pressEnter = GameObject.Find("Canvas/BlackBackground/PressEnter");
gameStart = GameObject.Find("Canvas/BlackBackground/GameStart");
healthIndicator = GameObject.Find("Canvas/HealthIndicator").GetComponent<HealthIndicator>();
gameOver.SetActive(false);
isGameOver = true;
healthIndicator.SetTransparency(0f);
currentDay = 0;
taskIndex = 0;
dayTimer = new Timer(30f);
endOfDayTimer = new Timer(4f);
dayTimer.Reset();
taskTimer = new Timer(StepTimeBasedOnDay);
prevRandTask = 0;
daysData = CSVParser.Parse("Data/days");
}
示例4: Update
// Update is called once per frame
void Update()
{
GetComponent<Transform>().LookAt(-mainCamera.GetComponent<Transform>().position);
GetComponent<Transform>().localPosition = new Vector3(0f, 5.69f, 0f);
if (dialogueTimer.IsOffCooldown()) {
Activate();
dialogueTimer = new Timer(NewTalkTime);
dialogueTimer.Reset();
}
}
示例5: Go
/// <summary>
/// Initializes & executes the server runtime loop
/// </summary>
public void Go()
{
float MAX_UPDATE = 1.0f / 60.0f;
Mogre.Timer frameTimer = new Timer();
frameTimer.Reset();
SafeTimer timer = new SafeTimer();
while (true) {
System.Threading.Thread.Sleep(10);
eventMgr.Update();
IPAddress ip = null;
while ((ip = netServer.GetDisconnectedIP()) != null)
{
netServer.RemovePlayer(ip);
}
if (netServer.NumPlayers == 0)
break;
//world update
float diff = (float)timer.Diff / 1000.0f;
while (diff > MAX_UPDATE) {
this.world.update(MAX_UPDATE);
diff -= MAX_UPDATE;
}
if (diff > 0) {
this.world.update(diff);
}
frameTimer.Reset();
mode.ProcessState();
serverShipMgr.sendShipStateStatus();
}
}
示例6: TestTimerGet
public void TestTimerGet()
{
Timer timer = new Timer();
timer.Reset();
timer.Start();
Timer.Delay(.3);
timer.Stop();
Assert.That(timer.HasPeriodPassed(0.25));
Assert.That(!timer.HasPeriodPassed(0.55));
Assert.That(timer.Get, Is.EqualTo(0.3).Within(0.05));
Timer.Delay(0.3);
Assert.That(timer.HasPeriodPassed(0.25));
Assert.That(!timer.HasPeriodPassed(0.55));
Assert.That(timer.Get, Is.EqualTo(0.3).Within(0.05));
}
示例7: Basics
public void Basics()
{
double elapsedTime, cpuTime, userTime, kernelTime, cpuUtilization;
Timer time = new Timer(),
test = new Timer();
time.Reset();
for (int k = 1000000; k > 0; k--)
{
test.Reset(); // get times in one call
elapsedTime = test.Read(out cpuTime, out cpuUtilization);
}
// get times one at a time.
elapsedTime = time.ElapsedTime;
cpuTime = time.CpuTime;
userTime = time.UserTime;
kernelTime = time.KernelTime;
Console.WriteLine("Timer read/write cost: {0:F4} microseconds.", elapsedTime);
Console.WriteLine("CPU time: {0:F4} microseconds.", cpuTime);
Console.WriteLine("User time: {0:F4} microseconds.", userTime);
Console.WriteLine("Kernal time: {0:F4} microseconds.", kernelTime);
}
示例8: UpdateAfterCamera
public void UpdateAfterCamera()
{
if(interactableHeld != null)
{
if (gameManager.running && Input.GetMouseButtonDown(0))
{
interactableHeld.Throw(this);
interactableHeld = null;
}
else
{
interactableHeld.Held(this);
}
}
else
{
Vector3 hitPoint;
Interactable interactable = cameraController.GetInteractable(out hitPoint);
if (interactableAimed != interactable)
{
if (interactableAimed != null)
interactableAimed.MouseLeave(this);
if (interactable != null)
interactable.MouseEnter(this);
}
if (interactable != null)
{
interactable.MouseAimed(this);
if (gameManager.running && Input.GetMouseButtonDown(0) && interactable.IsCloseEnough(this))
{
interactableHeld = interactable;
interactableHeld.Take(this);
grabTimer = new Timer();
grabTimer.Reset();
}
}
interactableAimed = interactable;
}
}
示例9: TestSet
public void TestSet()
{
double duration = 0.79;
double duration2 = 0.65;
double subtract = 0.5;
Timer t = new Timer(duration);
t.Update(subtract);
t.Set(duration2);
Assert.AreEqual(t.GetTimeLeft(), duration2);
t.Update(duration2);
t.Reset();
Assert.IsFalse(t.IsDone());
Assert.AreEqual(t.GetTimeLeft(), duration2);
Assert.AreEqual(t.Duration, duration2);
// Test that timespan works as well
TimeSpan d1 = new TimeSpan(123456);
t.Set(d1.TotalSeconds);
double tmp = t.Duration;
t.Set(d1);
Assert.AreEqual(tmp, t.Duration);
}
示例10: TestUpdate
public void TestUpdate()
{
TimeSpan duration = new TimeSpan(123456);
TimeSpan sub = new TimeSpan(1234);
Timer t = new Timer(duration);
Assert.IsTrue(t.Update(duration));
Assert.IsTrue(t.IsDone());
Assert.AreEqual(0, t.GetTimeLeft());
t.Reset();
Assert.IsTrue(t.Update(duration.TotalSeconds));
Assert.IsTrue(t.IsDone());
Assert.AreEqual(0, t.GetTimeLeft());
t.Reset();
Assert.IsFalse(t.Update(sub));
Assert.IsFalse(t.IsDone());
Assert.AreEqual(duration.TotalSeconds - sub.TotalSeconds, t.GetTimeLeft());
}
示例11: Main
static void Main(string[] args)
{
//Get the intstance of Map. Map is singleton.
Map currentMap = Map.Instance;
string[] mappackList = { "HardcodedLevels",
"EasyMaps"};
int levelCounter = 1;
//Create a timer and start it in a new Thread
Timer timer = new Timer(InitialTimerLimit);
System.Threading.Thread theTimerThread = new System.Threading.Thread(new System.Threading.ThreadStart(timer.Start));
theTimerThread.Start();
foreach (string mappackName in mappackList)
{
Mappack currentMappack = new Mappack(mappackName);
currentMap = currentMappack.NextMap();
while (true)
{
try
{
//Get next map
if (currentMap == null)
{
break;
}
//Create Keyboard and ConsolreRenderer objects
IUserInterface keyboard = new Keyboard();
IRenderer renderer = new ConsoleRenderer(currentMap.Size.Y, currentMap.Size.X, currentMap.OriginTopLeft);
//Create the Engine object
Engine engine = new Engine(currentMap.ObjectDictionary, renderer, keyboard, levelCounter, timer, (currentMap.TimeLimit > 0));
//Subscribe for keyboard events
keyboard.OnRightPressed += (sender, eventInfo) =>
{
PlayerArgs playerInfo = (PlayerArgs)eventInfo;
int playerType = playerInfo.Player;
engine.MoveRight(playerType);
};
keyboard.OnLeftPressed += (sender, eventInfo) =>
{
PlayerArgs playerInfo = (PlayerArgs)eventInfo;
int playerType = playerInfo.Player;
engine.MoveLeft(playerType);
};
keyboard.OnUpPressed += (sender, eventInfo) =>
{
PlayerArgs playerInfo = (PlayerArgs)eventInfo;
int playerType = playerInfo.Player;
engine.MoveUp(playerType);
};
keyboard.OnDownPressed += (sender, eventInfo) =>
{
PlayerArgs playerInfo = (PlayerArgs)eventInfo;
int playerType = playerInfo.Player;
engine.MoveDown(playerType);
};
keyboard.OnResetPressed += (sender, eventInfo) =>
{
timer.Reset();
engine.Reset();
};
keyboard.OnShowControlsPressed += (sender, eventInfo) =>
{
renderer.DisplayControls();
};
timer.InitialTime = currentMap.TimeLimit;
//Reset the timer and Run the Engine
timer.Reset();
engine.Run();
System.Threading.Thread.Sleep(500);
// Next Map
levelCounter++;
currentMap = currentMappack.NextMap();
}
catch (TimeoutException ex)
{
ConsoleRenderer.DisplayTimeOut();
}
catch (IndexOutOfRangeException)
{
}
}
}
ConsoleRenderer.PlayerWon();
Environment.Exit(0);
}
示例12: AloitaPeli
void AloitaPeli()
{
LohkojenMaara = 9;//Lohkojen täytyy yhdessä muodostaa neliön muotoinen alue. KUN MAAILMAN KOKOA MUUTETAAN, tämä muuttuja TÄYTYY PÄIVITTÄÄ! Muuten LataaLohko voi ladata väärät lohkot.
oet = 50;//oet = objektien etäisyys toisistaan
ajastin = new Timer();
ajastin.Interval = 3;
ajastin.Timeout += delegate()
{
voiVaihtaaLohkoa = true;
ajastin.Stop();//tekeekö reset tämän automaattisesti?
ajastin.Reset();
};
LataaLohko(5);
AsetaOhjaimet();
luoVarsJousi();
luoPuhPutki();
puhPutki.Destroy();
varsJousi.Destroy();
ase = "tyhja";
}
示例13: BombExplosion
public void BombExplosion(PhysicsObject bomb)
{
SoundEffect BombExplosion = LoadSoundEffect("Bomb");
BombExplosion.Play();
RRProjectile bombExplosion = new RRProjectile(5.0, 999999999999, "explosion");
bombExplosion.Position = bomb.Position;
bombExplosion.Damage = 150;
bombExplosion.Tag = "BX";
bombExplosion.IgnoresCollisionResponse = true;
bombExplosion.IgnoresGravity = true;
AddCollisionHandler<RRProjectile, RREnemy>(bombExplosion, playerCollisionHandler);
Add(bombExplosion);
RRProjectile bombShockwave = new RRProjectile(5.0, 999999999999, new Color(212, 0, 52, 30));
bombShockwave.Position = bomb.Position;
bombShockwave.Damage = 0.1;
bombShockwave.Tag = "BS";
bombShockwave.IgnoresCollisionResponse = true;
bombShockwave.IgnoresGravity = true;
AddCollisionHandler<RRProjectile, RREnemy>(bombShockwave, playerCollisionHandler);
Add(bombShockwave);
Timer growExplosion = new Timer();
growExplosion.Interval = 0.02;
growExplosion.Start();
growExplosion.Timeout += delegate
{
if (bombExplosion.Width >= 2500 & bombExplosion.Height >= 2500) { growExplosion.Reset(); bombExplosion.Destroy(); bombShockwave.Destroy(); }
else { bombExplosion.Width = bombExplosion.Width * 1.05; bombExplosion.Height = bombExplosion.Height * 1.05; bombShockwave.Width = bombShockwave.Width * 2.5; bombShockwave.Height = bombShockwave.Height * 2.5; }
};
}