void HandleResize() { if (_resize.triggered && !_resizing) { _resizing = true; var vec = _resize.ReadValue <Vector2>(); var newSize = _size; newSize.x += (int)vec.x; newSize.y += (int)vec.y; newSize = math.max(1, newSize); if (!_size.Equals(newSize)) { FindObjectOfType <TiledCamera>().TileCount = newSize; _size = newSize; _map.Dispose(); _map = new BasicPathingMap(_size.x, _size.y, Allocator.Persistent); _term.Resize(_size.x, _size.y); _dirty = true; OnResized(_size); } } else { _resizing = false; } }
protected virtual void OnEnable() { _term = GetComponent <TerminalBehaviour>(); _drag = GetComponent <DraggingControls>(); _drag.OnPointDragged += OnPointDragged; _drag.OnDragEnded += OnDragEnded; _drag.OnDragStarted += OnDragStarted; _controls = new Controls(); _controls.Enable(); _addNoise = _controls.Default.AddNoise; _resize = _controls.Default.ResizeMap; _clear = _controls.Default.Clear; _map = new BasicPathingMap(_size.x, _size.y, Allocator.Persistent); }
public void AddNoiseToMap(BasicPathingMap map) { Random rand = new Random((uint)UnityEngine.Random.Range(1, int.MaxValue)); int iters = rand.NextInt(1, 16); float per = rand.NextFloat(0.15f, 0.75f); float scale = rand.NextFloat(0.01f, .2f); int low = rand.NextInt(0, 10); int high = rand.NextInt(low + 5, low + 15); int thresh = rand.NextInt(low, high); new NoiseJob { Iterations = iters, Persistence = per, Scale = scale, Low = low, High = high, Threshold = thresh, Map = map }.Run(); }
public VisibilityMap(int w, int h, BasicPathingMap obstacleMap, Allocator allocator) { size = new int2(w, h); visible = new NativeArray <bool>(w * h, allocator); opaque = obstacleMap; }