Inheritance: MonoBehaviour
Beispiel #1
0
    public void separateLetters()
    {
        Debug.Log("Separating letters");
        // First add a Rigid Body component to the letters
        GameObject     letters = gameObject.transform.Find("Letters").gameObject;
        BoxCollider    collider;
        Rigidbody      rb;
        PhysicMaterial letterbounce = new PhysicMaterial();

        letterbounce.bounciness = .7f;
        Vector3 rbf = new Vector3();

        foreach (Transform letter in letters.transform)
        {
            rb                = letter.gameObject.AddComponent <Rigidbody> ();
            collider          = letter.gameObject.AddComponent <BoxCollider> ();
            collider.material = letterbounce;
            rbf.x             = Random.Range(-.3f, .3f);
            rbf.y             = Random.Range(-3, 3);
            rbf.z             = Random.Range(-.3f, .3f);
            rb.AddForce(rbf, ForceMode.VelocityChange);
            TimedDestroy timerscript = letter.gameObject.AddComponent <TimedDestroy> ();
            timerscript.m_destroyTime = Random.Range(m_destroyDelay * .80f, m_destroyDelay * 1.20f);
            timerscript.activate();
            //letter.parent = letter.parent.parent.parent;
        }
        letters.transform.DetachChildren();
    }
Beispiel #2
0
    //Hides the enemy's body, plays the death sound and particle system, then deletes the enemy after they finish.
    public override void OnDeath()
    {
        body.SetActive(false);
        if (deathAudio)
        {
            source.PlayOneShot(deathAudio);
        }
        DeathPS.Play();

        GetComponent <BaseAIStateMachine>().Deactivate();

        if (PlayerVariables.playerHealth <= healthSpawnThreshold)
        {
            pickupSpawnerObj.SetActive(true);
            SpawnHealth();
            TimedDestroy TD = pickupSpawnerScript.pickup.GetComponent <TimedDestroy>();
            deleteDelay = pickupSpawnerScript.spawnCount * pickupSpawnerScript.spawnDelay + (TD != null ? TD.time : 0);
        }
        else
        {
            deleteDelay = source.clip.length;
        }
        MassegeArena();
        Invoke(nameof(EndDeath), deleteDelay);
    }
Beispiel #3
0
 // Switches the Image Displayed for RxnImg
 public static void delpic()
 {
     if (GM.bricks == 3)
     {
         TimedDestroy.Destroy(Res17);
     }
 }
Beispiel #4
0
    private void InstantiateSound(AudioClip a_clip, float a_volume = 1f)
    {
        GameObject   gameObject = (GameObject)Object.Instantiate(m_audioPrefab, base.transform.position, Quaternion.identity);
        TimedDestroy component  = gameObject.GetComponent <TimedDestroy>();

        component.m_destroyAfter = a_clip.length + 0.1f;
        gameObject.audio.clip    = a_clip;
        gameObject.audio.volume  = a_volume;
        gameObject.audio.pitch   = Random.Range(0.9f, 1.1f);
        gameObject.audio.Play();
    }
    //Plays an Audio Clip for an Animation
    public void PlayAudio(AudioClip clip)
    {
        GameObject  a      = new GameObject("clip");
        AudioSource source = a.AddComponent <AudioSource>();

        source.clip = clip;
        source.Play();

        TimedDestroy destroyer = a.AddComponent <TimedDestroy>();

        destroyer.startOnAwake = true;
        destroyer.time         = clip.length;
    }
Beispiel #6
0
 //To be overridden by child
 public void ApplyPowerup(float duration)
 {
     if (powerupEffect)
     {
         GameObject   effect       = Instantiate(powerupEffect, this.transform);
         TimedDestroy destroyTimer = effect.GetComponent <TimedDestroy>();
         if (destroyTimer)
         {
             destroyTimer.SetTime(duration);
             destroyTimer.StartCountdown();
         }
     }
 }
Beispiel #7
0
    public void CmdActivateTimedDestroy(NetworkInstanceId objid)
    {
        NetworkIdentity netid         = NetworkServer.objects [objid];
        GameObject      obj           = netid.gameObject;
        TimedDestroy    destroyscript = obj.GetComponent <TimedDestroy> ();

        if (destroyscript)
        {
            SoundObjectActs acts = obj.GetComponent <SoundObjectActs> ();
            if (acts.m_looping)
            {
                CmdToggleSoundObjectLoopingState(objid);
            }
            destroyscript.RpcActivate();
        }
        else
        {
            CmdDestroyObject(objid);
        }
    }
Beispiel #8
0
    void Start()
    {
        /*
         * "Particle Effects"
         */
        // Get All Cubes
        cubes = transform.GetComponentsInChildren <Rigidbody>();

        // Jiggle Positions
        for (int i = 0; i < cubes.Length; i++)
        {
            cubes[i].transform.position += new Vector3(Random.Range(-0.25f, 0.25f), Random.Range(0, 0.25f), Random.Range(-0.25f, 0.25f));
        }

        // Add Explosion Force
        for (int i = 0; i < cubes.Length; i++)
        {
            cubes[i].AddExplosionForce(40f, transform.position, explosionRadius);
        }

        /*
         * Explosion Force
         */
        GameObject[] mobs = GameObject.FindGameObjectsWithTag("Mob");
        for (int i = 0; i < mobs.Length; i++)
        {
            if (Vector3.Distance(transform.position, mobs[i].transform.position) <= explosionRadius)
            {
                MobController m = mobs[i].GetComponent <MobController>();

                m.BlownAway();
                mobs[i].rigidbody.AddExplosionForce(400f, transform.position, explosionRadius);

                TimedDestroy t = mobs[i].AddComponent <TimedDestroy>();
                t.destroyTime = explosionLength;
            }
        }
    }