public void SpawnHero() { var heroOnGrid = _levelGrid.GetHeroOnGridPositionList(); var enemyOnGrid = _levelGrid.GetEnemyOnGridPositionList(); do { _newHeroGridPosition = new Vector2Int(Random.Range(0, _levelWidth), Random.Range(0, _levelHeight)); } while (_caravanController.GetCaravanGridPositionList().IndexOf(_newHeroGridPosition) != -1 && heroOnGrid.IndexOf(_newHeroGridPosition) != -1 && enemyOnGrid.IndexOf(_newHeroGridPosition) != -1); _heroGameObject = new GameObject("Hero" + GetInstanceID(), typeof(SpriteRenderer)); _heroGameObject.transform.position = new Vector3(_newHeroGridPosition.x, _newHeroGridPosition.y); var heroEntity = _heroGameObject.AddComponent <HeroEntity>(); heroEntity.Setup(GetRandomHeroSprite()); _levelGrid.AppendNewHeroPosition(_newHeroGridPosition); _heroOccupiedGridPosition.Add(_newHeroGridPosition); _gridPositionHeroEntityPair.Add(_newHeroGridPosition, heroEntity); }