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

public class FlowController : MonoBehaviour {

    GameObject _level;
    public int MinFlowDelta = 30;
    public int MaxFlowDelta = 40;
    public int MinFlowTime = 8;
    public int MaxFlowTime = 12;
    public int FlowHeightPerTick = 3;

    int _count = 0;
    int _flowcount = 0;
    int _flowdelta = 0;
    int _flowtime = 0;
    List<GameObject> _lavasource = new List<GameObject>();
    bool[][] _hadlava;

	void Start ()
    {
        _flowdelta = Random.Range(MinFlowDelta, MaxFlowDelta);
        _flowtime = Random.Range(MinFlowTime, MaxFlowTime);
        _hadlava = new bool[Level.LevelWidth][];
        for (int x = 0; x < Level.LevelWidth; x++)
        {
            _hadlava[x] = new bool[Level.LevelHeight];
        }
		StartCoroutine("Eruption");
	}

    public void SetLevel(GameObject level)
    {
        _level = level;
    }
	
	void FixedUpdate ()
    {
        _count++;
        if (_count == _flowdelta || Input.GetKeyDown(KeyCode.Space))
        {
            _count = 0;
            _flowdelta = Random.Range(MinFlowDelta, MaxFlowDelta);
            // tick all lava, and then flow in more from the stream source.
            for (int y = 0; y < Level.LevelHeight; y++)
            {
              for (int x = 0; x < Level.LevelWidth; x++)
                {
                    _hadlava[x][y] = _level.GetComponent<Level>()._tiles[x][y].GetComponent<Tile>().HasLava;
                }
            }
            for (int y = 0; y < Level.LevelHeight; y++)
            {
                for (int x = 0; x < Level.LevelWidth; x++)
                {
                    if (_hadlava[x][y]) _level.GetComponent<Level>()._tiles[x][y].GetComponent<Tile>().TrickleDown();
                }
            }
			foreach(GameObject tile in _lavasource)
			{
            	tile.GetComponent<Tile>().LavaHeight += FlowHeightPerTick;
			}
            _flowcount++;
            if (_flowcount == _flowtime)
            {
                _flowcount = 0;
                _flowtime = Random.Range(MinFlowTime, MaxFlowTime);
				_lavasource.Clear();
                NewStream();
            }
        }
	}

	IEnumerator Eruption()
	{
		while(true)
		{
			yield return new WaitForSeconds(60);
			_flowcount = 0;
			_flowtime = Random.Range(MinFlowTime, MaxFlowTime);
			for(int i = 0; i < 6; i++)
			{
				NewStream();
			}
		}
	}

    public void NewStream()
    {
        // todo: make this random distribution more uniform. most important RNG.
        // TODO TODO TODO
        GameObject tile = _level.GetComponent<Level>()._tiles[Random.Range(0, Level.LevelWidth - 1)][Level.LevelHeight - 1];
        tile.GetComponent<Tile>().GroundHeight = 2;
        tile.GetComponent<Tile>().LavaHeight = FlowHeightPerTick;
        _lavasource.Add(tile);
    }
}
<commit_msg>Added difficulty scaling<commit_after>﻿using UnityEngine;
using System.Collections.Generic;
using System.Collections;

public class FlowController : MonoBehaviour {

    GameObject _level;
    public int MinFlowDelta = 30;
    public int MaxFlowDelta = 40;
    public int MinFlowTime = 8;
    public int MaxFlowTime = 12;
    public int FlowHeightPerTick = 3;

    int _count = 0;
    int _flowcount = 0;
    int _flowdelta = 0;
    int _flowtime = 0;
    List<GameObject> _lavasource = new List<GameObject>();
    bool[][] _hadlava;
    private int _difficulty = 15;

	void Start ()
    {
        _flowdelta = Random.Range(MinFlowDelta, MaxFlowDelta);
        _flowtime = Random.Range(MinFlowTime, MaxFlowTime);
        _hadlava = new bool[Level.LevelWidth][];
        for (int x = 0; x < Level.LevelWidth; x++)
        {
            _hadlava[x] = new bool[Level.LevelHeight];
        }
		StartCoroutine("Eruption");
	}

    public void SetLevel(GameObject level)
    {
        _level = level;
    }
	
	void FixedUpdate ()
    {
        _count++;
        if (_count == _flowdelta || Input.GetKeyDown(KeyCode.Space))
        {
            _count = 0;
            _flowdelta = Random.Range(MinFlowDelta, MaxFlowDelta);
            // tick all lava, and then flow in more from the stream source.
            for (int y = 0; y < Level.LevelHeight; y++)
            {
              for (int x = 0; x < Level.LevelWidth; x++)
                {
                    _hadlava[x][y] = _level.GetComponent<Level>()._tiles[x][y].GetComponent<Tile>().HasLava;
                }
            }
            for (int y = 0; y < Level.LevelHeight; y++)
            {
                for (int x = 0; x < Level.LevelWidth; x++)
                {
                    if (_hadlava[x][y]) _level.GetComponent<Level>()._tiles[x][y].GetComponent<Tile>().TrickleDown();
                }
            }
			foreach(GameObject tile in _lavasource)
			{
            	tile.GetComponent<Tile>().LavaHeight += FlowHeightPerTick;
			}
            _flowcount++;
            if (_flowcount == _flowtime)
            {
                _flowcount = 0;
                _flowtime = Random.Range(MinFlowTime, MaxFlowTime);
				_lavasource.Clear();
                for (int i = 0; i <= (_difficulty - 10) / 10; i++)
                {
                    NewStream();
                }
            }
        }
	}

	IEnumerator Eruption()
	{
		while(true)
		{
			yield return new WaitForSeconds(75 - _difficulty);
			_flowcount = 0;
			_flowtime = Random.Range(MinFlowTime, MaxFlowTime);
			for(int i = 0; i < _difficulty / 3; i++)
			{
				NewStream();
			}
            _difficulty++;
		}
	}

    public void NewStream()
    {
        // todo: make this random distribution more uniform. most important RNG.
        // TODO TODO TODO
        GameObject tile = _level.GetComponent<Level>()._tiles[Random.Range(0, Level.LevelWidth - 1)][Level.LevelHeight - 1];
        tile.GetComponent<Tile>().GroundHeight = 2;
        tile.GetComponent<Tile>().LavaHeight = FlowHeightPerTick;
        _lavasource.Add(tile);
    }
}

{'fraction_non_alphanumeric': 0.1178252819390675, 'fraction_numerical': 0.010604275374516074, 'mean_word_length': 1.9242125984251968, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 23, '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': '1533609', 'n_tokens_mistral': 1968, 'n_tokens_neox': 1806, 'n_words': 414}