Exemplo n.º 1
0
        public void InitTankFrictionSound(NodeAddedEvent evt, [Combine] InitialTankFrictionSoundNode tank, SingleNode <SoundListenerBattleStateComponent> soundListener)
        {
            Transform soundRootTransform = tank.tankSoundRoot.SoundRootTransform;
            TankFrictionSoundEffectComponent tankFrictionSoundEffect = tank.tankFrictionSoundEffect;
            SoundController metallFrictionSourcePrefab  = tankFrictionSoundEffect.MetallFrictionSourcePrefab;
            SoundController stoneFrictionSourcePrefab   = tankFrictionSoundEffect.StoneFrictionSourcePrefab;
            SoundController frictionContactSourcePrefab = tankFrictionSoundEffect.FrictionContactSourcePrefab;

            tankFrictionSoundEffect.MetallFrictionSourceInstance  = this.InitSoundTransforms(metallFrictionSourcePrefab, soundRootTransform);
            tankFrictionSoundEffect.StoneFrictionSourceInstance   = this.InitSoundTransforms(stoneFrictionSourcePrefab, soundRootTransform);
            tankFrictionSoundEffect.FrictionContactSourceInstance = this.InitSoundTransforms(frictionContactSourcePrefab, soundRootTransform);
            GameObject gameObject = tank.tankFrictionMarker.gameObject;
            TankFrictionSoundBehaviour behaviour = gameObject.AddComponent <TankFrictionSoundBehaviour>();

            gameObject.layer = Layers.FRICTION;
            behaviour.Init(tank.Entity);
            float halfLength = tank.tankColliders.BoundsCollider.bounds.size.z * 0.5f;
            TankFrictionCollideSoundBehaviour behaviour2 = tank.tankCollision.gameObject.AddComponent <TankFrictionCollideSoundBehaviour>();

            behaviour2.Init(tank.tankFrictionSoundEffect.FrictionContactSourceInstance, tank.rigidbody.Rigidbody, halfLength, tank.tankFallingSoundEffect.MinPower, tank.tankFallingSoundEffect.MaxPower);
            TankFrictionSoundEffectReadyComponent component = new TankFrictionSoundEffectReadyComponent {
                TankFrictionCollideSoundBehaviour = behaviour2,
                TankFrictionSoundBehaviour        = behaviour
            };

            tank.Entity.AddComponent(component);
        }
Exemplo n.º 2
0
        public void PlayTankFrictionSound(UpdateEvent evt, ReadyActiveTankFrictionSoundNode tank)
        {
            TankFrictionSoundBehaviour tankFrictionSoundBehaviour = tank.tankFrictionSoundEffectReady.TankFrictionSoundBehaviour;

            if (tankFrictionSoundBehaviour.TriggerStay)
            {
                TankFrictionSoundEffectComponent tankFrictionSoundEffect = tank.tankFrictionSoundEffect;
                Collider frictionCollider = tankFrictionSoundBehaviour.FrictionCollider;
                if (frictionCollider == null)
                {
                    this.StopSounds(tankFrictionSoundEffect);
                }
                else
                {
                    Vector3 velocity = tank.rigidbody.Rigidbody.velocity;
                    if (frictionCollider.gameObject.layer == Layers.FRICTION)
                    {
                        this.SetMetallFriction(tankFrictionSoundEffect, velocity);
                    }
                    else
                    {
                        DustEffectBehaviour effect = tank.collisionDust.CollisionDustBehaviour.Effect;
                        if (effect == null)
                        {
                            this.StopSounds(tankFrictionSoundEffect);
                        }
                        else
                        {
                            DustEffectBehaviour.SurfaceType surface = effect.surface;
                            if (surface == DustEffectBehaviour.SurfaceType.Metal)
                            {
                                this.SetMetallFriction(tankFrictionSoundEffect, velocity);
                            }
                            else if (surface != DustEffectBehaviour.SurfaceType.Concrete)
                            {
                                this.StopSounds(tankFrictionSoundEffect);
                            }
                            else
                            {
                                this.SetStoneFriction(tankFrictionSoundEffect, velocity);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void StopTankFrictionSound(TankFrictionExitEvent evt, ReadyTankFrictionSoundNode tank)
        {
            TankFrictionSoundEffectComponent tankFrictionSoundEffect = tank.tankFrictionSoundEffect;

            this.StopSounds(tankFrictionSoundEffect);
        }
Exemplo n.º 4
0
 private void StopSounds(TankFrictionSoundEffectComponent tankFrictionSoundEffect)
 {
     tankFrictionSoundEffect.MetallFrictionSourceInstance.FadeOut();
     tankFrictionSoundEffect.StoneFrictionSourceInstance.FadeOut();
 }
Exemplo n.º 5
0
 private void SetStoneFriction(TankFrictionSoundEffectComponent tankFrictionSoundEffect, Vector3 velocity)
 {
     this.SetFriction(tankFrictionSoundEffect.StoneFrictionSourceInstance, tankFrictionSoundEffect.MetallFrictionSourceInstance, tankFrictionSoundEffect, velocity);
 }
Exemplo n.º 6
0
        private void SetFrictionVolume(SoundController sound, TankFrictionSoundEffectComponent tankFrictionSoundEffect, Vector3 velocity)
        {
            float minValuableFrictionPower = tankFrictionSoundEffect.MinValuableFrictionPower;

            this.SetVolumeByVelocity(sound, velocity, minValuableFrictionPower, tankFrictionSoundEffect.MaxValuableFrictionPower);
        }
Exemplo n.º 7
0
 private void SetFriction(SoundController actualSource, SoundController stopSource, TankFrictionSoundEffectComponent tankFrictionSoundEffect, Vector3 velocity)
 {
     this.SetFrictionVolume(actualSource, tankFrictionSoundEffect, velocity);
     actualSource.FadeIn();
     stopSource.FadeOut();
 }