public CameraFollowTargetEngine(ITime time) { _time = time; _taskRoutine = TaskRunner.Instance.AllocateNewTaskRoutine().SetEnumerator(PhysicUpdate()) .SetScheduler(StandardSchedulers.physicScheduler); _taskRoutine.Start(); }
void Update() { if (Input.GetKeyDown(KeyCode.Space)) { if (_paused == false) { Debug.LogWarning("Paused!"); _taskRountine.Pause(); _paused = true; } else { Debug.LogWarning("Resumed!"); _paused = false; _taskRountine.Resume(); } } if (Input.GetKeyUp(KeyCode.S)) { _taskRountine.Start(); } }
public GamePadInputDeviceManager() { gamePadState = new RingBuffer <GamePadState> [maxDevices]; deviceConnected = new bool[maxDevices]; _taskRoutine = TaskRunner.Instance.AllocateNewTaskRoutine().SetEnumerator(GamePadStateEnqueue()); if (InputManager.XInputUpdateRate == 0) { timeStep = Mathf.floorToInt(Time.deltaTime * 1000.0f); } else { timeStep = Mathf.floorToInt(1.0f / InputManager.XInputUpdateRate * 1000.0f); } bufferSize = (int)Math.Max(InputManager.XInputBufferSize, 1); for (int deviceIndex = 0; deviceIndex < maxDevices; deviceIndex++) { gamePadState[deviceIndex] = new RingBuffer <GamePadState>(bufferSize); } for (int deviceIndex = 0; deviceIndex < maxDevices; deviceIndex++) { GamePadInputDevice gamePad = new GamePadInputDevice(deviceIndex, this); devices.Add(gamePad); } _taskRoutine.Start(); }
IEnumerator CalculateAndShowNumber() //this will run on another thread { while (true) { IEnumerator enumerator = FindPrimeNumber((rnd1.Next() % 1000)); yield return(enumerator); long result = (long)enumerator.Current * 333; taskRoutine.SetEnumerator(SetColor(result)); yield return(taskRoutine.Start()); //yep the thread will wait for this other task to finish on the mainThreadScheduler } }
public void Step(ref TurnInfo token, int condition) { if (condition == TurnCondition.starting) { if (entityViewsDB.TryQueryEntityView(token.entityID, out _playerEntityView)) { _taskRoutine.Start(); } } else { _taskRoutine.Stop(); _playerEntityView = null; } }
public IEnumerator TestUnityWait() { var coroutineMonoRunner = new CoroutineMonoRunner("test1"); ITaskRoutine <IEnumerator> taskRoutine = TaskRunner.Instance.AllocateNewTaskRoutine(coroutineMonoRunner); taskRoutine.SetEnumeratorProvider(new WaitForSecondsUnity().GetEnumerator); taskRoutine.Start(); DateTime then = DateTime.Now; while (taskRoutine.isRunning == true) { yield return(null); } coroutineMonoRunner.Dispose(); var totalSeconds = (DateTime.Now - then).TotalSeconds; Assert.That(totalSeconds, Is.InRange(0.9, 1.1)); }
public IEnumerator TestUnityWaitInParallel() { var updateMonoRunner = new UpdateMonoRunner("test1"); ITaskRoutine <IEnumerator> taskRoutine = TaskRunner.Instance.AllocateNewTaskRoutine(updateMonoRunner); ParallelTaskCollection pt = new ParallelTaskCollection(); pt.Add(new WaitForSecondsUnity().GetEnumerator()); pt.Add(new WaitForSecondsUnity().GetEnumerator()); taskRoutine.SetEnumerator(pt); taskRoutine.Start(); DateTime then = DateTime.Now; while (taskRoutine.isRunning == true) { yield return(null); } updateMonoRunner.Dispose(); var totalSeconds = (DateTime.Now - then).TotalSeconds; Assert.That(totalSeconds, Is.InRange(0.9, 1.1)); }
public void Step(ref UserMovementInfo[] token, int condition) { string resultText; if (token[0].userMovement == token[1].userMovement) { resultText = DataConstants.ResultTexts.Draw; Debug.Log("Empate"); } else { if (token[0].userMovement != UserMovement.None && token[1].userMovement != UserMovement.None) { if (_movements[token[0].userMovement] == token[1].userMovement) { resultText = DataConstants.ResultTexts.Win; Debug.Log("Gana usuario 0"); } else { resultText = DataConstants.ResultTexts.Lose; Debug.Log("Gana usuario 1"); } } else { resultText = CheckNoneMovement(token); } } ResultTextView resultTextView = entityViewsDB.QueryEntityViews <ResultTextView>()[0]; resultTextView.TextComponent.SetText = resultText; resultTextView.LerpAlphaColorComponent.SetVisibleAndDisappearWhenFinished = true; _taskRoutine.Start(); }
// Use this for initialization void Start() { _taskRountine = TaskRunner.Instance.AllocateNewTaskRoutine().SetEnumeratorProvider(ResetTaskAndRun); //The Task routine is pooled! You could have used Start directly, but you need to use SetEnumeratorProvider if you want restart the TaskRoutine later _taskRountine.Start(); }
protected override void Add(PlayerActionLeftStickEntityView playerActionLeftStickEntityView) { _playerActionLeftStickEntityView = playerActionLeftStickEntityView; _taskRoutine.Start(); }
protected override void Add(PlayerActionSetEntityView entityView) { _playerActionSetEntityView = entityView; _taskRoutine.Start(); }