コード例 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "PlayerBullet")
        {
            Destroy(other.gameObject.transform.parent.gameObject);
        }

        if (other.tag == "Enemy")
        {
            if (other.gameObject.name.Contains("Boss")) //보스는 벽에 닿더라도 삭제할 필요없다 어차피 클리어 될때까지 사라질일 없음
            {
                return;
            }

            Destroy(other.gameObject);
        }

        if (other.tag == "EnemyBullet")
        {
            EntityBulletInfo EntityBulletInfo = other.GetComponent <EntityBulletInfo>();
            Destroy(other.gameObject.transform.parent.gameObject);
        }

        if (other.tag == "PlayerUltimate")
        {
            Destroy(other.gameObject);
        }
    }
コード例 #2
0
    public GameObject SpawnBullet(EntityBulletType type, Vector3 position, Quaternion rotation, EntityCore core, float speed, int damage, Vector3 defaultDirection, AllyFlag allyFlag, bool selfControlled = false, Vector3 noramalizedDirection = default)
    {
        Rect bottomRectangle = new Rect(new Vector2(-15.0f, -15.0f), new Vector2(90.0f, 13.0f));
        Rect topRectangle    = new Rect(new Vector2(-15.0f, 102.0f), new Vector2(90.0f, 13.0f));
        Rect leftRectangle   = new Rect(new Vector2(-15.0f, -15.0f), new Vector2(13.0f, 130.0f));
        Rect rightRectangle  = new Rect(new Vector2(62.0f, -15.0f), new Vector2(13.0f, 130.0f));

        if (bottomRectangle.Contains(position))
        {
            return(null);
        }

        if (topRectangle.Contains(position))
        {
            return(null);
        }

        if (leftRectangle.Contains(position))
        {
            return(null);
        }

        if (rightRectangle.Contains(position))
        {
            return(null);
        }

        GameObject bulletPrefab = GetEnemyBulletPrefabObject(type);

        if (bulletPrefab == null)
        {
            throw new Exception(type.ToString() + "의 불렛프리팹을 가져오는데 실패했습니다");
        }

        GameObject gameObject = Instantiate(bulletPrefab, position, rotation);

        switch (allyFlag)
        {
        case AllyFlag.Player:
            gameObject.SetTagIncludeAllChildren("PlayerBullet");
            break;

        case AllyFlag.Enemy:
            gameObject.SetTagIncludeAllChildren("EnemyBullet");
            break;
        }

        EntityBulletInfo comp = gameObject.AddComponent <EntityBulletInfo>();

        comp.SetSpeed(speed);
        comp.SetSelfControlled(selfControlled);
        comp.SetDamage(damage);
        comp.SetEntityCore(core);
        comp.SetDirection(noramalizedDirection);
        comp.SetDefaultDirection(defaultDirection);
        gameObject.GetComponent <EntityBulletMovementController>().SetEntityBulletInfo(comp);
        return(gameObject);
    }
コード例 #3
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));
            }
        }
    }
コード例 #4
0
 public void SetEntityBulletInfo(EntityBulletInfo EntityBulletInfo) => m_EntityBulletInfo = EntityBulletInfo;