void Summon() { // The wave continue if (EnemiesForCurrentWave.Count >= 1) { Transform BasicEnemy = EnemiesForCurrentWave [0].prefab.transform; int randomIndex = Random.Range(0, SpawnerPositionList.Count - 1); randomIndex = AdjustSpawn(randomIndex, BasicEnemy.gameObject); // Summon a BOSS if (EnemiesForCurrentWave [0].t == ConfigurationEnemy.Type.Boss) { GameManager.instance.isBoss = true; randomIndex = SpawnerPositionList.Count / 2 - ((SpawnerPositionList.Count % 2 == 0) ? 1 : 0); SoundManager.instance.PlayerMusic("MusicBossInGame"); } else { GameManager.instance.isBoss = false; } // Instanciate a basic enemy 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); BasicEnnemy enemy = Instantiate(BasicEnemy.gameObject, pos, Quaternion.identity).GetComponent <BasicEnnemy> (); SpawnLineInfo [randomIndex] = enemy.gameObject; if (!enemy) { Debug.LogError("[WaveManager]Can't instanciate the enemy !"); } // SETUP the new enemy enemy.UpdateWithConfig(EnemiesForCurrentWave [0]); combinationGenerator.FixedSize = enemy.CombinationSize; enemy.Combination = combinationGenerator.GetListButton(); enemy.Setup(); NbrEnemiesOnScreen++; GameManager.instance.EnemiesOnScreen.Add(enemy.gameObject); if (EnemiesForCurrentWave.Count >= 2) { TimeLeft = EnemiesForCurrentWave [0].SpawnCoolDown; } EnemiesForCurrentWave.RemoveAt(0); } }
public override int DecreaseLifePoint(int lp) { if (minions.Count > 0) { return(0); } combinationGenerator.FixedSize = CombinationSize; Combination = combinationGenerator.GetListButton(); ResetCombination(); return(base.DecreaseLifePoint(lp)); }
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); } }
public override int DecreaseLifePoint(int lp) { if (IsInvisible) { return(0); } combinationGenerator.FixedSize = CombinationSize; Combination = combinationGenerator.GetListButton(); ResetCombination(); int ret = base.DecreaseLifePoint(lp); if (Life == LifeMax / 3) { StartInvisible(1, 3); } else if (Life == LifeMax / 3 * 2) { StartInvisible(2, 1); } return(ret); }
void MakeEnemy() { // Instanciate a basic enemy if (!CheckBoss) { // Find a random kind of enemy string PathToEnemiesPrefab = "Prefabs/UnlimitedEnemies/"; string type = "Robot01"; switch (Random.Range(0, 3)) { case 0: type = "Robot01"; break; case 1: type = "Robot02"; break; case 2: type = "Robot03"; break; default: break; } // Get enemy prefab GameObject BasicEnemy = Resources.Load <GameObject>(PathToEnemiesPrefab + type); if (!BasicEnemy) { Debug.LogError("Impossible to instantiate " + type + " (Path: " + PathToEnemiesPrefab + type + ")"); } // Get enemy spawn position (random) int randomIndex = Random.Range(0, SpawnerPositionList.Count - 1); randomIndex = AdjustSpawn(randomIndex, BasicEnemy.gameObject); RectTransform TopPos = GameObject.Find("Canvas/TopBackground").GetComponent <RectTransform>(); Vector3 pos = SpawnerPositionList[randomIndex]; pos.y = TopPos.position.y; 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); // Instanciate the enemy BasicEnnemy enemy = Instantiate(BasicEnemy.gameObject, pos, Quaternion.identity).GetComponent <BasicEnnemy>(); SpawnLineInfo [randomIndex] = enemy.gameObject; // Set up enemy data (random) int nbGold = Random.Range(0, 2) * 5; int nbLife; int nbButton; if (DifficultyLevel == 1) { nbLife = Random.Range(1, 3); nbButton = Random.Range(2, 4); } else if (DifficultyLevel == 2) { nbLife = Random.Range(2, 4); nbButton = 3; } else if (DifficultyLevel == 3) { nbLife = Random.Range(2, 4); nbButton = Random.Range(3, 5); } else if (DifficultyLevel == 4) { nbLife = Random.Range(3, 5); nbButton = 4; } else { nbLife = Random.Range(3, 5); nbButton = Random.Range(4, 6); } enemy.Init(nbLife, nbGold, nbButton); if (!enemy) { Debug.LogError("[WaveManager]Can't instanciate the enemy !"); } combinationGenerator.FixedSize = enemy.CombinationSize; enemy.Combination = combinationGenerator.GetListButton(); enemy.Speed = 0.3f; enemy.Setup(); NbrEnemiesOnScreen++; GameManager.instance.EnemiesOnScreen.Add(enemy.gameObject); // Update BOSS "timer" CheckBossEnergy += 0; if (CheckBossEnergy >= 100) { CheckBoss = true; } } // Instanciate a boss else { if (NbrEnemiesOnScreen == 0) { MakeBoss(); CheckBossEnergy = 0; } } }