Exemple #1
0
    private void OnDestroy()
    {
        if (m_PlayerGun == null)
        {
            return;
        }

        GunCoreCharging playerGunCoreCharging = m_PlayerGun.GetCore <GunCoreCharging>();

        if (playerGunCoreCharging.IsCharging() == true)
        {
            ParticleFactory.GetInstance().DeleteParticle(this);
        }
    }
    protected void OnTriggerEnter(Collider coll)
    {
        if (coll.tag == "EnemyBullet")
        {
            if (gameObject.layer == LayerMask.NameToLayer("EnemyEntity"))
            {
                return;
            }

            ParticleFactory.GetInstance().CreateOnceParticle <ParticleExplosion>(coll.gameObject.GetComponent <Collider>().ClosestPointOnBounds(transform.position))
            .SetExplosionParticleNumber(10)
            .SetMinExplosionDistance(1.0f)
            .SetMaxExplosionDistance(3.0f)
            .SetExplosionParticleLifeTime(0.4f)
            .SetExplosionParticleColor(new Color(Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f)))
            .Play();

            if (m_Core.isPenetrable() == false)
            {
                Destroy(coll.gameObject.transform.parent.gameObject);
            }

            Material material = GetComponentInChildren <MeshRenderer>().material;

            if (m_Core.IsInvincible() == false)
            {
                m_Core.SetHp <EntityCore>(m_Core.GetHp() - ManagerPool.GetInstance().GetManager <PlayerManager>().GetPlayerGun().GetBulletDamage());
            }

            if (m_Core.GetHp() <= 0)
            {
                PlayerManager playerManager = ManagerPool.GetInstance().GetManager <PlayerManager>();
                playerManager.SetPlayerScore(playerManager.GetPlayerScore() + m_Core.GetScore());

                ParticleFactory.GetInstance().CreateOnceParticle <ParticleExplosion>(gameObject.transform.position)
                .SetExplosionParticleColor(new Color(Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f)))
                .Play();
                Destroy(gameObject);

                material.DOKill();
            }
            else
            {
                DOTween.Sequence()
                .Append(material.DOColor(Color.white, 0.05f))
                .Append(material.DOColor(m_Core.GetColor(), 0.05f));
            }
        }

        if (coll.tag == "PlayerBullet")
        {
            if (gameObject.layer == LayerMask.NameToLayer("PlayerEntity"))
            {
                return;
            }

            ParticleFactory.GetInstance().CreateOnceParticle <ParticleExplosion>(coll.gameObject.GetComponent <Collider>().ClosestPointOnBounds(transform.position))
            .SetExplosionParticleNumber(10)
            .SetMinExplosionDistance(1.0f)
            .SetMaxExplosionDistance(3.0f)
            .SetExplosionParticleLifeTime(0.4f)
            .SetExplosionParticleColor(new Color(Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f)))
            .Play();

            if (m_Core.isPenetrable() == false)
            {
                Destroy(coll.gameObject.transform.parent.gameObject);
            }

            Material material = GetComponentInChildren <MeshRenderer>().material;

            if (m_Core.IsInvincible() == false)
            {
                m_Core.SetHp <EntityCore>(m_Core.GetHp() - ManagerPool.GetInstance().GetManager <PlayerManager>().GetPlayerGun().GetBulletDamage());
            }

            if (m_Core.GetHp() <= 0)
            {
                PlayerManager playerManager = ManagerPool.GetInstance().GetManager <PlayerManager>();
                ItemManager   itemManager   = ManagerPool.GetInstance().GetManager <ItemManager>();

                playerManager.SetPlayerScore(playerManager.GetPlayerScore() + m_Core.GetScore());

                ParticleFactory.GetInstance().CreateOnceParticle <ParticleExplosion>(gameObject.transform.position)
                .SetExplosionParticleColor(new Color(Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f)))
                .Play();

                float randNum = Random.Range(0.0f, 1000.0f);
                if (randNum <= 1000.0f)
                {
                    ItemType itemType = (ItemType)Random.Range(1, Enum.GetValues(typeof(ItemType)).Cast <int>().Max() + 1);
                    itemManager.SpawnItem(itemType, gameObject.transform.position);
                }

                Destroy(gameObject);
                material.DOKill();
            }
            else
            {
                if (m_Core.IsInvincible() == false)
                {
                    DOTween.Sequence()
                    .Append(material.DOColor(Color.white, 0.05f))
                    .Append(material.DOColor(m_Core.GetColor(), 0.05f));
                }
            }
        }
    }
Exemple #3
0
    void Update()
    {
        if (m_PlayerGun == null)
        {
            return;
        }

        if (m_PlayerManager.IsPlayerLoaded() == false)
        {
            return;
        }

        if (m_PlayerManager.IsInteractable() == false)
        {
            return;
        }

        if (m_PlayerManager.IsShootable() == false)
        {
            return;
        }

        m_PlayerGun.SetCurrentBulletFiringTime(m_PlayerGun.GetCurrentBulletFiringTime() + Time.deltaTime);
        if (m_PlayerGun.GetCurrentBulletFiringTime() >= m_PlayerGun.GetBulletFiringDelay())
        {
            m_PlayerGun.SetFireEnabled(true);
        }

        bool hasGunChargingCore = m_PlayerGun.HasCore <GunCoreCharging>();

        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            m_CurrentRecognizingPressedTime += Time.deltaTime;
            if (m_PlayerGun.IsFireEnabled())
            {
                if (hasGunChargingCore == false)
                {
                    FireBullet();
                }
                else
                {
                    GunCoreCharging playerGunCoreCharging = m_PlayerGun.GetCore <GunCoreCharging>();

                    if (m_CurrentRecognizingPressedTime < m_MaxRecognizingPressedTime)
                    {
                        FireBullet();
                    }
                }
            }
        }
        else if (Input.GetKey(KeyCode.LeftControl))
        {
            m_CurrentRecognizingPressedTime += Time.deltaTime;
            if (m_PlayerGun.IsFireEnabled())
            {
                if (hasGunChargingCore == false)
                {
                    FireBullet();
                }
                else
                {
                    if (m_CurrentRecognizingPressedTime < m_MaxRecognizingPressedTime)
                    {
                        FireBullet();
                    }
                    else
                    {
                        GunCoreCharging playerGunCoreCharging = m_PlayerGun.GetCore <GunCoreCharging>();

                        if (playerGunCoreCharging.IsCharging() == false)
                        {
                            if (playerGunCoreCharging.IsChargingFiring() == false)
                            {
                                playerGunCoreCharging.SetIsCharging(true);
                                ParticleFactory.GetInstance().CreatePermanentParticle <ParticleCharging>(this, m_FireTransforms[(int)MainFireTransformPosition.Top].transform).Play();
                            }
                        }
                        else
                        {
                            if (playerGunCoreCharging.IsChargingFiring() == false)
                            {
                                playerGunCoreCharging.SetChargingTime(playerGunCoreCharging.GetChargingTime() + Time.deltaTime);
                                m_PointLight.intensity = 20.0f * playerGunCoreCharging.GetChargingTime() / playerGunCoreCharging.GetMaxCharingTime();;
                                m_PointLight.range     = 20.0f * playerGunCoreCharging.GetChargingTime() / playerGunCoreCharging.GetMaxCharingTime();;


                                //차징 게이지가 모두 찬 경우 차징풀 상태로 바꾼다.
                                if (playerGunCoreCharging.GetChargingTime() >= playerGunCoreCharging.GetMaxCharingTime())
                                {
                                    playerGunCoreCharging.SetIsChargingFull(true);
                                }

                                //차징이 다된 경우 파티클을 더이상 재생하지 않는다.
                                if (playerGunCoreCharging.IsChargingFull() && ParticleFactory.GetInstance().IsPlaying <ParticleCharging>(this) == true)
                                {
                                    ParticleFactory.GetInstance().DeleteParticle(this);
                                }
                            }
                        }
                    }
                }
            }
        }

        else if (Input.GetKeyUp(KeyCode.LeftControl))
        {
            if (hasGunChargingCore == false)
            {
                FireBullet();
            }
            else
            {
                GunCoreCharging playerGunCoreCharging = m_PlayerGun.GetCore <GunCoreCharging>();
                ParticleFactory.GetInstance().DeleteParticle(this);

                if (playerGunCoreCharging.IsCharging() == true)
                {
                    FireBullet();
                }
            }

            m_CurrentRecognizingPressedTime = 0.0f;
            m_PointLight.intensity          = 0.0f;
            m_PointLight.range = 0.0f;
        }
    }
Exemple #4
0
    private void OnTriggerEnter(Collider coll)
    {
        if (m_PlayerManager.IsPlayerLoaded() == false)
        {
            return;
        }

        if (coll.tag == "Item")
        {
            ItemCore itemCore = coll.gameObject.GetComponent <ItemCore>();

            if (itemCore == null)
            {
                return;
            }

            Destroy(coll.gameObject);
            m_PlayerManager.EatItem(itemCore.GetItemType());
            m_PlayerManager.SetPlayerScore(m_PlayerManager.GetPlayerScore() + itemCore.GetScore());
        }

        if (coll.tag == "Enemy")
        {
            if (m_PlayerManager.isInvincible())
            {
                Debug.Log("[Mode] Invincible");
                return;
            }

            if (coll.gameObject.name.Contains("boss") == false)
            {
                Destroy(coll.gameObject);
            }
            Destroy(gameObject);

            m_PlayerManager.SetIsDead(true);
            m_PlayerManager.SetPlayerLifeCount(m_PlayerManager.GetPlayerLifeCount() - 1);
            m_PlayerManager.SetIsPlayerLoaded(false);

            ParticleFactory.GetInstance().CreateOnceParticle <ParticleExplosion>(gameObject.transform.position)
            .SetExplosionParticleColor(new Color(Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f)))
            .Play();

            ParticleFactory.GetInstance().CreateOnceParticle <ParticleExplosion>(coll.transform.position)
            .SetExplosionParticleColor(new Color(Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f)))
            .Play();
        }

        if (coll.tag == "EnemyBullet")
        {
            if (m_PlayerManager.isInvincible())
            {
                Debug.Log("[Mode] Invincible");
                return;
            }

            EntityBulletInfo bulletInfo = coll.transform.parent.GetComponent <EntityBulletInfo>();
            Material         material   = m_PlayerManager.GetPlayerMaterial();
            Destroy(coll.transform.parent.gameObject);

            m_PlayerManager.SetPlayerHp(m_PlayerManager.GetPlayerHp() - bulletInfo.GetDamage());
            if (m_PlayerManager.GetPlayerHp() <= 0)
            {
                m_PlayerManager.GetPlayerGun().ClearSupporter();
                m_PlayerManager.SetIsDead(true);
                m_PlayerManager.SetPlayerLifeCount(m_PlayerManager.GetPlayerLifeCount() - 1);
                m_PlayerManager.SetIsPlayerLoaded(false);

                ParticleFactory.GetInstance().CreateOnceParticle <ParticleExplosion>(gameObject.transform.position)
                .SetExplosionParticleColor(new Color(Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f), Random.Range(0.5f, 1.0f)))
                .Play();

                material.DOKill();
                Destroy(gameObject);
            }
            else
            {
                DOTween.Sequence()
                .Append(material.DOColor(m_PlayerManager.GetPlayerColor().Clone().SetA(0.0f), 0.05f))
                .Append(material.DOColor(m_PlayerManager.GetPlayerColor(), 0.05f));
            }
        }
    }