Esempio n. 1
0
    IEnumerator SetDetonation()
    {
        Transform delayEffect = Instantiate(delayParticles, transform.position, Quaternion.identity);

        delayEffect.parent = transform;
        Destroy(delayEffect.gameObject, delay);
        yield return(new  WaitForSeconds(delay));

        // annd kaboom
        Transform detonateEffect = Instantiate(detonateParticles, transform.position, Quaternion.identity);

        Destroy(detonateEffect.gameObject, 3f);
        TerrainManager tMan = FindObjectOfType <TerrainManager>();

        if (tMan != null)
        {
            tMan.AddJob(transform.position, effectPower, radius, effectDuration, falloff);
        }
        Destroy(gameObject, 0.1f);
    }
Esempio n. 2
0
    public override void LandHit(RaycastHit hit, Vector3 hitPosition)
    {
        base.LandHit(hit, hitPosition);

        if (!bHit && (impactParticles != null))
        {
            // Spawning impact particles
            Transform hitParticles = Instantiate(impactParticles, hitPosition, transform.rotation);
            Destroy(hitParticles.gameObject, 1.1f);

            // Detach lifetime particles
            if (onboardParticles != null)
            {
                onboardParticles.parent = null;
                Destroy(onboardParticles.gameObject, 1.0f);
            }

            // Damage & Radius
            float hitnormalScalar = Mathf.Clamp(Mathf.Pow(1f / Mathf.Abs(Vector3.Dot(Vector3.up, hit.normal)), 2f), 1f, 10f);
            float thisHitDamage   = damage * Mathf.Clamp(hitnormalScalar, 1f, 2f);
            float thisHitRadius   = radiusOfEffect * hitnormalScalar;

            // Ground Manipulations
            if (hit.transform.CompareTag("Land"))
            {
                TerrainManager tMan = FindObjectOfType <TerrainManager>();
                if (tMan != null)
                {
                    //tMan.RaiseMesh(hitPosition, thisHitDamage, thisHitRadius);
                    tMan.AddJob(hitPosition, thisHitDamage, thisHitRadius, damageDuration, falloff);
                }
            }

            audioPlayer.PlayOneShot(impactSound);

            bHit = true;

            //Destroy(gameObject, 2f);
        }
    }