void Summon() { // New wave if (EnemiesForCurrentWave.Count <= 0 && NbrEnemiesOnScreen == 0) { if (WaveLeft.Count > 0) { TimeLeft = 5; EnemiesForCurrentWave = WaveLeft [0]; WaveLeft.RemoveAt(0); StartCoroutine("SummonLater", TimeLeft); return; } } // The wave continue if (EnemiesForCurrentWave.Count >= 1) { Transform BasicEnemy = EnemiesForCurrentWave [0].transform; int randomIndex = Random.Range(0, SpawnerPositionList.Count - 1); //Debug.Log ("count : " + SpawnerPositionList.Count); Vector3 pos = SpawnerPositionList[randomIndex]; float ysize = BasicEnemy.GetComponent <BoxCollider> ().size.y; float ycenter = BasicEnemy.GetComponent <BoxCollider> ().center.y; float yscale = BasicEnemy.GetComponent <Transform>().localScale.y; pos.y -= (ysize * (yscale / 2)) + (ycenter * yscale); Debug.Log("test : " + BasicEnemy.GetComponent <BoxCollider> ().center.y); //pos.y -= BasicEnemy.GetComponent<BoxCollider>().size.y * BasicEnemy.GetComponent<Transform>().localScale.y / 2; Tutorial_Ennemy enemy = Instantiate(BasicEnemy.gameObject, pos, Quaternion.identity).GetComponent <Tutorial_Ennemy>(); CombinationGenerator c = new CombinationGenerator(); c.FixedSize = enemy.Combination.Count; enemy.Combination = c.GetListButton(); enemy.Setup(); NbrEnemiesOnScreen++; Tutorial_GameManager.instance.EnemiesOnScreen.Add(enemy.gameObject); if (EnemiesForCurrentWave.Count >= 2) { TimeLeft = EnemiesForCurrentWave [1].SpawnCooldown; } EnemiesForCurrentWave.RemoveAt(0); } }
void Update() { //if(killEnemy_count == 3) //{ // Pause_count = 2; //} if (launch) { WaveManager.launch(); launch = false; } /*if (Combination.GetCurrentCombination().Count > 0) * { * bool combinationExist = false; * foreach (GameObject enemy in EnemiesOnScreen) * { * BasicEnnemy e = enemy.GetComponent<BasicEnnemy>(); * if (Combination.CompareCombination(e.Combination)) * { * combinationExist = true; * if (Combination.isSameCombination(e.Combination)) * { * e.Die(); * Combination.Reset(); * break; * } * } * } * if (!combinationExist) * { * Combination.Reset(); * } * }*////KEEP IT FOR THE BOSS if (Combination.GetCurrentCombination().Count > 0 && EnemiesOnScreen.Count > 0) { Tutorial_Ennemy enemy; if (lockEnemy) { enemy = lockEnemy; } else { GameObject firstEnemy = EnemiesOnScreen[0]; foreach (GameObject e in EnemiesOnScreen) { if (e.GetComponent <Transform>().position.y < firstEnemy.GetComponent <Transform>().position.y) { firstEnemy = e; } } enemy = firstEnemy.GetComponent <Tutorial_Ennemy>(); } if (Combination.CompareCombination(enemy.Combination)) { lockEnemy = enemy; if (Combination.isSameCombination(enemy.Combination)) { enemy.Die(); } } else { Combination.Reset(); } } }