private void MovingUp() { if (forkBase.position.y >= maxHeight.position.y) { _state = ForkState.WaitingTop; return; } _state = ForkState.MovingUp; var move = 1 * Time.deltaTime * moveSpeed; forkBase.position += new Vector3(0, move, 0); if (telescopeRails == null) { return; } if (_telescopeExtension > maxTelescopeExtension) { return; } foreach (var rail in telescopeRails) { move /= telescopeRails.Length; _telescopeExtension += move; rail.position += new Vector3(0, move, 0); } }
private void MovingDown() { if (forkBase.position.y <= minHeight.position.y) { _state = ForkState.WaitingBottom; return; } _state = ForkState.MovingDown; var move = 1 * Time.deltaTime * moveSpeed; forkBase.position -= new Vector3(0, move, 0); if (telescopeRails == null) { return; } if (_telescopeExtension <= 0) { return; } foreach (var rail in telescopeRails) { move /= telescopeRails.Length; _telescopeExtension -= move; rail.position -= new Vector3(0, move, 0); } }
private void Waiting() { if (_currentTimer > pauseDuration) { _state = _state == ForkState.WaitingBottom ? ForkState.MovingUp : ForkState.MovingDown; _currentTimer = 0; return; } _currentTimer += Time.deltaTime; }