// -------------------------------------------------------------------------

    private void Start()
    {
        this.spriteRenderer = this.GetComponentInChildren <SpriteRenderer>();
        Assert.IsNotNull(this.spriteRenderer, "Missing asset");

        this.canMove       = true;
        this.movementState = SnapGridMovementState.IDLE;

        Assert.IsNotNull(this.snapGridData, "Missing asset");
        Assert.IsTrue(this.moveDurationInSec > 0.0f, "Missing asset");
    }
    private void Update()
    {
        this.moveReloadAccumulatorInSec -= Time.fixedDeltaTime;
        if (this.moveReloadAccumulatorInSec <= 0.0f)
        {
            this.movementState = SnapGridMovementState.IDLE;
        }
        else
        {
            this.movementState = SnapGridMovementState.MOVING;
        }

        float t = this.moveDurationInSec - this.moveReloadAccumulatorInSec;

        this.spriteRenderer.transform.position = Vector3.Lerp(this.spriteRenderer.transform.position, this.transform.position, t);
    }
    public bool Move(SnapGridMovementDirection moveDirection)
    {
        if (this.IsMoving() || !this.canMove)
        {
            return(false);
        }

        if (this.CanMoveInDirection(moveDirection))
        {
            Vector2 moveVector = GetNormVectorFromDirection(moveDirection) * this.snapGridData.snapDistanceInUnityUnits;
            Debug.DrawLine(this.transform.position, this.transform.position + new Vector3(moveVector.x, moveVector.y, 0.0f), Color.yellow, 0.5f);

            Vector3 oldPosition = this.transform.position;
            this.moveReloadAccumulatorInSec = this.moveDurationInSec;
            this.movementState = SnapGridMovementState.MOVING;
            this.transform.Translate(moveVector);
            this.spriteRenderer.transform.position = oldPosition; // The sprite stays at the old position. Then lerp to new
            return(true);
        }

        return(false);
    }