Exemplo n.º 1
0
 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;
         }
     }
 }
Exemplo n.º 2
0
 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");
 }
Exemplo n.º 3
0
    void Awake()
    {
        //init singleton
        if (active == null) { active = this; }
        else { Destroy(this.gameObject); }


    }
Exemplo n.º 4
0
 // 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();
     }
 }
Exemplo n.º 5
0
 // Update is called once per frame
 void Update()
 {
     AnimationController();
     PlayerInputs();
     if (enemyFormation == null)
     {
         enemyFormation = GameObject.FindObjectOfType <EnemyFormation> ();
     }
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 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]);
         }
     }
 }
Exemplo n.º 8
0
    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"));
    }
Exemplo n.º 9
0
 public void LoadLevel3()
 {
     if (level3returning == false)
     {
         Application.LoadLevel("Level3");
         level3returning = true;
     }
     else
     {
         EnemyFormation.UpDiff3();
         Application.LoadLevel("Level3");
     }
 }
Exemplo n.º 10
0
    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"));
    }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 public AI2FlyInFormation(EnemyFormation formation)
 {
     this.formation = formation;
 }
Exemplo n.º 13
0
 void Awake()
 {
     enemyFormation = FindObjectOfType<EnemyFormation>();
 }
Exemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        gameController = FindObjectOfType<GameController>();
        enemyFormation = FindObjectOfType<EnemyFormation>();

        currentShield = startingShield;
        currentHealth = startingHealth;
    }
Exemplo n.º 15
0
 // Use this for initialization
 void Awake()
 {
     gameController = FindObjectOfType<GameController>();
     enemyFormation = FindObjectOfType<EnemyFormation>();
 }
Exemplo n.º 16
0
 public void KeepFighting()
 {
     BubbaHider.isActive = true;
     EnemyFormation.UpDifficulty();
     waves = startWaves + 1;
 }
Exemplo n.º 17
0
    /// <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");
    }