//Methods
        public void PlayOneShot(SurfaceOutput output, AudioSource audioSource, float volumeMultiplier = 1, float pitchMultiplier = 1)
        {
            var vol   = volumeMultiplier * output.volumeMultiplier * output.weight;
            var pitch = pitchMultiplier * output.pitchMultiplier;

            surfaceTypeSounds[output.surfaceTypeID].PlayOneShot(audioSource, vol, pitch);
        }
예제 #2
0
        public void PlayParticles(SurfaceOutputs outputs, SurfaceOutput output, Color selfColor, float impulse, Vector3 vel, float mass, float radius = 0, float deltaTime = 0.25f)
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif

            Particles[] ps = GetSurfaceParticles(output);

            for (int i = 0; i < ps.Length; i++)
            {
                var p = ps[i];

                var rot      = Quaternion.FromToRotation(Vector3.forward, outputs.hitNormal);
                var otherVel = Utility.GetVelocityMass(outputs.collider.attachedRigidbody, outputs.hitPosition, out Vector3 centerVel1, out float mass1);
                var speed    = (otherVel - vel).magnitude;
                p.particles.GetInstance().PlayParticles
                (
                    p.originType,
                    selfColor, output.color,
                    output.selfParticleMultipliers * p.selfMultipliers, output.otherParticleMultipliers * p.otherMultipliers,
                    1,
                    impulse, speed,
                    rot, outputs.hitPosition, radius, outputs.hitNormal,
                    vel, otherVel,
                    mass, mass1,
                    dt: deltaTime
                );
            }
        }
예제 #3
0
        //Methods
        public Particles[] GetSurfaceParticles(SurfaceOutput o)
        {
            if (o.particleOverrides != null)
            {
                var sps = o.particleOverrides.Get(ref o, this);
                if (sps != null)
                {
                    return(sps);
                }
            }

            var stp = surfaceTypeParticles[o.surfaceTypeID];

            return(stp.particles);
        }
        private void AddSingleOutput(int stID, SurfaceType st, SurfaceType.SubType subType)
        {
            outputs.hardness = st.hardnessMultiplier;

            var so = new SurfaceOutput()
            {
                surfaceTypeID            = stID,
                weight                   = 1,
                volumeMultiplier         = subType.settings.volumeMultiplier,
                pitchMultiplier          = subType.settings.pitchMultiplier,
                particleOverrides        = null,
                color                    = st.defaultColorTint * subType.settings.defaultColor,
                selfParticleMultipliers  = ParticleMultipliers.Default(),
                otherParticleMultipliers = ParticleMultipliers.Default(),
            };

            outputs.Add(so);
        }
예제 #5
0
        //Methods
        public Particles[] Get(ref SurfaceOutput output, SurfaceParticleSet particleSet) //, out bool flipSelf, out bool isBoth
        {
            for (int i = 0; i < overrides.Length; i++)
            {
                var o = overrides[i];
                if (o.particleSet == particleSet)
                {
                    //output.selfParticleMultipliers *= o.selfMultipliers; // // //Note that these are flipped!:
                    //output.otherParticleMultipliers *= o.otherMultipliers;
                    //flipSelf = o.flipSelf;
                    //isBoth = o.isBoth;
                    return(o.particles);
                }
            }

            //flipSelf = false;
            //isBoth = false;
            return(null);
        }