Example #1
0
    public void PullTrigger(Collider2D other)
    {
        if (currHitPoint <= 0)
        {
            return;
        }

        float  damage     = 0;
        string otherLayer = LayerMask.LayerToName(other.gameObject.layer);

        if (otherLayer == TagManager.sSingleton.playerBulletLayer)
        {
            if (other.GetComponent <BulletMove>() != null)
            {
                BulletMove bulletMove = other.GetComponent <BulletMove>();
                damage = bulletMove.GetBulletDamage;

                if (bulletMove.GetIsMagnum)
                {
                    mIsMarkedByMagnum = true;
                }

                if (!bulletMove.GetIsPiercing())
                {
                    other.gameObject.SetActive(false);
                }

                GetDamaged(damage, other, bulletMove.BulletType);
            }
            else if (other.GetComponent <DamageWithinRadius>() != null && !isHitByMagnumRadius)
            {
                mIsMarkedByMagnum   = true;
                isHitByMagnumRadius = true;

                DamageWithinRadius dmgRad = other.GetComponent <DamageWithinRadius>();
                GetDamaged(dmgRad.damage, other, BulletManager.GroupIndex.PLAYER_MAIN);
            }
        }
        else if (otherLayer == TagManager.sSingleton.playerBulletNoDestroyLayer)
        {
            Laser laser = other.GetComponent <Laser>();
            damage = laser.GetDmgPerFrame;
            GetDamaged(damage, other, BulletManager.GroupIndex.PLAYER_SECONDARY);
        }
    }
Example #2
0
    void GetDamaged(float damagedValue, Collider2D other, BulletManager.GroupIndex groupType)
    {
        float scoreGet = damagedValue * scoreMultiplier;

        currHitPoint -= damagedValue;

        ParticleSystem ps  = EnvObjManager.sSingleton.GetEnemyHitImpactPS();
        Vector3        pos = other.gameObject.GetComponent <Collider2D>().bounds.ClosestPoint(transform.position);

        BulletMove bulletMove = other.GetComponent <BulletMove>();

        if ((bulletMove != null && bulletMove.GetIsPiercing()) || other.GetComponent <Laser>() != null)
        {
            PlayEnemyGetHitImpactPS(ps, pos, true);
        }
        else
        {
            PlayEnemyGetHitImpactPS(ps, pos, false);
        }

        if (!mIsChangeColor)
        {
            StartCoroutine(GetDamagedColorChange());
        }
        if (currHitPoint <= 0)
        {
            if (isBoss)
            {
                BulletManager.sSingleton.TransformEnemyBulsIntoScorePU();
                BulletManager.sSingleton.DisableEnemyBullets(false);
                UIManager.sSingleton.DeactivateBossTimer();
                EnemyManager.sSingleton.isBossDead = true;

                if (isEndShakeScreen)
                {
                    CameraShake.sSingleton.ShakeCamera();
                }
                if (AudioManager.sSingleton != null)
                {
                    AudioManager.sSingleton.PlayBossExplodeSfx();
                }
            }
            else if (mItemDropController != null)
            {
                mItemDropController.ItemDropFunc();
            }

            if (mIsMarkedByMagnum)
            {
                Transform magnumRad = EnvObjManager.sSingleton.GetMagnumRadius();
                magnumRad.position = transform.position;
                magnumRad.gameObject.SetActive(true);

                mMagnumTimer      = 0;
                mIsMarkedByMagnum = false;
            }

            if (other.tag == TagManager.sSingleton.player1BulletTag)
            {
                mPlayer1Controller.UpdateMultiplier(defeatedMult);
            }
            else if (other.tag == TagManager.sSingleton.player2BulletTag)
            {
                mPlayer2Controller.UpdateMultiplier(defeatedMult);
            }
            else if (other.tag == TagManager.sSingleton.magnumRadTag)
            {
                int playerID = other.GetComponent <DamageWithinRadius> ().playerID;
                if (playerID == 1)
                {
                    mPlayer1Controller.UpdateMultiplier(defeatedMult);
                }
                else if (playerID == 2)
                {
                    mPlayer2Controller.UpdateMultiplier(defeatedMult);
                }
            }

            scoreGet  = (currHitPoint + damagedValue) * scoreMultiplier;
            scoreGet += defeatedScore;

            Transform trans = EnvObjManager.sSingleton.GetKillScore();
            trans.GetComponent <Text> ().text = defeatedScore.ToString();
            trans.position = transform.position;
            trans.gameObject.SetActive(true);

            PlayEnemyDeathPS();
            gameObject.SetActive(false);
        }

        PlayerGainScore((int)scoreGet, other, groupType);
    }
Example #3
0
    void OnTriggerStay2D(Collider2D other)
    {
        if (!isDestructable)
        {
            return;
        }

        float  damage         = 0;
        string otherLayerName = LayerMask.LayerToName(other.gameObject.layer);

        BulletMove bulletMove = other.GetComponent <BulletMove>();

        // Particle play.
        if (otherLayerName == TagManager.sSingleton.playerBulletLayer || otherLayerName == TagManager.sSingleton.playerBulletNoDestroyLayer)
        {
            if (other.tag != TagManager.sSingleton.bombShieldTag && other.tag != TagManager.sSingleton.bulletWipeTag)
            {
                if (!mIsChangeColor)
                {
                    StartCoroutine(GetDamagedColorChange());
                }

                ParticleSystem ps  = EnvObjManager.sSingleton.GetEnemyHitImpactPS();
                Vector3        pos = other.gameObject.GetComponent <Collider2D>().bounds.ClosestPoint(transform.position);

                if ((bulletMove != null && bulletMove.GetIsPiercing()) || other.GetComponent <Laser>() != null)
                {
                    PlayEnvObjGetHitImpactPS(ps, pos, true);
                }
                else
                {
                    PlayEnvObjGetHitImpactPS(ps, pos, false);
                }
            }
        }

        // Damage and impact.
        if (otherLayerName == TagManager.sSingleton.playerBulletLayer)
        {
            if (other.tag == TagManager.sSingleton.player1BulletTag || other.tag == TagManager.sSingleton.player2BulletTag)
            {
                damage = bulletMove.GetBulletDamage;

                float deltaTime = 0;
                if (BombManager.sSingleton.isTimeStopBomb)
                {
                    deltaTime = Time.unscaledDeltaTime;
                }
                else
                {
                    deltaTime = Time.deltaTime;
                }

                // Move object up slightly.
                Vector3 pos = transform.position;
                pos.y += deltaTime * impactMultiplier;
                transform.position = pos;

                // Update player's score.
                if (other.tag == TagManager.sSingleton.player1BulletTag)
                {
                    if (bulletMove.BulletType == BulletManager.GroupIndex.PLAYER_MAIN)
                    {
                        mPlayer1Controller.UpdateLinkBar(extraLinkMultiplier);
                    }
                    else if (bulletMove.BulletType == BulletManager.GroupIndex.PLAYER_SECONDARY)
                    {
                        mPlayer1Controller.UpdateLinkBarForSecondary(extraLinkMultiplier);
                    }

                    mPlayer1Controller.UpdateScore((int)(damage * scoreMultiplier));
                }
                else if (other.tag == TagManager.sSingleton.player2BulletTag)
                {
                    if (bulletMove.BulletType == BulletManager.GroupIndex.PLAYER_MAIN)
                    {
                        mPlayer2Controller.UpdateLinkBar(extraLinkMultiplier);
                    }
                    else if (bulletMove.BulletType == BulletManager.GroupIndex.PLAYER_SECONDARY)
                    {
                        mPlayer2Controller.UpdateLinkBarForSecondary(extraLinkMultiplier);
                    }

                    mPlayer2Controller.UpdateScore((int)(damage * scoreMultiplier));
                }

                if (!bulletMove.GetIsPiercing())
                {
                    other.gameObject.SetActive(false);
                }
            }
        }
        else if (otherLayerName == TagManager.sSingleton.playerBulletNoDestroyLayer)
        {
            if (other.GetComponent <Laser>() != null)
            {
                Laser laser = other.GetComponent <Laser>();
                damage = laser.GetDmgPerFrame;

                if (other.tag == TagManager.sSingleton.player1BulletTag)
                {
                    mPlayer1Controller.UpdateLinkBarForSecondary(extraLinkMultiplier);
                    mPlayer1Controller.UpdateScore((int)(damage * scoreMultiplier));
                }
                else if (other.tag == TagManager.sSingleton.player2BulletTag)
                {
                    mPlayer2Controller.UpdateLinkBarForSecondary(extraLinkMultiplier);
                    mPlayer2Controller.UpdateScore((int)(damage * scoreMultiplier));
                }
            }
        }

        // Death.
        currHitPoint -= damage;
        if (currHitPoint <= 0 && !mIsDead)
        {
            ParticleSystem ps = EnvObjManager.sSingleton.GetRockDestroyPS();
            ps.transform.position = transform.position;
            ps.Play();

            gameObject.SetActive(false);
            for (var i = 0; i < transform.childCount; i++)
            {
                if (transform.GetChild(i).gameObject.activeSelf)
                {
                    transform.GetChild(i).GetComponent <ItemDropController>().ItemDropFunc();
                    gameObject.SetActive(false);
                }
            }

            if (other.tag == TagManager.sSingleton.player1BulletTag)
            {
                mPlayer1Controller.UpdateMultiplier(defeatedMult);
            }
            else if (other.tag == TagManager.sSingleton.player2BulletTag)
            {
                mPlayer2Controller.UpdateMultiplier(defeatedMult);
            }

            mIsDead = true;
        }
    }