public void pauseGame() { if (GameManager.getLevelName() == "EQUALS") { EnemyFormation enemiesOnScreen = FindObjectOfType <EnemyFormation>(); if (enemiesOnScreen != null) { EnemySpawner.decreaseSpawnedCount(); } } if (!isGamePaused()) { isPaused = true; MusicPlayer.setVolume(0); if (life > 0) { pauseMenuPanel.active = true; } pauseButton.active = false; playerSpawner.active = false; enemySpawner.active = false; if (goalDetector != null) { for (int i = 0; i < goalDetector.Length; i++) { goalDetector[i].active = false; } } if (getLevelName() == "ARCADE" || getLevelName() == "TIME_LAPSE") { bombSpawner.active = false; } } else if (isGamePaused()) { isPaused = false; if (!VolumeManager.getIsMuted()) { MusicPlayer.setVolume(0.5f); } if (life > 0) { pauseMenuPanel.active = false; } pauseButton.active = true; playerSpawner.active = true; enemySpawner.active = true; if (goalDetector != null) { for (int i = 0; i < goalDetector.Length; i++) { goalDetector[i].active = true; } } if (getLevelName() == "ARCADE") { bombSpawner.active = true; } } }
public void FuseFormations(EnemyFormation formationToStrengthen, EnemyFormation formationToDissolve) { //Debug.Log("Fusing formations " + formationToStrengthen + " and " + formationToDissolve); formationToStrengthen.formationMembers.AddRange(formationToDissolve.formationMembers); enemyFormations.Remove(formationToDissolve); carolHelp.TriggerGeneralAdvice("SwarmsReforming"); }
void Awake() { //init singleton if (active == null) { active = this; } else { Destroy(this.gameObject); } }
// Update is called once per frame void Update() { //keep firing rate approx. constant no matter how many ships if (Random.value * EnemyFormation.GetNumShips() < firingRate * Time.deltaTime) { Fire(); } }
// Update is called once per frame void Update() { AnimationController(); PlayerInputs(); if (enemyFormation == null) { enemyFormation = GameObject.FindObjectOfType <EnemyFormation> (); } }
void CreateEnemies() { enemyGroup = Instantiate(enemyGroup); enemyGroup.transform.parent = transform; enemyFormation = enemyGroup.GetComponent <EnemyFormation>(); yBoundary = Camera.main.orthographicSize; enemyFormationTransform = enemyGroup.transform; xBoundary = (Screen.width / Screen.height) * yBoundary; beginAttack = true; }
public void CheckFusionableFormations(EnemyFormation ownFormation) { // for (int i = 0; i < enemyFormations.Count; i++) { if (enemyFormations[i] != ownFormation && ownFormation.FormationStrength + enemyFormations[i].FormationStrength <= 1) { FuseFormations(ownFormation, enemyFormations[i]); } } }
private bool hitByPlayer = false; // Whether this ship has been hit by a player // Use this for initialization protected void Start() { // Set up refereces gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); rb = GetComponent <Rigidbody2D>(); enemyFormation = GetComponentInParent <EnemyFormation>(); audioSource = GameObject.FindGameObjectWithTag("MainAudioSource").GetComponent <AudioSource>(); // Set speed at start rb.velocity = new Vector2(0, -speed); Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Enemy"), LayerMask.NameToLayer("Enemy")); }
public void LoadLevel3() { if (level3returning == false) { Application.LoadLevel("Level3"); level3returning = true; } else { EnemyFormation.UpDiff3(); Application.LoadLevel("Level3"); } }
private bool hitByPlayer = false; // Whether this ship has been hit by a player // Use this for initialization protected void Start() { // Set up refereces gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); rb = GetComponent <Rigidbody>(); enemyFormation = GetComponentInParent <EnemyFormation>(); audioSource = GameObject.FindGameObjectWithTag("MainAudioSource").GetComponent <AudioSource>(); smokeEffect = transform.FindChild("trail").gameObject; // Set speed at start rb.velocity = new Vector3(0, 0, -speed); deathRotation = Random.Range(deathRotationMin, deathRotationMax); Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Enemy"), LayerMask.NameToLayer("Enemy")); }
public void KillBub() { Destroy(healthBar); Destroy(gameObject); fireRate = startFireRate; killCount = 0; Projectile.damage = startDamage; MoneyManager.Reset(); ShopItems.Reset(); LevelManager.ResetLevels(); SelectionManager.ResetLevelProg(); EnemyFormation.ResetDifficulties(); UIManager.ResetChat(); health = startMaxHealth; isDead = true; }
public AI2FlyInFormation(EnemyFormation formation) { this.formation = formation; }
void Awake() { enemyFormation = FindObjectOfType<EnemyFormation>(); }
// Use this for initialization void Start() { gameController = FindObjectOfType<GameController>(); enemyFormation = FindObjectOfType<EnemyFormation>(); currentShield = startingShield; currentHealth = startingHealth; }
// Use this for initialization void Awake() { gameController = FindObjectOfType<GameController>(); enemyFormation = FindObjectOfType<EnemyFormation>(); }
public void KeepFighting() { BubbaHider.isActive = true; EnemyFormation.UpDifficulty(); waves = startWaves + 1; }
/// <summary> /// Activa los enemigos y los coloca donde corresponde /// Puede ser llamado por el boss /// </summary> /// <param name="i"></param> public void ActivateEnemies(int i, Vector3 spawnPoint = new Vector3()) { //Metodo con spawn points EnemyIdentifier enemyIdentifier = enemiesSpawnSettings[i].enemyPrefab.GetComponent <EnemyIdentifier>(); Transform groupSpawn; Vector3 pointForGroupSpawn; // if (spawnPoint != Vector3.zero) { pointForGroupSpawn = spawnPoint; } else if (enemyIdentifier) { EnemyType typeToSpawn = enemyIdentifier.enemyType; groupSpawn = GetRandomSpawmPointNearerThanX(typeToSpawn, farestSpawnDistanceToEpicenter); // Control de errores if (groupSpawn == null) { return; } pointForGroupSpawn = groupSpawn.position; } else { // TODO: Desarrorlo pointForGroupSpawn = epicenterPoint; } // NOTA: Control de error // De primeras no debería haber tamaño de spawn 0 int enemiesToSpawn = (int)GameManager.instance.ApplyDifficultyFactor(enemiesSpawnSettings[i].enemiesToSpawn, 1); Debug.Log("Spawning enemies: " + enemiesSpawnSettings[i].enemiesToSpawn + ", " + enemiesToSpawn); // Aparte, ahora sale todo el grupo o no sale if (/*enemiesSpawnSettings[i].*/ enemiesToSpawn > 0 && /*enemiesSpawnSettings[i].enemiesToSpawn*/ enemiesToSpawn <= enemiesSpawnSettings[i].maxActiveEnemies - activeEnemies[i].Count) { // Si no hay enemigos activos de ese tipo, aviso de Carol if (activeEnemies[i].Count == 0) { carolHelp.TriggerGeneralAdvice("EnemiesIncoming"); } // Primero iniciamos la formación EnemyFormation newEnemyFormation = null; if (enemiesSpawnSettings[i].formationData != null) { // //newEnemyFormation = new EnemyFormation(enemiesSpawnSettings[i].enemiesToSpawn, // enemiesSpawnSettings[i].formationData.formationInfo.formationType, // enemiesSpawnSettings[i].formationData.formationInfo.distanceBetweenMembers); newEnemyFormation = new EnemyFormation(enemiesSpawnSettings[i].formationData.formationInfo, /*enemiesSpawnSettings[i].*/ enemiesToSpawn); // enemyFormations.Add(newEnemyFormation); } // float memberSpawnAngle = 360 / /*enemiesSpawnSettings[i].*/ enemiesToSpawn; float meberSpawnRadius = 10; // Sacamos a los enemigos for (int j = 0; j < /*enemiesSpawnSettings[i].*/ enemiesToSpawn; j++) { // float memberSpawnCoordinates = memberSpawnAngle * j; Vector2 memberSpawnPositionXY = new Vector2(Mathf.Cos(memberSpawnCoordinates) * meberSpawnRadius, Mathf.Sin(memberSpawnCoordinates) * meberSpawnRadius); //Vector3 positionToSpawn = new Vector3(Random.Range(-groupToSpawnSize[i], groupToSpawnSize[i]) + pointForGroupSpawn.x, 1, // Random.Range(-groupToSpawnSize[i], groupToSpawnSize[i]) + pointForGroupSpawn.z); Vector3 positionToSpawn = new Vector3(pointForGroupSpawn.x + memberSpawnPositionXY.x, pointForGroupSpawn.y, pointForGroupSpawn.z + memberSpawnPositionXY.y); // TODO: Chequear cuando esté vacía if (reserveEnemies[i].Count == 0) { Debug.Log("No more enemies in reserve"); continue; } GameObject nextEnemy = reserveEnemies[i][0]; reserveEnemies[i].Remove(nextEnemy); // TODO: Revisar que falla aquí if (nextEnemy.gameObject == null) { Debug.Log(nextEnemy); continue; } // TODO: Revisar lo de la posición al activarlos nextEnemy.SetActive(true); nextEnemy.transform.position = positionToSpawn; EnemyConsistency enemyConsistency = nextEnemy.GetComponent <EnemyConsistency>(); // TODO: Cuando esté bien organizado este paso no debería ahcer falta if (enemyConsistency == null) { enemyConsistency = nextEnemy.GetComponentInChildren <EnemyConsistency>(); } // if (enemyConsistency != null) { enemyConsistency.ManagerIndex = i; enemyConsistency.ResetStatus(); } // Ponemos los bosses de lado de momento if (levelManager.LevelVictoryCondition == VictoryCondition.SlayTheBeast && i == 0) { nextEnemy.transform.Rotate(Vector3.up * -90); } // Y lo añadimos a enemigos activos activeEnemies[i].Add(nextEnemy); // Si he formación lo metemos a ella if (newEnemyFormation != null) { //TODO: Meterlo en la formación EnemyBaseBodyBehaviour behaviour = nextEnemy.GetComponent <EnemyBaseBodyBehaviour>(); // TODO: Arregalro para que no haga falta hacer esto if (behaviour == null) { behaviour = nextEnemy.GetComponentInChildren <EnemyBaseBodyBehaviour>(); } // newEnemyFormation.formationMembers.Add(behaviour); behaviour.enemyFormation = newEnemyFormation; } //GameObject nextEnemy = Instantiate(enemyPrefabsToUse[i], pointForGroupSpawn, Quaternion.identity); } } //else // Debug.Log("Zero enemies to spawn or no more room for enemies"); }