Esempio n. 1
0
    public static VFX PlayVFX(VFXType type, Vector3 position)
    {
        var i = GetVFX(type);

        i.effect.transform.position = position;
        return(i);
    }
Esempio n. 2
0
        /// <summary>
        /// This is a shortcut, will get a VFX of the given type and will place it at the given position
        /// </summary>
        /// <param name="type">The type of VFX wanted. This enum will be generated by a tool in the Editor based on the VFXDatabase entries</param>
        /// <param name="position">Where the VFX will be placed</param>
        /// <returns>The Instance it just placed, can be useful if the effect isn't auto-disabled (e.g. looping effect)</returns>
        public static VFXInstance PlayVFX(VFXType type, Vector3 position)
        {
            var _vfx = GetVFX(type);

            _vfx.Effect.gameObject.transform.position = position;
            return(_vfx);
        }
Esempio n. 3
0
    public GameObject Create(
        VFXType type,
        Transform parent = null)
    {
        GameObject prefab = _getFXPrefab(type);

        Assert.IsNotNull(prefab);

        return(Instantiate <GameObject>(prefab, parent, false));
    }
Esempio n. 4
0
    private GameObject _getFXPrefab(VFXType type)
    {
        switch (type)
        {
        case VFXType.CARD_HOVER:    return(cardHover);

        case VFXType.CARD_SLAM:     return(cardSlam);
        }

        return(null);
    }
Esempio n. 5
0
    public void SpawnEffect(VFXType vfxType, Vector3 position, Vector3 direction, int team)
    {
        EmitParams param = new EmitParams()
        {
            position      = position,
            velocity      = direction * directionMult,
            startLifetime = 0             // Particle will immediately die, spawning its sub emitters
        };

        pS[IndexFromVFXType(vfxType)].Emit(param, 1);
    }
Esempio n. 6
0
 public void StartParticleSystem(VFXType type, Vector3 position, Quaternion rotation, Transform root)
 {
     foreach (var vfxData in _vfxsData)
     {
         if (vfxData.Type == type)
         {
             var particleSystemInstance = Instantiate(vfxData.Prefab, position, rotation, root);
             particleSystemInstance.Play();
             Destroy(particleSystemInstance.gameObject, particleSystemInstance.main.duration);
         }
     }
 }
    public void SpawnVFX(GameObject VFXSourceGo, Vector3 pos, VFXType vfxType, Vector3 extraVel, float delayTime, float lifetime)
    {
        if (delayTime == 0)
        {
            //If same type of vfx happen too fast and multiple times in the same spot then only spawn one of them at this moment
            if (lastVFXSnapshots.ContainsKey(vfxType) && (lastVFXSnapshots[vfxType].pos - pos).magnitude < 0.05f && Time.time - lastVFXSnapshots[vfxType].time < smallestSameSpotVFXTimeInterval)
            {
                return;
            }

            //Record a specific vfx's snapshot
            if (lastVFXSnapshots.ContainsKey(vfxType))
            {
                lastVFXSnapshots[vfxType] = new VFXSnapshot()
                {
                    time = Time.time, pos = pos
                };
            }
            else
            {
                lastVFXSnapshots.Add(vfxType, new VFXSnapshot()
                {
                    time = Time.time, pos = pos
                });
            }

            var go        = GameObject.Instantiate(VFXSourceGo, pos, Quaternion.identity);
            var partSyses = go.GetComponentsInChildren <ParticleSystem>();
            foreach (var pSys in partSyses)
            {
                var emisModule = pSys.emission;
                var bursts     = new ParticleSystem.Burst[emisModule.burstCount];
                emisModule.GetBursts(bursts);
                for (int i = 0; i < bursts.Length; i++)
                {
                    bursts[i].maxCount = (short)((float)bursts[i].maxCount * (1f + extraVel.magnitude * 0.5f));
                    bursts[i].minCount = (short)((float)bursts[i].minCount * (1f + extraVel.magnitude * 0.5f));
                }
                var main = pSys.main;
                main.startSpeedMultiplier = 1f + extraVel.magnitude;
            }

            Destroy(go, lifetime);
        }
        else if (delayTime > 0)
        {
            StartCoroutine(SpawnVFX_Delay(VFXSourceGo, pos, vfxType, extraVel, delayTime, lifetime));
        }
    }
Esempio n. 8
0
    private static VFX GetVFX(VFXType type)
    {
        int idx = (int)type;

        /*
         * if (Instance.m_Pool[idx].Count == 0)
         * {
         *  Instance.CreateNewInstances(idx);
         * }
         */
        var inst = Instance.m_Pool[idx].Dequeue();

        inst.effect.SetActive(true);
        Instance.m_Pool[idx].Enqueue(inst);
        return(inst);
    }
Esempio n. 9
0
        /// <summary>
        /// Return a VFXInstance of the given type. use instance.Effect to access the gameobject.
        /// It will be SetActive by the function, so you just have to place it.
        /// </summary>
        /// <param name="type">The type of VFX wanted. This enum will be generated by a tool in the Editor based on the VFXDatabase entries</param>
        /// <returns>The instance that was in front of the pool queue</returns>
        public static VFXInstance GetVFX(VFXType type)
        {
            int idx = (int)type;

            if (Instance.m_Instances[idx].Count == 0)
            {
                Instance.CreateNewInstances(idx);
            }

            //we put the instance from the from to the back of the queue. Perfect for one shot particle, it will have been
            //disabled before being back on front of the list
            var inst = Instance.m_Instances[idx].Dequeue();

            Instance.m_Instances[idx].Enqueue(inst);

            inst.Effect.gameObject.SetActive(true);
            return(inst);
        }
Esempio n. 10
0
    int IndexFromVFXType(VFXType vfxType)
    {
        switch (vfxType)
        {
        case VFXType.Hit_Normal:
            return(0);

        case VFXType.Hit_Absorbed:
            return(1);

        case VFXType.Hit_Near:
            return(2);

        case VFXType.Fighter_Die_Explode:
            return(3);

        default:
            return(0);
        }
    }
Esempio n. 11
0
 public static void PlayVFX(Vector3 pos, VFXType type)
 {
     int idx = -1;
     instance.poolMap.TryGetValue(type, out idx);
     instance.pools[idx].playVFX(pos);
 }
    IEnumerator SpawnVFX_Delay(GameObject VFXSourceGo, Vector3 pos, VFXType vfxType, Vector3 extraVel, float delayTime, float lifetime)
    {
        yield return(new WaitForSeconds(delayTime));

        SpawnVFX(VFXSourceGo, pos, vfxType, extraVel, 0, lifetime);
    }
Esempio n. 13
0
 public OnVFXPlay(Vector3 pos, VFXType type)
 {
     Pos  = pos;
     Type = type;
 }
Esempio n. 14
0
 public void SpawnEffect(VFXType vfxType, Vector3 position)
 {
     SpawnEffect(vfxType, position, Vector3.up, -1);
 }
Esempio n. 15
0
    public void Anim_VFX(VFXType type)
    {
        GameObject vfx = LoadManager.Instance.GetVFX(type);

        Instantiate(vfx, transform.position, Quaternion.identity);
    }