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

public class Loading : MonoBehaviour {

	public GameObject loading;
	public Text text;

	private float actime = 0;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {

		if(Input.GetKeyDown(KeyCode.Escape))
		{
			loading.SetActive (false);
		}

		actime += Time.deltaTime;  // 시간을 매 프레임마다 더해줘서 누적시간을 만듭니다. 

		if (actime < 0.5) {
			text.text = "...";
		
		} else if (actime < 1) {
			text.text = "....";

		} else if (actime < 1.5) {
			text.text = ".....";

		} else if (actime < 2) {
			text.text = "......";

		} else if (actime < 2.5) {
			text.text = "......";

		} else if (actime < 3) {
			text.text = ".....";

		} else if (actime < 3.5) {
			text.text = "....";

		} else {
			actime = 0;        // 다시 시간을 계산합니다. 
			text.text = "...";
		}
	}


	public void show ()
	{
		actime = 0;
		loading.SetActive (true);
	}

	public void hide ()
	{
		actime = 0;
		loading.SetActive (false);
	}
}
