当前位置: 首页>>代码示例>>C#>>正文


C# Timer.Reset方法代码示例

本文整理汇总了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;
    }
开发者ID:fdu5526,项目名称:ktp,代码行数:11,代码来源:DialogueBox.cs

示例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());
        }
开发者ID:Vectovox,项目名称:MonoKle,代码行数:13,代码来源:TimerTest.cs

示例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");
	}
开发者ID:fdu5526,项目名称:CTIN492_FoundText,代码行数:27,代码来源:CirclesManager.cs

示例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();
        }
    }
开发者ID:fdu5526,项目名称:ktp,代码行数:12,代码来源:DialogueBox.cs

示例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();
            }
        }
开发者ID:andyhebear,项目名称:ymfas,代码行数:41,代码来源:TestEngineServer_Run.cs

示例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));
        }
开发者ID:chopshop-166,项目名称:WPILib,代码行数:16,代码来源:TestWPITimer.cs

示例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);
 }
开发者ID:lwes,项目名称:lwes-dotnet,代码行数:21,代码来源:TimerTests.cs

示例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;
     }
 }
开发者ID:robinfaury,项目名称:Genevieve,代码行数:39,代码来源:Genevieve.cs

示例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);
        }
开发者ID:Vectovox,项目名称:MonoKle,代码行数:23,代码来源:TimerTest.cs

示例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());
 }
开发者ID:Vectovox,项目名称:MonoKle,代码行数:17,代码来源:TimerTest.cs

示例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);
        }
开发者ID:Bezideiko,项目名称:OOP,代码行数:93,代码来源:GameLoader.cs

示例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";
 }
开发者ID:Ky1e,项目名称:endless-rpg,代码行数:20,代码来源:Endless.cs

示例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; }
        };
    }
开发者ID:JakezuGD,项目名称:RampageRebellion,代码行数:32,代码来源:RRBegin.cs


注:本文中的Timer.Reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。