using System;
using System.Collections;
using System.Collections.Generic;
//using System.Linq;

//using UnityEditor;
using UnityEngine;
//using UnityEngine.UI;
// using Uhity.Entities;

using URD = UnityEngine.Random;

public class Ken : MonoBehaviour {
	
	
	public GameObject display;
	
	public Transform mark;
	
	public float min = -250, max = 250;
	
	public int count = 0;
	
	public void Show(bool state) {
		display.SetActive(state);
	}
	
	public void Begin() {
		StartCoroutine(MoveMark());
		
	}
	
	private IEnumerator MoveMark() {
		var t = 0f;
		
		var k = Mathf.PingPong(t,1);
	
		while(true) {
			
			t += Time.deltaTime;
			k = Mathf.PingPong(t,1);
			
			mark.localPosition = Vector3.right * Mathf.Lerp(min, max, k);
			
			if(Input.GetKeyDown(KeyCode.Space)) {
				yield return StartCoroutine(KenYiXia(k));
				t = 0;
			}
			
			yield return null;
		}
	
	}
	
	private IEnumerator KenYiXia(float k) {
		yield return new WaitForSeconds(2f);
		
		if(k>0.425f && k < 0.575f) count ++;
	}
	
}
