public void StartMission(int startingMissionNode, PlanetAlien alien) { this.alien = alien; if (alien != null) { ImageController imageController = FindObjectOfType <ImageController>(); StartCoroutine(imageController.GetSprite(FindObjectOfType <PlanetController>().GetPlanetInfo().background_image, (Sprite sprite) => { backgroundImage.sprite = sprite; })); StartCoroutine(imageController.GetSprite(alien.GetAlienInfo().picture_path, (Sprite sprite) => { alienAvatar.SetAvatar(sprite, alien.GetAlienInfo().name); })); } else { Debug.LogWarning("Starting mission while not connected to alien!"); } if (startingMissionNode == -1) { throw new UnityException("Attempting to start mission when there are no more missions with this alien!"); } StartCoroutine(StartMissionCoroutine(startingMissionNode)); }
public void LoadAliens() { if (planetInfo.aliens.Count == 0) { Debug.LogError("Planet has no aliens to load!"); return; } foreach (Alien alienInfo in planetInfo.aliens) { Vector2 relativePosition = GetFreeAlienRelativePosition(); if (relativePosition == new Vector2(-1, -1)) { Debug.LogWarning("No more space for aliens! Stopping at alien " + alienInfo.name); return; } Vector2 position = new Vector2( Mathf.Lerp(0, canvas.pixelRect.width, relativePosition.x), Mathf.Lerp(0, canvas.pixelRect.height, relativePosition.y) ); PlanetAlien alien = Instantiate(alienPrefab, position, Quaternion.identity); alien.SetAlienInfo(alienInfo); alien.transform.SetParent(canvas.transform); alienPositions[relativePosition] = alien; } }