示例#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);
        }
示例#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);
                            }
                        }
                    }
                }
            }
        }