Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D otherCollider)
    {
        ProjectileController projectile = null;
        int destructionLevel            = CONSTRUCTION_LEVEL_INVALID;

        //Debug.Log("Debug : ObstacleController : on trigger enter.");
        if (otherCollider.gameObject != null)
        {
            projectile = otherCollider.gameObject.GetComponent <ProjectileController>();
            if (projectile != null)
            {
                destructionLevel = projectile.GetDestructionLevel();
                if ((destructionLevel != CONSTRUCTION_LEVEL_INVALID) && (destructionLevel >= constructionLevel))
                {
                    /*halmeida - in this case, the projectile may affect the obstacle.*/
                    if (projectile.GetEffectCode() == ProjectileController.EFFECT_CODE_HP_DAMAGE)
                    {
                        DamageObstacle(projectile.GetEffectIntensity(), otherCollider.gameObject);
                    }
                    else if (projectile.GetEffectCode() == ProjectileController.EFFECT_CODE_HP_RECOVERY)
                    {
                        DamageObstacle(projectile.GetEffectIntensity() * -1f, otherCollider.gameObject);
                    }
                }
                projectile.Deactivate();
            }
        }
    }
Esempio n. 2
0
    private void DeactivateObstacles(bool _newGame)
    {
        // ----- DEACTIVATE PROJECTILES -----

        // Loop CURRENT PROJECTILES list in reverse in order to remove elements safely
        for (int i = currentProjectiles.Count - 1; i >= 0; i--)
        {
            // If projectile is eligible for deactivating
            if (_newGame ||
                (currentProjectiles[i].CheckIf_ItsActive() && currentProjectiles[i].CheckIf_ItsGone()))
            {
                // ----- REMOVE FROM "CURRENT PROJECTILE GROUPS" -----

                // Loop "current projectile groups" list
                for (int a = currentProjectileGroups.Count - 1; a >= 0; a--)
                {
                    // Loop projectiles in current group
                    for (int b = currentProjectileGroups[a].Count - 1; b >= 0; b--)
                    {
                        // If projectile is found
                        if (currentProjectileGroups[a][b] == currentProjectiles[i])
                        {
                            // Remove from list
                            currentProjectileGroups[a].RemoveAt(b);
                        }
                    }

                    // Remove child list from parent list if child list is empty
                    if (currentProjectileGroups[a].Count == 0)
                    {
                        currentProjectileGroups.RemoveAt(a);
                    }
                }

                // ----- DEACTIVATE -----

                // Deactivate obstacle wall child
                DeactivateObstacleWallChild(currentProjectiles[i].gameObject);

                // Deactivate projectile
                currentProjectiles[i].Deactivate();

                // ----- REMOVE FROM "CURRENT PROJECTILES" -----

                // Remove from list
                currentProjectiles.RemoveAt(i);
            }
        }

        // ----- DEACTIVATE MINIONS -----


        // ----- DEACTIVATE FLAWED PROJECTILES -----

        if (_newGame || (flawedProjectile.CheckIf_ItsActive() && flawedProjectile.CheckIf_ItsGone()))
        {
            flawedProjectile.Deactivate();
        }
    }
Esempio n. 3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.layer == 11)
        {
            Debug.Log("collided with other");
            ProjectileController projectile = other.GetComponent <ProjectileController>();
            projectile.Deactivate();
            currentHealth -= projectile.damage;
            if (currentHealth <= 0f)
            {
                CancelInvoke("UpdatePath");
                gameObject.SetActive(false);
                EnemySpawner.enemyCount--;
            }


            return;
        }
    }