void MovePlayer() { Vector3 movementDirection = GetMovementDirection(); if (_timerRoutine == null && _speedLevel < MaxSpeedLevel && movementDirection != Vector3.zero) { _timerRoutine = _timerCoroutineFactory.CreateTimer(_speedLevel + 1); _asyncTaskProcessor.Process(_timerRoutine, () => { _speedLevel++; Log.Debug("Speedlevel: {0}", _speedLevel); _timerRoutine = null; }); } if (movementDirection == Vector3.zero) { if (_walkingTimeout == null) { _walkingTimeout = _timerCoroutineFactory.CreateTimer(.25f); _asyncTaskProcessor.Process(_walkingTimeout, () => { _speedLevel = 1; if (_asyncTaskProcessor.IsProcessing(_timerRoutine)) { _asyncTaskProcessor.Cancel(_timerRoutine); _timerRoutine = null; _walkingTimeout = null; } }); } } else { if (_asyncTaskProcessor.IsProcessing(_walkingTimeout)) { _asyncTaskProcessor.Cancel(_walkingTimeout); _walkingTimeout = null; } } //Also if we have a nonzero velocity lets have the mesh kinda rotated forward //and bobbing as a little placeholder, more rotated per speed level var velocity = movementDirection * (InitialSpeed + (_speedLevel * SpeedMultiplier)); //Set direction and speed Rigidbody.velocity = Rigidbody.velocity .SetX(velocity.x) .SetZ(velocity.z); }
public void DisablePickUpColliderForHalfSecond() { if (_timer != null) { _asyncTaskProcessor.Cancel(_timer); } _playerGuyHooks.PlayerHandsCollider.GetComponent <Collider>().enabled = false; _timer = _timerCoroutineFactory.CreateTimer(.5f); _asyncTaskProcessor.Process(_timer, () => { _playerGuyHooks.PlayerHandsCollider.GetComponent <Collider>().enabled = true; _timer = null; }); }