public void ShakeOnFalling(TankFallEvent evt, SelfTankNode tank, [JoinAll] CameraShakerFallingNode cameraShaker, [JoinAll] SingleNode <GameCameraShakerSettingsComponent> settings, [JoinAll] SingleNode <MainHUDComponent> hud) { float fallingPower = evt.FallingPower; float minFallingPower = cameraShaker.tankFallingCameraShakerConfig.MinFallingPower; float maxFallingPower = cameraShaker.tankFallingCameraShakerConfig.MaxFallingPower; float weakeningCoeff = Mathf.Clamp01((fallingPower - minFallingPower) / (maxFallingPower - minFallingPower)); cameraShaker.cameraShaker.ShakeByFalling(settings.component, cameraShaker.tankFallingCameraShakerConfig, weakeningCoeff); if (fallingPower >= cameraShaker.tankFallingCameraShakerConfig.MinFallingPowerForHUD) { hud.component.battleHudRoot.ShakeHUDOnFalling(settings.component, cameraShaker.tankFallingCameraShakerConfig); } }
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); }
public void PlayFallingSound(TankFallEvent evt, TankFallingSoundEffectNode tank, [JoinAll] SingleNode <MapDustComponent> map) { TankFallingSoundEffectComponent tankFallingSoundEffect = tank.tankFallingSoundEffect; float minPower = tankFallingSoundEffect.MinPower; float maxPower = tankFallingSoundEffect.MaxPower; float num4 = Mathf.Clamp01((evt.FallingPower - minPower) / (maxPower - minPower)); if ((num4 > 0f) && (evt.FallingType != TankFallingType.NOTHING)) { Transform soundRootTransform = tank.tankSoundRoot.SoundRootTransform; AudioSource source = this.PrepareAudioSource(evt, tankFallingSoundEffect, map.component, soundRootTransform); source.volume = num4; source.Play(); } }
public void PlayEffect(NodeAddedEvent e, ExplosiveMassEffectNode effectNode, [JoinByTank] TankNode tank) { GameObject explosiveMassEffect = tank.moduleVisualEffectObjects.ExplosiveMassEffect; if (!explosiveMassEffect.activeInHierarchy) { explosiveMassEffect.transform.position = tank.rigidbody.RigidbodyTransform.position; explosiveMassEffect.SetActive(true); } TankFallEvent eventInstance = new TankFallEvent { FallingPower = 100f, FallingType = TankFallingType.NOTHING }; base.NewEvent(eventInstance).Attach(tank).ScheduleDelayed(((float)effectNode.explosiveMassEffect.Delay) / 1000f); }
public void EnableEffect(NodeAddedEvent e, ExternalImpactEffectNode effectNode, [JoinByTank] TankNode tank, [JoinAll] SelfTankNode selfTank) { GameObject externalImpactEffect = tank.moduleVisualEffectObjects.ExternalImpactEffect; if (!externalImpactEffect.activeInHierarchy) { externalImpactEffect.transform.position = tank.rigidbody.RigidbodyTransform.position; externalImpactEffect.SetActive(true); } base.ScheduleEvent <StartSplashEffectEvent>(effectNode); TankFallEvent eventInstance = new TankFallEvent { FallingPower = 100f, FallingType = TankFallingType.NOTHING }; base.ScheduleEvent(eventInstance, selfTank); }
private void ApplyFall(Entity tankEntity, Vector3 previousVelocity, TankFallingComponent tankFalling, TrackComponent track, ChassisConfigComponent chassisConfig, TankCollisionComponent tankCollision, RigidbodyComponent rigidbody, bool fallingByTrack) { if ((tankFalling != null) && (!tankFalling.IsGrounded && rigidbody.Rigidbody)) { bool flag; Vector3 planeNormal = this.GetFallingNrm(fallingByTrack, track, chassisConfig, tankCollision, out flag); Vector3 vector2 = Vector3.ProjectOnPlane(previousVelocity, planeNormal); Vector3 position = rigidbody.Rigidbody.transform.position; TankFallingType type = this.DefineFallingCollisionMode(flag, fallingByTrack, planeNormal); TankFallEvent eventInstance = new TankFallEvent { FallingPower = (previousVelocity - vector2).sqrMagnitude, FallingType = type, Velocity = previousVelocity }; if ((type == TankFallingType.SLOPED_STATIC_WITH_COLLISION) && this.CheckTankCollisionNotNull(tankCollision)) { eventInstance.FallingTransform = tankCollision.Collision.transform; } base.ScheduleEvent(eventInstance, tankEntity); tankFalling.IsGrounded = true; } }