예제 #1
0
    void OnCollisionEnter(Collision c)
    {
        if (!isReady)
        {
            return;
        }

        if (c.transform.tag.Contains(TAG_NAME.TAG_GUN) || (c.transform.tag.Contains(TAG_NAME.TAG_THROW)) || (c.transform.tag.Contains(TAG_NAME.TAG_NONETARGET)))
        {
            return;
        }

        Instantiate(prefabExplosion, transform.position, prefabExplosion.transform.rotation);
        VR_AudioManager.Instance.PlaySE(AUDIO_NAME.SE_EXPLOSION, transform.position, 20.0f, 1.0f);

        Collider[] targets = Physics.OverlapSphere(transform.position, DAMAGE_AREA_RADUIUS);
        foreach (Collider obj in targets)
        {
            IRegionSettable i_region = obj.gameObject.GetComponent <IRegionSettable>();
            if (i_region != null)
            {
                i_region.SetRegionType(Region.TYPE.NONE);
            }

            IDamageable <int> i_damage = obj.gameObject.GetComponent <IDamageable <int> >();
            if (i_damage != null)
            {
                i_damage.SetGenPos(transform.position, BOMB_FORCE);
                i_damage.Damage(GetAttackValue());
            }
            else
            {
                if (!obj.tag.Contains(TAG_NAME.TAG_GUN) &&
                    !obj.tag.Contains(TAG_NAME.TAG_THROW))
                {
                    Rigidbody rigid = obj.GetComponent <Rigidbody>();
                    if (rigid != null)
                    {
                        Vector3 forceDir = (obj.transform.position - transform.position).normalized;
                        forceDir.x = forceDir.x * BOMB_FORCE;
                        forceDir.y = (forceDir.y + Random.Range(0.8f, 2.5f)) * BOMB_FORCE;
                        forceDir.z = forceDir.z * BOMB_FORCE;

                        rigid.AddForceAtPosition(forceDir, transform.position, ForceMode.Impulse);
                    }
                }
            }
        }
        Destroy(gameObject);
    }
예제 #2
0
    /// <summary>
    /// 損傷ダメージ
    /// </summary>
    /// <param name="_damageValue">Damage value.</param>
    public void Damage(int _damageValue)
    {
        IRegionSettable i_region = callTarget.GetComponent <IRegionSettable>();

        if (i_region != null)
        {
            i_region.SetRegionType(regionType);
        }

        IDamageable <int> i_damage = callTarget.GetComponent <IDamageable <int> >();

        if (i_damage != null)
        {
            i_damage.Damage(_damageValue);
        }
    }
예제 #3
0
    /// <summary>
    /// 損壊時の処理
    /// </summary>
    protected override void ToBreak()
    {
        base.ToBreak();

        // 走行エフェクト停止
        foreach (ParticleSystem smoke in arrayEffectSmoke)
        {
            smoke.Stop();
        }
        navMeshObstacle.enabled = true;
        // パス移動停止
        iTween.Stop(tankTransform.gameObject);

        foreach (Transform t in arrayBombPoint)
        {
            WaitAfter(Random.Range(0.0f, 0.1f), () => { Instantiate(prefabExplosion, t.position, prefabExplosion.transform.rotation); });
        }

        VR_AudioManager.Instance.StopSE(AUDIO_NAME.SE_TANK_MOVE);
        VR_AudioManager.Instance.PlaySE(AUDIO_NAME.SE_EXPLOSION, transform.position, 1.0f);

        foreach (GameObject go in arrayFire)
        {
            go.SetActive(true);
        }

        Collider[] targets = Physics.OverlapSphere(tankTransform.position, DAMAGE_AREA_RADUIUS);

        foreach (Collider obj in targets)
        {
            if (!gameObject.Equals(obj.gameObject))
            {
                IRegionSettable i_region = obj.gameObject.GetComponent <IRegionSettable>();
                if (i_region != null)
                {
                    i_region.SetRegionType(Region.TYPE.NONE);
                }

                IDamageable <int> idamage = obj.gameObject.GetComponent <IDamageable <int> >();
                if (idamage != null)
                {
                    idamage.Damage(DEAD_BOMB_POWER);
                }
                else
                {
                    if (!obj.tag.Contains(TAG_NAME.TAG_GUN) &&
                        !obj.tag.Contains(TAG_NAME.TAG_THROW))
                    {
                        Rigidbody rigid = obj.GetComponent <Rigidbody>();
                        if (rigid != null)
                        {
                            Vector3 forceDir = (obj.transform.position - transform.position).normalized;
                            forceDir.x = forceDir.x * BOMB_FORCE;
                            forceDir.y = (forceDir.y + Random.Range(0.8f, 2.5f)) * BOMB_FORCE;
                            forceDir.z = forceDir.z * BOMB_FORCE;

                            rigid.AddForceAtPosition(forceDir, transform.position, ForceMode.Impulse);
                        }
                    }
                }
            }
        }

        rootTurretColider.SetActive(false);

        foreach (BoxCollider col in arrayAfterCol)
        {
            col.enabled = true;
        }

        var rigidTurret = turret.gameObject.AddComponent <Rigidbody>();

        rigidTurret.mass = 100;
    }