private void UpdateDebugVisuals(bool remove, int sig, GameObject debugPrefab) { if (!remove && _manager.ShowDebug && _manager.OccupiedTilePrefab != null) { // Attempt to reuse a grid if (_debugTileCounter >= debugVisuals.Count) { GameObject newVisual = Instantiate(debugPrefab) as GameObject; Hex hex = newVisual.GetComponent <Hex>(); if (hex != null) { float factor = (_trackedGameObject == null) ? 0.8f : 0.9f; hex.GridSize = _manager.GridSize * factor; } newVisual.transform.parent = _manager.transform; debugVisuals.Add(newVisual); } int x, y; Vector3 pos = Vector3.zero; _manager.SigToGrid(sig, out x, out y); _manager.GridToPosition(x, y, ref pos); debugVisuals[_debugTileCounter].transform.position = pos + (Vector3.up * _manager.OccupiedDebugYPosition); // Re-use pos pos.Set(x, 0, y); debugVisuals[_debugTileCounter].gameObject.SetActive(_manager.IsValid(pos)); _debugTileCounter++; } }
void GetNewDestination() { tempGrid.Set(Random.Range(-70, 70), 0, Random.Range(-70, 70)); if (_gridManager.IsValid(tempGrid) && !_gridManager.IsOccupied(tempGrid)) { Vector3 destination = Vector3.zero; _gridManager.GridToPosition(tempGrid, ref destination); _navAgent.destination = destination; } }