using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HyperJumpState : State {
    [SerializeField] private Transform starField = null; // Set from editor
    [SerializeField] private int fieldSize = 160;
    [SerializeField] private float jumpTime = 1f;
    [SerializeField] private float fieldPerSecond = 3f;

    private float timer = 0;
    private float fieldShift = 0;

    protected override void OnStateShow() {
        timer = jumpTime;
    }

    // Update is called once per frame
    void Update () {
        if (timer > 0) {
            timer -= Time.deltaTime;
            fieldShift += fieldPerSecond * Time.deltaTime;
            fieldShift -= Mathf.Floor(fieldShift);
            starField.localPosition = new Vector3(Mathf.Round(-fieldShift * (float)fieldSize), 0, 0);
        } else {
            PlayerData.ShowQuest();
        }
	}
}
