<commit_before>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class EnemySpawnner : MonoBehaviour {

	public GameObject[] enemy;

	float posY1;
	float posY2;

	Tweener tween1;
	Tweener tween2;

	void Update () {
		if (Input.GetKeyDown (KeyCode.I)) {
			OneWave ();
		} else if (Input.GetKeyDown (KeyCode.O)) {
			TwoWave ();
		} else if (Input.GetKeyDown (KeyCode.P)) {
			FullRandom ();
		} else if (Input.GetKeyDown (KeyCode.U)) {
			WallOfEnemies (3);
		}

		/*if(Time.time - lastTime > 0.3f){
			var pos = this.transform.position;
			pos.y = posY;
			Instantiate(enemy, pos, this.transform.rotation);
			lastTime = Time.time;
		}*/
	}

	void TrySpawn(ref float lastTime, int i){
		if (i == 1) {
			if (Time.time - lastTime > 2f) {
				var pos = this.transform.position;
				pos.y = posY1;
				Instantiate (enemy[Random.Range(0, enemy.Length)], pos + new Vector3(10,0,0), this.transform.rotation);
				lastTime = Time.time;
			}
		} else {
			if (Time.time - lastTime > 2f) {
				var pos = this.transform.position;
				pos.y = posY2;
				Instantiate (enemy[Random.Range(0, enemy.Length)], pos + new Vector3(10,0,0), this.transform.rotation);
				lastTime = Time.time;
			}
		}
	}

	void TwoWave(){
		float lastTime1 = 0, lastTime2 = 0;

		if (tween1 != null) {
			tween1.Kill ();
			tween1 = null;
		}

		if (tween2 != null) {
			tween2.Kill ();
			tween2 = null;
		}

		tween1 = DOTween.To (x => posY1 = x, 0, 4, 2).SetLoops (2, LoopType.Yoyo).SetEase (Ease.InOutQuad).OnUpdate(() => {
			TrySpawn(ref lastTime1, 1);
		});
		tween2 = DOTween.To (x => posY2 = x, 0, -3, 2).SetLoops (2, LoopType.Yoyo).SetEase (Ease.InOutQuad).OnUpdate(() => {
			TrySpawn(ref lastTime2, 2);
		});;
	}

	void OneWave(){
		float lastTime2 = 0f;

		if (tween1 != null) {
			tween1.Kill ();
			tween1 = null;
		}

		if (tween2 != null) {
			tween2.Kill ();
			tween2 = null;
		}

		tween1 = DOTween.To (x => posY1 = x, -3, 4, 2).SetLoops (-1, LoopType.Yoyo).SetEase (Ease.InOutQuad).OnUpdate( () => {
			TrySpawn(ref lastTime2, 1);
		});<commit_msg>spawm by time<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class EnemySpawnner : MonoBehaviour {

	public GameObject[] enemy;

	float posY1;
	float posY2;

	Tweener tween1;
	Tweener tween2;

	private float lastTime = 0f;

	void Update () {

		if(Time.time - lastTime > 5f){
			lastTime = Time.time;
			int r = Random.Range(1,5);
			if (r == 1) {
				OneWave ();
			} else if (r == 2) {
				TwoWave ();
			} else if (r == 3) {
				FullRandom ();
			} else if (r == 4) {
				WallOfEnemies (3);
			}
		}
	}

	void TrySpawn(ref float lastTime, int i){
		if (i == 1) {
			if (Time.time - lastTime > 2f) {
				var pos = this.transform.position;
				pos.y = posY1;
				Instantiate (enemy[Random.Range(0, enemy.Length)], pos + new Vector3(10,0,0), this.transform.rotation);
				lastTime = Time.time;
			}
		} else {
			if (Time.time - lastTime > 2f) {
				var pos = this.transform.position;
				pos.y = posY2;
				Instantiate (enemy[Random.Range(0, enemy.Length)], pos + new Vector3(10,0,0), this.transform.rotation);
				lastTime = Time.time;
			}
		}
	}

	void TwoWave(){
		float lastTime1 = 0, lastTime2 = 0;

		if (tween1 != null) {
			tween1.Kill ();
			tween1 = null;
		}

		if (tween2 != null) {
			tween2.Kill ();
			tween2 = null;
		}

		tween1 = DOTween.To (x => posY1 = x, 0f, 4f, 2f).SetLoops (2, LoopType.Yoyo).SetEase (Ease.InOutQuad).OnUpdate(() => {
			TrySpawn(ref lastTime1, 1);
		});
		tween2 = DOTween.To (x => posY2 = x, 0f, -3f, 2f).SetLoops (2, LoopType.Yoyo).SetEase (Ease.InOutQuad).OnUpdate(() => {
			TrySpawn(ref lastTime2, 2);
		});;
	}

	void OneWave(){
		float lastTime2 = 0f;

		if (tween1 != null) {
			tween1.Kill ();
			tween1 = null;
		}

		if (tween2 != null) {
			tween2.Kill ();
			tween2 = null;
		}

		tween1 = DOTween.To (x => posY1 = x, -3f, 4f, 2f).SetLoops (2, LoopType.Yoyo).SetEase (Ease.InOutQuad).OnUpdate( () => {
			TrySpawn(ref lastTime2, 1);
		});
{'fraction_non_alphanumeric': 0.16609167077378018, 'fraction_numerical': 0.03400689995071464, 'mean_word_length': 2.952288218111003, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4016168', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1661, 'n_words': 365}