Beispiel #1
0
    private PowerupBumpAudio bumpAudio; // connection - auto: the sibling Powerup Bump Audio



    // updating //


    // before the start: //
    private void Awake()
    {
        // connect to the parent Powerup //
        powerup = transform.parent.GetComponent <Powerup>();

        // connect to the sibling Powerup Bump Audio //
        bumpAudio = powerup.GetComponentInChildren <PowerupBumpAudio>();
    }
Beispiel #2
0
    public void PowerupPickedUp(string powerupId)
    {
        // If gameobject is destroyed or already picked up (can happen if a remote user didn't get the RPC that the powerup
        // was picked up before sending his own) just return
        if (!powerups.ContainsKey(powerupId))
        {
            return;
        }
        Powerup powerup = powerups[powerupId];

        // Play pickup sound
        AudioSource.PlayClipAtPoint(pickupSound, powerup.transform.position);

        // Disable colliders so players can walk through the powerup
        SphereCollider[] cols = powerup.GetComponentsInChildren <SphereCollider>();
        foreach (var col in cols)
        {
            col.enabled = false;
        }

        // Hide all graphics except the particles
        powerup.GetComponentInChildren <Light>().enabled = false;
        MeshRenderer[] meshes = powerup.GetComponentsInChildren <MeshRenderer>();
        foreach (var mesh in meshes)
        {
            mesh.enabled = false;
        }

        // Disable looping on the partical system so the particles dissipate instead of suddenly disappearing
        var main = powerup.GetComponentInChildren <ParticleSystem>().main;

        main.loop = false;

        // Destroy instance after timeout
        Destroy(powerup.gameObject, 1.5f);
    }