Example #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            IncreaseScale();

            GameMaster.Instance.Freeze(freezeDuration);
            if (freezeDuration < .15f)
            {
                freezeDuration += addFreezeDuration;
            }

            if (ReadWriteSaveManager.Instance.GetData("CanFlash", true, false))
            {
                var flashInst = Instantiate(flashObj, other.transform.position, Quaternion.identity);
                Destroy(flashInst.gameObject, .25f);

                GameMaster.Instance.ChangeBackColor(colorNum);
                if (colorNum < .35f)
                {
                    colorNum += .05f;
                }
            }

            AudioManager.Instance.Play("EnemyHit", pitch);
            pitch += .05f;

            HomingEnemy   homingEnemy   = other.gameObject.GetComponent <HomingEnemy>();
            ShootingEnemy shootingEnemy = other.gameObject.GetComponent <ShootingEnemy>();
            SittingEnemy  sittingEnemy  = other.gameObject.GetComponent <SittingEnemy>();
            DashingEnemy  dashingEnemy  = other.gameObject.GetComponent <DashingEnemy>();

            if (homingEnemy)
            {
                scoreText.SetScore(addScoreHomingHit + addScoreStacking);
                comboUI.SetCounter(addScoreHomingHit + addScoreStacking, homingEnemy.transform.position);
                homingEnemy.DamageEnemy();
                defeatedHoming = true;
            }
            else if (shootingEnemy)
            {
                scoreText.SetScore(addScoreShootingHit + addScoreStacking);
                comboUI.SetCounter(addScoreShootingHit + addScoreStacking, shootingEnemy.transform.position);
                shootingEnemy.DamageEnemy();
                defeatedShooting = true;
            }
            else if (sittingEnemy)
            {
                scoreText.SetScore(addScoreSittingHit + addScoreStacking);
                comboUI.SetCounter(addScoreSittingHit + addScoreStacking, sittingEnemy.transform.position);
                sittingEnemy.DamageEnemy();
                defeatedSitting = true;
            }
            else if (dashingEnemy)
            {
                int dashingAdd = dashingEnemy.GetAddScore();
                scoreText.SetScore(addScoreDashingHit + addScoreStacking + dashingAdd);
                comboUI.SetCounter(addScoreDashingHit + addScoreStacking + dashingAdd, dashingEnemy.transform.position);
                dashingEnemy.DamageEnemy();
                defeatedDashing = true;
            }

            addScoreStacking += 100;

            comboCounter++;
            GameMaster.Instance.SpongeCheckUnlock(comboCounter);
            GameMaster.Instance.BounceCheckUnlock(defeatedHoming, defeatedShooting, defeatedSitting, defeatedDashing);
        }

        if (other.CompareTag("Player"))
        {
            PlayerShooting playerShooting = other.GetComponent <PlayerShooting>();

            if (playerShooting.isRecalling || playerShooting.canRecall)
            {
                shake.Shake(shakeDuration, shakeIntensity);
                AudioManager.Instance.Play("PlayerTriHit");
                playerShooting.BulletHit();
                Destroy(parentBul.gameObject);
            }
        }
    }
Example #2
0
    public void EnemyHit(GameObject enemy, Vector3 bulletPos, Quaternion bulletRot)
    {
        GameMaster.Instance.Freeze(freezeDuration);
        if (freezeDuration < .15f)
        {
            freezeDuration += addFreezeDuration;
        }

        if (ReadWriteSaveManager.Instance.GetData("CanFlash", true, false))
        {
            var flashInst = Instantiate(flashObj, bulletPos, Quaternion.identity);
            Destroy(flashInst.gameObject, .25f);

            GameMaster.Instance.ChangeBackColor(colorNum);
            if (colorNum < .35f)
            {
                colorNum += .05f;
            }
        }

        AudioManager.Instance.Play("EnemyHit", hitPitch);
        hitPitch += .05f;

        HomingEnemy   homing   = enemy.GetComponent <HomingEnemy>();
        ShootingEnemy shooting = enemy.GetComponent <ShootingEnemy>();
        SittingEnemy  sitting  = enemy.GetComponent <SittingEnemy>();
        DashingEnemy  dashing  = enemy.GetComponent <DashingEnemy>();

        if (homing)
        {
            scoreText.SetScore(addScoreHomingHit + addScoreStacking);
            comboUI.SetCounter(addScoreHomingHit + addScoreStacking, homing.transform.position);
            homing.DamageEnemy();
            defeatedHoming = true;
        }
        else if (shooting)
        {
            scoreText.SetScore(addScoreShootingHit + addScoreStacking);
            comboUI.SetCounter(addScoreShootingHit + addScoreStacking, shooting.transform.position);
            shooting.DamageEnemy();
            defeatedShooting = true;
        }
        else if (sitting)
        {
            scoreText.SetScore(addScoreSittingHit + addScoreStacking);
            comboUI.SetCounter(addScoreSittingHit + addScoreStacking, sitting.transform.position);
            sitting.DamageEnemy();
            defeatedSitting = true;
        }
        else if (dashing)
        {
            int dashingAdd = dashing.GetAddScore();
            scoreText.SetScore(addScoreDashingHit + addScoreStacking + dashingAdd);
            comboUI.SetCounter(addScoreDashingHit + addScoreStacking + dashingAdd, dashing.transform.position);
            dashing.DamageEnemy();
            defeatedDashing = true;
        }

        addScoreStacking += 100;
        comboCounter++;
        GameMaster.Instance.SpongeCheckUnlock(comboCounter);
        GameMaster.Instance.BounceCheckUnlock(defeatedHoming, defeatedShooting, defeatedSitting, defeatedDashing);
    }