/// <summary> /// Unity Start Method /// </summary> private void Start() { Application.targetFrameRate = 300; _stopwatch = new Stopwatch(); /** * Subscribe to events */ _optionsManager.StartedAlgorithm += (a, b) => { _containerManager.CreateMessage("Preparing Quadcopter", PREPARING_ALGORITHM_MSG_ID, true); }; PathfindingManager.Instance.StartedPathfinding += () => { _containerManager.DestroyMessage(PREPARING_ALGORITHM_MSG_ID); _containerManager.CreateMessage("Finding Path", SEARCHING_PATH_MSG_ID, true); _stopwatch.Start(); }; PathfindingManager.Instance.FinishedPathfinding += (a, foundPath) => { _stopwatch.Stop(); _foundPath = foundPath; }; QuadtreeManager.Instance.CreatedNode += a => { _quadcopterFlights++; }; }
/// <summary> /// Sets up the map-container, the map and the overlay object /// </summary> /// <param name="texture">The map texture</param> public void SetMap(Texture2D texture) { var dimensions = new Vector2(texture.width, texture.height); CalculateZoomLevels(dimensions); _mapContainer.sizeDelta = dimensions; _mapContainer.localScale = new Vector3(_defaultZoomLevel, _defaultZoomLevel, _defaultZoomLevel); _mapRawImage.texture = texture; // Create overlay texture _overlayTexture = new Texture2D(texture.width, texture.height, TextureFormat.ARGB32, false) { filterMode = FilterMode.Point }; _overlayRawImage.texture = _overlayTexture; _containerManager.CreateMessage("Coloring overlay texture...", COLORING_OVERLAY_MSG_ID, true); _overlayTexture.ClearTexture(() => _containerManager.DestroyMessage(COLORING_OVERLAY_MSG_ID)); }