示例#1
0
		public void CreateSplash( WaterPlaneType.SplashTypes splashType, Vec3 pos )
		{
			//get items array for this alias
			WaterPlaneType.SplashItem[] items = GetSplashItemsByType( splashType );
			if( items.Length == 0 )
				return;

			//random choose item
			WaterPlaneType.SplashItem item = items[ World.Instance.Random.Next( items.Length ) ];

			//create particle systems
			foreach( WaterPlaneType.SplashItem.ParticleItem particleItem in item.Particles )
			{
				Map.Instance.CreateAutoDeleteParticleSystem( particleItem.ParticleName, pos, Quat.Identity,
					new Vec3( particleItem.Scale, particleItem.Scale, particleItem.Scale ) );
			}

			//play sound
			if( !string.IsNullOrEmpty( item.SoundName ) )
			{
				Sound sound = SoundWorld.Instance.SoundCreate( item.SoundName, SoundMode.Mode3D );
				if( sound != null )
				{
					VirtualChannel channel = SoundWorld.Instance.SoundPlay( sound,
						EngineApp.Instance.DefaultSoundChannelGroup, .5f, true );
					if( channel != null )
					{
						channel.Position = pos;
						switch( Type.SoundRolloffMode )
						{
						case WaterPlaneType.SoundRolloffModes.Logarithmic:
							channel.SetLogarithmicRolloff( Type.SoundMinDistance, Type.SoundMaxDistance,
								Type.SoundRolloffLogarithmicFactor );
							break;
						case WaterPlaneType.SoundRolloffModes.Linear:
							channel.SetLinearRolloff( Type.SoundMinDistance, Type.SoundMaxDistance );
							break;
						}
						channel.Pause = false;
					}
				}
			}

			if( EntitySystemWorld.Instance.IsServer() )
				Server_SendCreateSplashToAllClients( splashType, pos );
		}
示例#2
0
		void Server_SendCreateSplashToAllClients( WaterPlaneType.SplashTypes splashType, Vec3 pos )
		{
			SendDataWriter writer = BeginNetworkMessage( typeof( WaterPlane ),
				(ushort)NetworkMessages.CreateSplashToClient );
			writer.WriteVariableUInt32( (uint)splashType );
			writer.Write( pos );
			EndNetworkMessage();
		}
示例#3
0
		WaterPlaneType.SplashItem[] GetSplashItemsByType( WaterPlaneType.SplashTypes splashType )
		{
			if( splashItemsCache == null )
				splashItemsCache = new Dictionary<WaterPlaneType.SplashTypes, WaterPlaneType.SplashItem[]>();

			WaterPlaneType.SplashItem[] items;
			if( !splashItemsCache.TryGetValue( splashType, out items ) )
			{
				items = Type.Splashes.FindAll( delegate( WaterPlaneType.SplashItem item )
				{
					return item.SplashType == splashType;
				} ).ToArray();
				splashItemsCache.Add( splashType, items );
			}
			return items;
		}