Exemple #1
0
    private void SpawnTowers()
    {
        // Destroy towers
        foreach (GameObject tower in towers)
        {
            Destroy(tower);
        }
        towers.Clear();
        idToTower.Clear();

        for (int i = 0; i < DimensionsManager.roadLength; i++)
        {
            float columnXPosition = DimensionsManager.ColumnXPosition(i);

            // Spawn top towers
            Vector3    topTowerPosition = new Vector3(columnXPosition, 0, DimensionsManager.TopZPosition());
            GameObject spawnedTopTower  = Instantiate(towerPrefab, topTowerPosition, Quaternion.Euler(0, 180, 0));
            idToTower.Add(i * 3, spawnedTopTower.GetComponent <Tower>()); // Quick hack
            towers.Add(spawnedTopTower);

            // Spawn bottom towers
            Vector3    bottomTowerPosition = new Vector3(columnXPosition, 0, DimensionsManager.BottomZPosition());
            GameObject spawnedBottomTower  = Instantiate(towerPrefab, bottomTowerPosition, Quaternion.identity);
            idToTower.Add(i * 3 + 2, spawnedTopTower.GetComponent <Tower>()); // Quick hack
            towers.Add(spawnedBottomTower);
        }
    }
Exemple #2
0
 public void UpdateDimensions()
 {
     grass.size = DimensionsManager.GrassDimensions();
     path.size  = DimensionsManager.PathDimensions();
     start.transform.localScale         = DimensionsManager.StartAndGoalDimensions();
     start.transform.position           = DimensionsManager.StartPosition();
     goal.transform.localScale          = DimensionsManager.StartAndGoalDimensions();
     goal.transform.position            = DimensionsManager.GoalPosition();
     finishGraphic.transform.position   = DimensionsManager.FinishGraphicsPosition();
     finishGraphic.transform.localScale = DimensionsManager.FinishGraphicScale();
     finishGraphic.size = DimensionsManager.finishGraphicSize();
     SpawnTowers();
     cameraLocationPicker.CreateNewLocationsAndButtons(DimensionsManager.GetAllPositions());
 }
Exemple #3
0
 public override void restartGame(RestartMessage restartMessage)
 {
     // Set correct values for the dimension manager from the restart message.
     DimensionsManager.UpdateFromRestartMessage(restartMessage);
     UpdateDimensions();
 }