using UnityEngine;
using System;

public class MoveTo : SomethingTo {

    private Vector3 fromPosition;
    private Vector3 targetPosition;
    private Vector3 initializePosition;
    public Vector3 InitializePosition{
        get{ return initializePosition; }
    }

    void Awake(){
        initializePosition = transform.position;
    }

    private void Lerp(float lerp){
        transform.position = Vector3.Lerp(fromPosition, targetPosition, lerp);
    }

    public void ChangePosition(Vector3 targetPosition, float interval, EasingType easingType = EasingType.Linear){
        ChangePosition(transform.position, targetPosition, interval, ActionExtensions.EmptyAction, easingType);
    }
    public void ChangePosition(Vector3 fromPosition, Vector3 targetPosition, float interval, EasingType easingType = EasingType.Linear){
        ChangePosition(fromPosition, targetPosition, interval, ActionExtensions.EmptyAction, easingType);
    }
    public void ChangePosition(Vector3 targetPosition, float interval, Action callback, EasingType easingType = EasingType.Linear){
        ChangePosition(transform.position, targetPosition, interval, ActionExtensions.EmptyAction, easingType);
    }
    public void ChangePosition(Vector3 fromPosition, Vector3 targetPosition, float interval, Action callback, EasingType easingType = EasingType.Linear){
        this.targetPosition = targetPosition;
        this.fromPosition = fromPosition;
        Begin(Lerp, interval, callback, easingType);
    }
}
