public bool TryLock(PinLockLine line) { if (_state == State.Free) { _lockedParticles.Play(); _rigidbody.gravityScale = 0.0f; _rigidbody.velocity = Vector2.zero; Vector2 offset = transform.position - _slotPos.position; Vector2 curPos = transform.position; curPos.y = line.transform.position.y + offset.y; transform.localPosition = curPos; _rigidbody.position = transform.position; _lockedTime = Time.time; _springJoint.enabled = false; _state = State.Locked; PinStateChangedEvent.Invoke(new Args(this)); return(true); } return(false); }
public bool OnUse(PinLockLine line) { if (_mode == Mode.Lock) { return(_pin.TryLock(line)); } else { line.UnlockAll(true); return(true); } }
public Args(PinLockLine line) { LockLine = line; }