예제 #1
0
    private IEnumerator PlaceAnimation(ISelectable obj, Vector3 targetPos, Action <Vector3> movingAction)
    {
        float elapsedtime     = 0;
        float duration        = 0.3f;
        var   objectTransform = obj.GetPosition();

        while (elapsedtime < duration)
        {
            movingAction?.Invoke(Vector3.Lerp(objectTransform, targetPos, elapsedtime / duration));
            obj.Rotate(new Vector3(0, obj.GetRotation().y, 0));

            elapsedtime += Time.deltaTime;
            yield return(null);
        }

        var t = obj as IEditable;

        t.GetTransform().position = targetPos;
        t.GetTransform().gameObject.layer = 0;
        t.GetTransform().SetParent(transform);

        if (obj is UpperBun)
        {
            PlayState.Confirm();
        }
    }