// spawn ExplosionFX
    public ParticleFX spawnExplosionFX(Vector3 position)
    {
        ParticleFX fx = m_ExplosionFXsPool.spawn(position, transform);

        fx.Setpool(m_ExplosionFXsPool);
        return(fx);
    }
示例#2
0
 void InstantiateParticle(ParticleFX FX)
 {
     if (FX != null && FX.particle != null)
     {
         Instantiate(FX.particle, transform.position + FX.positionOffset, Quaternion.identity, transform);
     }
 }
    // spawn HitFX
    public ParticleFX spawnHitFX(Vector3 position)
    {
        ParticleFX fx = m_hitFxPool.spawn(position, transform);

        fx.Setpool(m_hitFxPool);
        return(fx);
    }
示例#4
0
        public void FireWeapon()
        {
            recoiler.StartRecoil();

            RaycastHit hit;
            Ray        ray       = new Ray(rayOrigin.position, rayOrigin.forward);
            bool       hitTarget = Physics.Raycast(ray, out hit, behavior.maxDistance, behavior.hitMask, QueryTriggerInteraction.Ignore);

            Quaternion lookRotation = hitTarget ? Quaternion.LookRotation(hit.normal) : Quaternion.identity;
            Vector3    endPoint     = hitTarget ? hit.point : ray.origin + ray.direction * behavior.maxDistance;

            // if (onFireGun != null) {
            //     onFireGun(ray.origin, endPoint, hitTarget ? hit.transform : null);
            // }

            // eventPlayer["HitTarget"].SetValue(hitTarget);

            // if (hitTarget) {
            //     //set hit target type (blood, concrete, wood, etc...)
            //     eventPlayer["HitTargetTag"].SetValue(hit.transform.tag);
            // }

            // AssetObjectsPacks.Playlist.InitializePerformance("shoot", behavior.shootEvent, eventPlayer, false, 0, new MiniTransform(endPoint, lookRotation), true, null);
            // AssetObjectsPacks.Playlist.InitializePerformance("muzzleflash", behavior.secondaryEvent, eventPlayer, false, 1, new MiniTransform( muzzleTransform, true ), true, null);

            ParticleFX muzzleFlashInstance = ParticleFX.PlayParticlesPrefab(DecideMuzzleFlashFX(), muzzleTransform.position, muzzleTransform.rotation, behavior.muzzleFlashSpeed, behavior.muzzleFlashSize);

            ParticleFX tracerInstance = ParticleFX.PlayParticlesPrefab(DecideTracerFX(), muzzleTransform.position, Quaternion.LookRotation(endPoint - muzzleTransform.position), behavior.tracerSpeed, behavior.tracerSize);

            if (shellEjectTransform != null)
            {
                ParticleFX shellsInstance = ParticleFX.PlayParticlesPrefab(DecideShellEjectFX(), shellEjectTransform.position, shellEjectTransform.rotation, behavior.shellEjectSpeed, behavior.shellEjectSize);
            }

            if (hitTarget)
            {
                ParticleFX impactInstance = ParticleFX.PlayParticlesPrefab(DecideImpactFX(hit.transform), endPoint, lookRotation, behavior.impactSpeed, behavior.impactSize);


                // Debug.LogError("hit " + hit.transform.name);

                ActorElement actorElement = hit.transform.GetComponent <ActorElement>();

                if (actorElement != null)
                {
                    actorElement.OnDamageReceive(ray.origin, hit.transform, behavior.damage, behavior.severity);
                }


                //add rb force
                Rigidbody rb = hit.transform.GetComponent <Rigidbody>();
                if (rb != null)
                {
                    rb.AddForceAtPosition(ray.direction.normalized * behavior.force, hit.point, ForceMode.VelocityChange);
                }
            }
        }
 public void release(ParticleFX obj)
 {
     if (activeobjs.Contains(obj))
     {
         activeobjs.Remove(obj);
         inActiveobjs.Add(obj);
         obj.gameObject.SetActive(false);
     }
 }
示例#6
0
        ParticleFX DecideImpactFX(Transform hitTransform)
        {
            ParticleFX particlesToUse = behavior.gunFX.impacts.GetParticleFX(hitTransform);

            if (particlesToUse == null)
            {
                particlesToUse = combatSettings.gunFX.impacts.GetParticleFX(hitTransform);
            }
            return(particlesToUse);
        }
 //xoa cac ativeobj
 public void Clear()
 {
     while (activeobjs.Count > 0)
     {
         ParticleFX obj = activeobjs[0];
         obj.gameObject.SetActive(false);
         activeobjs.RemoveAt(0);
         inActiveobjs.Add(obj);
     }
 }
    public List <ParticleFX> activeobjs;    //chua cac danh sach enemy dang su dung

    //spawn cac obj when using
    public ParticleFX spawn(Vector3 position, Transform parent)
    {
        if (inActiveobjs.Count == 0)
        {
            ParticleFX newObj = GameObject.Instantiate(m_ParticleFXPrefabs, parent);
            newObj.transform.position = position;
            activeobjs.Add(newObj);
            return(newObj);
        }
        else
        {
            ParticleFX oldObj = inActiveobjs[0];
            oldObj.gameObject.SetActive(true);
            oldObj.transform.SetParent(parent);
            oldObj.transform.position = position;
            activeobjs.Add(oldObj);
            inActiveobjs.RemoveAt(0);
            return(oldObj);
        }
    }
 public void ReleaseHitFX(ParticleFX obj)
 {
     m_hitFxPool.release(obj);
 }