Esempio n. 1
0
        private void TryEmitFromSuspensionRay(float maxCompression, Track track, MapDustComponent mapDust, float[] delays, int i)
        {
            SuspensionRay ray = track.rays[i];
            float         num = delays[i] - UnityTime.deltaTime;

            if (!ray.hasCollision)
            {
                delays[i] = num;
            }
            else
            {
                RaycastHit          rayHit      = ray.rayHit;
                Transform           target      = rayHit.transform;
                DustEffectBehaviour effectByTag = mapDust.GetEffectByTag(target, rayHit.textureCoord);
                if (effectByTag == null)
                {
                    delays[i] = num;
                }
                else
                {
                    Vector3 point = rayHit.point;
                    if (num <= 0f)
                    {
                        num = 1f / effectByTag.movementEmissionRate.RandomValue;
                        effectByTag.TryEmitParticle(point, ray.velocity);
                        delays[i] = num;
                    }
                    else
                    {
                        if (!ray.hadPreviousCollision)
                        {
                            float num2 = Mathf.Clamp01(ray.compression / maxCompression);
                            if (num2 > effectByTag.landingCompressionThreshold)
                            {
                                effectByTag.TryEmitParticle(point, Vector3.up * (effectByTag.movementSpeedThreshold.max * num2));
                            }
                        }
                        delays[i] = num;
                    }
                }
            }
        }
Esempio n. 2
0
 public void TryEmitFromTracks(UpdateEvent evt, TrackDustUpdateNode tankNode, [JoinAll] SingleNode <MapDustComponent> mapDustNode)
 {
     if (tankNode.cameraVisibleTrigger.IsVisibleAtRange(30f))
     {
         TrackComponent         component     = tankNode.track;
         TrackDustComponent     trackDust     = tankNode.trackDust;
         ChassisConfigComponent chassisConfig = tankNode.chassisConfig;
         float            maxRayLength        = chassisConfig.MaxRayLength;
         Track            leftTrack           = component.LeftTrack;
         Track            rightTrack          = component.RightTrack;
         MapDustComponent mapDust             = mapDustNode.component;
         float[]          leftTrackDustDelay  = trackDust.leftTrackDustDelay;
         float[]          rightTrackDustDelay = trackDust.rightTrackDustDelay;
         int numRaysPerTrack = chassisConfig.NumRaysPerTrack;
         for (int i = 0; i < numRaysPerTrack; i += 2)
         {
             this.TryEmitFromSuspensionRay(maxRayLength, leftTrack, mapDust, leftTrackDustDelay, i);
             this.TryEmitFromSuspensionRay(maxRayLength, rightTrack, mapDust, rightTrackDustDelay, i);
         }
     }
 }
        private AudioSource PrepareAudioSource(TankFallEvent evt, TankFallingSoundEffectComponent tankFallingSoundEffect, MapDustComponent mapDust, Transform root)
        {
            AudioSource collisionSourceAsset;

            switch (evt.FallingType)
            {
            case TankFallingType.TANK:
            case TankFallingType.VERTICAL_STATIC:
                collisionSourceAsset = tankFallingSoundEffect.CollisionSourceAsset;
                break;

            case TankFallingType.FLAT_STATIC:
            case TankFallingType.SLOPED_STATIC_WITH_TRACKS:
                collisionSourceAsset = tankFallingSoundEffect.FallingSourceAsset;
                break;

            case TankFallingType.SLOPED_STATIC_WITH_COLLISION:
            {
                DustEffectBehaviour effectByTag = mapDust.GetEffectByTag(evt.FallingTransform, Vector2.zero);
                if (effectByTag == null)
                {
                    collisionSourceAsset = tankFallingSoundEffect.FallingSourceAsset;
                }
                else
                {
                    DustEffectBehaviour.SurfaceType surface = effectByTag.surface;
                    collisionSourceAsset = ((surface == DustEffectBehaviour.SurfaceType.Metal) || (surface == DustEffectBehaviour.SurfaceType.Concrete)) ? tankFallingSoundEffect.CollisionSourceAsset : tankFallingSoundEffect.FallingSourceAsset;
                }
                break;
            }

            default:
                throw new ArgumentException("Illegal type of falling");
            }
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = collisionSourceAsset.gameObject,
                AutoRecycleTime = ((collisionSourceAsset != tankFallingSoundEffect.FallingSourceAsset) ? collisionSourceAsset.clip : this.GetFallingAudioClip(tankFallingSoundEffect)).length + 0.2f
            };

            base.ScheduleEvent(eventInstance, new EntityStub());
            Transform   instance  = eventInstance.Instance;
            AudioSource component = instance.GetComponent <AudioSource>();

            instance.parent        = root;
            instance.localPosition = Vector3.zero;
            instance.localRotation = Quaternion.identity;
            instance.gameObject.SetActive(true);
            component.Play();
            return(component);
        }