public bool MoveHero(Hero hero, int pos, Action <int> onFinishedMoving = null) { if (heroes[pos].hero != null) { return(false); } for (int i = 0; i < heroes.Length; i++) { if (heroes[i].hero == hero) { heroes[i].hero = null; heroes[pos] = new HeroPos(hero); StartCoroutine(MovingHero(pos, onFinishedMoving)); return(true); } } return(false); }
public void SpawnHero(Hero hero) { hero.transform.position = spawnPoint.position; hero.gameObject.SetActive(true); int pos = 0; while (pos < heroes.Length && (heroes[pos].hero != null || CheckPosition(pos))) { pos++; } if (pos == heroes.Length) { Debug.LogError("Could not spawn " + hero); return; } heroes[pos] = new HeroPos(hero); StartCoroutine(MovingHero(pos)); }