Exemple #1
0
    private void Update()
    {
        if (anchorProperty.GetTransformProperty().Item3)
        {
            _distance = Vector3.Distance(transform.position, anchorProperty.GetTransformProperty().Item1);
            if (_distance >= 0.01f)
            {
                var newPos = Vector3.Lerp(transform.position, anchorProperty.GetTransformProperty().Item1, 35f * Time.deltaTime);
                transform.position = newPos;
                transform.rotation = anchorProperty.GetTransformProperty().Item2;
                //Debug.Log("corutin");
            }
            else
            {
                anchorProperty.SetTransformProperty(false);
                SvedObject.GetHitObject().gameObject.SetActive(false);


                _scoreManager.CalculateScore(anchorProperty.GetAnchorType(), anchorProperty.GetCurrentSelectedPiece());

                gameObject.tag = _untag;
                gameObject.transform.parent = _holder.transform;
                _undoBooster.AddToHistory(gameObject, jewelleryPos.GetValue(), SvedObject.GetHitObject().gameObject);
                this.enabled = false;
                Vibration.VibratePeek();
            }
        }
        else
        {
            _distance = Vector3.Distance(transform.position, jewelleryPos.GetValue());
            if (_distance > 0.1f)
            {
                var newPos = Vector3.Lerp(transform.position, jewelleryPos.GetValue(), 6f * Time.deltaTime);
                transform.position = newPos;
                //Debug.Log("corutin");
            }
            else
            {
                _rb.isKinematic = false;
                this.enabled    = false;
            }
        }
    }
Exemple #2
0
    void Update()
    {
        if (Physics.Raycast(transform.position, Vector3.down, out var hit, 0.5f, _selectableLayer))
        {
            _currentHitObject = hit.transform.gameObject;
            if (_currentHitObject != _lastHitObj)
            {
                if (_lastHitObj)
                {
                    _lastHitObj.GetComponent <Scale>().StopAnimation();
                }

                //Debug.Log("checking correct layer");
                _scale = _currentHitObject.GetComponent <Scale>();
                var anchor = _currentHitObject.GetComponent <Anchor>();
                _scale.ScleBody();
                _lastHitObj = _currentHitObject;
                anchorTransform.SetTransformProperty(_currentHitObject.transform.position, _currentHitObject.transform.rotation, true);
                SvedObject.SetTransformProperty(anchor);
                //anchorTransform.SetAnchor(anchor);
                anchorTransform.SetAnchorType(anchor.anchorType.pieceType);
            }
        }