Example #1
0
    IEnumerator BuildMapRoutine()
    {
        for (int x = 0; x < GlobalConstants.MapSize; x++)
        {
            for (int y = 0; y < GlobalConstants.MapSize; y++)
            {
                Instantiate(TerrainTile, new Vector3(x, y, 0.0f), Quaternion.identity, ObjectsHolder.transform);
            }
        }

        for (float x = 3.0f; x < GlobalConstants.MapSize - 3.0f; x += 3.0f)
        {
            for (float y = 3.0f; y < GlobalConstants.MapSize - 3.0f; y += 3.0f)
            {
                _obstaclesGrid.Add(new Vector2(x, y));
            }
        }

        PlaceBorder();
        PlaceObstacles();
        SetupSpawnZones();

        Player.SetPlayerPosition(new Vector3(GlobalConstants.MapSize / 2.0f, GlobalConstants.MapSize / 2.0f, 0.0f));

        Score           = 0;
        ScoreCount.text = Score.ToString();

        _isLoading = false;

        yield return(StartCoroutine(WaitForSecondsRoutine(2.0f)));

        LoadingScreen.SetActive(false);

        yield return(null);
    }