<commit_before>﻿using UnityEngine;
using System.Collections;

public class EnemySpawner : MonoBehaviour
{
    //public for a editor script
    public Vector3 spawnMin;   
    public Vector3 spawnMax;

    [SerializeField]
    GameObject Enemy;

#if UNITY_EDITOR
    [SerializeField]
    Color lineColor;
#endif

    void Start()
    {

    }

    float t;
    void Update()
    {
        if (t > 0.05f)
        {
            TestSpawn();
            t = 0;
        }

        t += Time.deltaTime;
    }

    void TestSpawn()
    {
        GameObject g = GameObject.CreatePrimitive(PrimitiveType.Cube);
        //Destroy(g.GetComponent<BoxCollider>());
        g.name = "Test";
        PhysicMaterial pm = new PhysicMaterial("BOUNCE");
        pm.bounciness = 0.8f;
        g.GetComponent<BoxCollider>().material = pm;
        g.transform.SetParent(transform, false);
        g.transform.localPosition = RandomPos();

        Rigidbody r = g.AddComponent<Rigidbody>();

        r.velocity = new Vector3(0, 0, -2);
        r.useGravity = false;

        g.AddComponent<EnemyBase>();


        Destroy(g, 20f);

    }

    Vector3 RandomPos()
    {

        return new Vector3(Random.Range(spawnMin.x, spawnMax.x), Random.Range(spawnMin.y, spawnMax.y), Random.Range(spawnMin.z, spawnMax.z));
    }

    [ContextMenu("Center")]
    void Center()
    {
        Vector3 startPos = transform.position;
        transform.position = Vector3.Lerp(spawnMax + transform.position, spawnMin + transform.position, 0.5f);
        Vector3 diff =transform.position - startPos;
        spawnMin -= diff;
        spawnMax -= diff;
    }

#if UNITY_EDITOR
    Vector3 tmpMax;
    Vector3 tmpMin;
    public void OnDrawGizmosSelected()
    {
        tmpMax = transform.position + spawnMax;
        tmpMin = transform.position + spawnMin;
        Gizmos.color = Color.green;
        Gizmos.DrawCube(tmpMin, Vector3.one * 0.5f);
        Gizmos.color = Color.red;
        Gizmos.DrawCube(tmpMax, Vector3.one * 0.5f);
        
    }

    public void OnDrawGizmos()
    {
        Gizmos.color = lineColor;
        Gizmos.DrawLine(tmpMin, new Vector3(tmpMin.x, tmpMin.y, tmpMax.z));
        Gizmos.DrawLine(tmpMin, new Vector3(tmpMin.x, tmpMax.y, tmpMin.z));
        Gizmos.DrawLine(tmpMin, new Vector3(tmpMax.x, tmpMin.y, tmpMin.z));

        Gizmos.DrawLine(tmpMax, new Vector3(tmpMax.x, tmpMax.y, tmpMin.z));
        Gizmos.DrawLine(tmpMax, new Vector3(tmpMax.x, tmpMin.y, tmpMax.z));
        Gizmos.DrawLine(tmpMax, new Vector3(tmpMin.x, tmpMax.y, tmpMax.z));

        Gizmos.DrawLine(new Vector3(tmpMax.x, tmpMin.y, tmpMax.z), new Vector3(tmpMax.x, tmpMin.y, tmpMin.z));
        Gizmos.DrawLine(new Vector3(tmpMax.x, tmpMin.y, tmpMax.z), new Vector3(tmpMin.x, tmpMin.y, tmpMax.z));

        Gizmos.DrawLine(new Vector3(tmpMin.x, tmpMax.y, tmpMin.z), new Vector3(tmpMin.x, tmpMax.y, tmpMax.z));
        Gizmos.DrawLine(new Vector3(tmpMin.x, tmpMax.y, tmpMin.z), new Vector3(tmpMax.x, tmpMax.y, tmpMin.z));

        Gizmos.DrawLine(new Vector3(tmpMin.x, tmpMin.y, tmpMax.z), new Vector3(tmpMin.x, tmpMax.y, tmpMax.z));
        Gizmos.DrawLine(new Vector3(tmpMax.x, tmpMax.y, tmpMin.z), new Vector3(tmpMax.x, tmpMin.y, tmpMin.z));
    }


#endif

}
<commit_msg>added field for delay time<commit_after>﻿using UnityEngine;
using System.Collections;

public class EnemySpawner : MonoBehaviour
{
    //public for a editor script
    public Vector3 spawnMin;   
    public Vector3 spawnMax;

    [SerializeField]
    GameObject Enemy;

    [SerializeField, Tooltip("time in seconds")]
    float SpawnDelay = 0.05f;

#if UNITY_EDITOR
    [SerializeField]
    Color lineColor;
#endif

    void Start()
    {

    }

    float t;
    void Update()
    {
        if (t > SpawnDelay)
        {
            TestSpawn();
            t = 0;
        }

        t += Time.deltaTime;
    }

    void TestSpawn()
    {
        GameObject g = GameObject.CreatePrimitive(PrimitiveType.Cube);
        //Destroy(g.GetComponent<BoxCollider>());
        g.name = "Test";
        PhysicMaterial pm = new PhysicMaterial("BOUNCE");
        pm.bounciness = 0.8f;
        g.GetComponent<BoxCollider>().material = pm;
        g.transform.SetParent(transform, false);
        g.transform.localPosition = RandomPos();

        Rigidbody r = g.AddComponent<Rigidbody>();

        r.velocity = new Vector3(0, 0, -2);
        r.useGravity = false;

        g.AddComponent<EnemyBase>();


        Destroy(g, 20f);

    }

    Vector3 RandomPos()
    {

        return new Vector3(Random.Range(spawnMin.x, spawnMax.x), Random.Range(spawnMin.y, spawnMax.y), Random.Range(spawnMin.z, spawnMax.z));
    }

    [ContextMenu("Center")]
    void Center()
    {
        Vector3 startPos = transform.position;
        transform.position = Vector3.Lerp(spawnMax + transform.position, spawnMin + transform.position, 0.5f);
        Vector3 diff =transform.position - startPos;
        spawnMin -= diff;
        spawnMax -= diff;
    }

#if UNITY_EDITOR
    Vector3 tmpMax;
    Vector3 tmpMin;
    public void OnDrawGizmosSelected()
    {
        tmpMax = transform.position + spawnMax;
        tmpMin = transform.position + spawnMin;
        Gizmos.color = Color.green;
        Gizmos.DrawCube(tmpMin, Vector3.one * 0.5f);
        Gizmos.color = Color.red;
        Gizmos.DrawCube(tmpMax, Vector3.one * 0.5f);
        
    }

    public void OnDrawGizmos()
    {
        Gizmos.color = lineColor;
        Gizmos.DrawLine(tmpMin, new Vector3(tmpMin.x, tmpMin.y, tmpMax.z));
        Gizmos.DrawLine(tmpMin, new Vector3(tmpMin.x, tmpMax.y, tmpMin.z));
        Gizmos.DrawLine(tmpMin, new Vector3(tmpMax.x, tmpMin.y, tmpMin.z));

        Gizmos.DrawLine(tmpMax, new Vector3(tmpMax.x, tmpMax.y, tmpMin.z));
        Gizmos.DrawLine(tmpMax, new Vector3(tmpMax.x, tmpMin.y, tmpMax.z));
        Gizmos.DrawLine(tmpMax, new Vector3(tmpMin.x, tmpMax.y, tmpMax.z));

        Gizmos.DrawLine(new Vector3(tmpMax.x, tmpMin.y, tmpMax.z), new Vector3(tmpMax.x, tmpMin.y, tmpMin.z));
        Gizmos.DrawLine(new Vector3(tmpMax.x, tmpMin.y, tmpMax.z), new Vector3(tmpMin.x, tmpMin.y, tmpMax.z));

        Gizmos.DrawLine(new Vector3(tmpMin.x, tmpMax.y, tmpMin.z), new Vector3(tmpMin.x, tmpMax.y, tmpMax.z));
        Gizmos.DrawLine(new Vector3(tmpMin.x, tmpMax.y, tmpMin.z), new Vector3(tmpMax.x, tmpMax.y, tmpMin.z));

        Gizmos.DrawLine(new Vector3(tmpMin.x, tmpMin.y, tmpMax.z), new Vector3(tmpMin.x, tmpMax.y, tmpMax.z));
        Gizmos.DrawLine(new Vector3(tmpMax.x, tmpMax.y, tmpMin.z), new Vector3(tmpMax.x, tmpMin.y, tmpMin.z));
    }


#endif

}

{'fraction_non_alphanumeric': 0.13078562728380025, 'fraction_numerical': 0.014311814859926919, 'mean_word_length': 2.570108695652174, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '5655119', 'n_tokens_mistral': 2388, 'n_tokens_neox': 2337, 'n_words': 439}