Exemple #1
0
    public float Raise(Vector3 position, Quaternion rotation, Vector3 scale, Transform parent = null)
    {
        float fxTime = 0;

        if (sfx != null)
        {
            AudioInstance.PlayClipAtPoint(sfx, position, outputMixer, pitchRange);
            fxTime = sfx.length;
        }

        foreach (GameObject visualFX in visualFX)
        {
            GameObject instance = FXPool.getFXObject(visualFX, poolSize);
            instance.transform.position = position;
            instance.transform.rotation = rotation;
            instance.transform.SetParent(parent);
            instance.transform.localScale = scale;
            instance.SetActive(true);
            VisualFX vFX = instance.GetComponent <VisualFX>();
            if (vFX != null)
            {
                if (fxTime < vFX.displayTime)
                {
                    fxTime = vFX.displayTime;
                }
                vFX.Play();
            }
        }
        return(fxTime);
    }
Exemple #2
0
    public static GameObject InstanceFromPool(this GameObject prefab, int poolSize, Transform parent)
    {
        GameObject instance = FXPool.getFXObject(prefab, poolSize);

        instance.transform.SetParent(parent);
        instance.SetActive(true);
        return(instance);
    }
Exemple #3
0
    public static GameObject InstanceFromPool(this GameObject[] prefabArray, int maxIndex, int poolSize, Transform parent)
    {
        GameObject prefab = prefabArray[
            Random.Range(
                0,
                Mathf.Clamp(maxIndex, 0, prefabArray.Length)
                )];
        GameObject instance = FXPool.getFXObject(prefab, poolSize);

        instance.transform.SetParent(parent);
        instance.SetActive(true);
        return(instance);
    }
Exemple #4
0
    public void Raise(Vector3 position, out AudioSource audioSource, out GameObject[] vfx)
    {
        if (sfx != null)
        {
            if (loopSFX)
            {
                audioSource = AudioInstance.LoopClipAtPoint(sfx, position, outputMixer, pitchRange);
            }
            else
            {
                AudioInstance.PlayClipAtPoint(sfx, position, outputMixer, pitchRange);
                audioSource = null;
            }
        }
        else
        {
            audioSource = null;
        }

        vfx = new GameObject[visualFX.Length];
        for (int i = 0; i < visualFX.Length; i++)
        {
            GameObject visualfx = visualFX[i];
            GameObject instance = FXPool.getFXObject(visualfx, poolSize);
            instance.transform.position = position;
            instance.transform.rotation = visualfx.transform.rotation;
            instance.transform.SetParent(null);
            instance.transform.localScale = Vector3.one;
            instance.SetActive(true);
            VisualFX vFX = instance.GetComponent <VisualFX>();
            if (vFX != null)
            {
                vFX.Play();
            }
            vfx[i] = instance;
        }
    }