// Use this for initialization void Start() { #region Button init //find buttons StartButton = GameObject.Find("ButtonStart").GetComponent <Button>(); if (StartButton == null) { Debug.LogError("ButtonStart not found."); } CreditsButton = GameObject.Find("ButtonCredits").GetComponent <Button>(); if (CreditsButton == null) { Debug.LogError("ButtonCredits not found."); } QuitButton = GameObject.Find("ButtonQuit").GetComponent <Button>(); if (QuitButton == null) { Debug.LogError("ButtonQuit not found."); } //add listeners to the buttons StartButton.onClick.AddListener(StartButtonService); CreditsButton.onClick.AddListener(CreditsButtonService); QuitButton.onClick.AddListener(QuitButtonService); #endregion #region Hide credits menuElements = GameObject.FindGameObjectsWithTag("UI"); for (int i = 0; i < menuElements.Length; i++) { if (menuElements[i].name == "Credits") { menuElements[i].SetActive(false); } } #endregion #region Tile the background tiler = GetComponent <Tiling>(); if (tiler == null) { Debug.LogError("Tiler not found."); } else //tile the world { tiler.TileWorld("Prefabs/Tileset/Tile_Roof_", 10.0f, 10.0f, false, false, false, false, 3, 3); } #endregion }
// Use this for initialization void Start() { //globalGameManager = GameObject.Find("GlobalManager").GetComponent<GlobalGameManager>(); #region World bound support mainCamera = Camera.main; worldBounds = new Bounds(Vector3.zero, Vector3.one); UpdateWorldWindowBound(); #endregion #region Enemy spawning if (EnemyToSpawn == null) { EnemyToSpawn = Resources.Load("Prefabs/Enemy") as GameObject; } if (EnemyToSpawn == null) { Debug.LogError("Enemy not found."); } // first 50 enemies for (int i = 0; i < initialSpawn; i++) { SpawnAnEnemy(true); } #endregion #region Other references scoreText = GameObject.Find("Score").GetComponent <Text>(); if (scoreText == null) { Debug.LogError("Score not found."); } statusText = GameObject.Find("Status").GetComponent <Text>(); if (statusText == null) { Debug.LogError("Status not found."); } tiler = GameObject.Find("Tiler").GetComponent <Tiling>(); if (tiler == null) { Debug.LogError("Tiler not found."); } else //tile the world { tiler.TileWorld("Prefabs/Tileset/Tile_Wood_", 11.8f, 11.8f, false, false); } #endregion }
//Use this for initialization void Start() { #region References scoreText = GameObject.Find("ScoreDisplayText").GetComponent <Text>(); if (scoreText == null) { Debug.LogError("ScoreDisplayText not found."); } if (newStarSprite == null) { Debug.LogError("newStarSprite not assigned."); } stars = GameObject.FindGameObjectsWithTag("UI"); if (stars.Length != 3) { Debug.LogError("Only " + stars.Length + " stars found."); } #endregion #region Tile the background tiler = GetComponent <Tiling>(); if (tiler == null) { Debug.LogError("Tiler not found."); } else //tile the world { tiler.TileWorld("Prefabs/Tileset/Tile_Roof_", 10.0f, 10.0f, false, false, false, true, 3, 3); } #endregion //set timer SceneStartTime = Time.realtimeSinceStartup; //read status variables lastScore = MenuBehavior.TheGameState.GetLastScore(); totalScore = MenuBehavior.TheGameState.GetTotalScore(); lastTime = MenuBehavior.TheGameState.GetLastTime(); int level = MenuBehavior.TheGameState.GetLastLevel(); //echo level complete scoreText.text = "Level " + level + " complete!"; }
// Use this for initialization void Start() { #region Other references sceneBoundary = GameObject.Find("GameManager").GetComponent <WorldBound>(); if (sceneBoundary == null) { Debug.LogError("WorldBound not found for levelManager in " + this + "."); Application.Quit(); } scoreText = GameObject.Find("Score").GetComponent <Text>(); if (scoreText == null) { Debug.LogError("Score not found."); } statusText = GameObject.Find("Status").GetComponent <Text>(); if (statusText == null) { Debug.LogError("Status not found."); } tiler = GetComponent <Tiling>(); if (tiler == null) { Debug.LogError("Tiler not found."); } #endregion #region Get data from GlobalGameManager totalScore = MenuBehavior.TheGameState.GetTotalScore(); level = MenuBehavior.TheGameState.GetLastLevel() + 1; initialSpawn = MenuBehavior.TheGameState.GetLastEnemyCount() + level * initialSpawn; //non-level 1 changes if (level != 1) { Spawning = true; tiler.TileWorld("Prefabs/Tileset/Tile_Wood_", 10.0f, 10.0f, false, false, true, true, 2, 0); } else { tiler.TileWorld("Prefabs/Tileset/Tile_Wood_", 10.0f, 10.0f, false, false, true, true, 1, 0); } //increase spawn interval by 1s per level EnemySpawnInterval += level; #endregion #region Enemy spawning if (EnemyToSpawn == null) { EnemyToSpawn = Resources.Load("Prefabs/Enemy") as GameObject; } if (EnemyToSpawn == null) { Debug.LogError("Enemy not found."); } // first x enemies for (int i = 0; i < initialSpawn; i++) { SpawnAnEnemy(true); } #endregion }
// Use this for initialization void Start() { #region Other references sceneBoundary = GameObject.Find("GameManager").GetComponent <WorldBound>(); if (sceneBoundary == null) { Debug.LogError("WorldBound not found for levelManager in " + this + "."); Application.Quit(); } scoreText = GameObject.Find("Score").GetComponent <Text>(); if (scoreText == null) { Debug.LogError("Score not found."); } statusText = GameObject.Find("Status").GetComponent <Text>(); if (statusText == null) { Debug.LogError("Status not found."); } tiler = GetComponent <Tiling>(); if (tiler == null) { Debug.LogError("Tiler not found."); } #endregion #region Get data from GlobalGameManager totalScore = MenuBehavior.TheGameState.GetTotalScore(); level = MenuBehavior.TheGameState.GetLastLevel() + 1; initialSpawn = MenuBehavior.TheGameState.GetLastEnemyCount() + level * initialSpawn; //non-level 1 changes if (level != 1) { Spawning = true; tiler.TileWorld("Prefabs/Tileset/Tile_Wood_", 10.0f, 10.0f, false, false, true, true, 2, 0); } else { tiler.TileWorld("Prefabs/Tileset/Tile_Wood_", 10.0f, 10.0f, false, false, true, true, 1, 0); //create a tutorial powerup GameObject itemDrop = Resources.Load("Prefabs/PowerUp") as GameObject; if (itemDrop == null) { Debug.LogError("PowerUp not found for " + this + "."); } else { GameObject e = Instantiate(itemDrop) as GameObject; e.transform.position = new Vector3(sceneBoundary.WorldCenter.x + 10, sceneBoundary.WorldCenter.y + 10, 0); TextMesh text = e.AddComponent <TextMesh>(); text.text = "This gives a burst of fireball charges!"; text.fontSize = 30; text.alignment = TextAlignment.Center; } } //increase spawn interval by 1s per level EnemySpawnInterval += level; #endregion #region Enemy spawning if (EnemyToSpawn == null) { EnemyToSpawn = Resources.Load("Prefabs/Enemy") as GameObject; } if (EnemyToSpawn == null) { Debug.LogError("Enemy not found."); } // first x enemies for (int i = 0; i < initialSpawn; i++) { SpawnAnEnemy(true); } #endregion }