예제 #1
0
파일: Storm.cs 프로젝트: sodomon2/dwarfcorp
        public void Start()
        {
            World.MakeAnnouncement("A storm is coming!", null);

            switch (TypeofStorm)
            {
            case StormType.RainStorm:
                SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_rain_storm_alert, 0.15f);
                break;

            case StormType.SnowStorm:
                SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_snow_storm_alert, 0.15f);
                break;
            }

            BoundingBox bounds         = World.ChunkManager.Bounds;
            Vector3     extents        = bounds.Extents();
            Vector3     center         = bounds.Center();
            Vector3     windNormalized = WindSpeed / WindSpeed.Length();
            Vector3     offset         = new Vector3(-windNormalized.X * extents.X + center.X, bounds.Max.Y + 5, -windNormalized.Z * extents.Z + center.Z);
            Vector3     perp           = new Vector3(-windNormalized.Z, 0, windNormalized.X);
            int         numClouds      = (int)(MathFunctions.RandInt(10, 100) * Intensity);
            int         numCloudLayers = MathFunctions.RandInt(1, 5);

            for (int layer = 0; layer < numCloudLayers; layer++)
            {
                for (int i = 0; i < numClouds; i++)
                {
                    Vector3 cloudPos = offset + perp * 5 * (i - numClouds / 2) + MathFunctions.RandVector3Cube() * 10 + windNormalized * 2 * layer;

                    Cloud cloud = new Cloud(World.ComponentManager, Intensity, 5, offset.Y + MathFunctions.Rand(-3.0f, 3.0f), cloudPos, TypeofStorm == StormType.RainStorm ? 0.15f : 0.0f)
                    {
                        Velocity    = WindSpeed * 0.5f,
                        TypeofStorm = TypeofStorm
                    };
                    Clouds.Add(cloud);
                    World.ComponentManager.RootComponent.AddChild(cloud);
                }
            }
            IsInitialized = true;
        }
예제 #2
0
            public void Start()
            {
                World.MakeAnnouncement("A storm is coming!", null);
                BoundingBox bounds         = World.ChunkManager.Bounds;
                Vector3     extents        = bounds.Extents();
                Vector3     center         = bounds.Center();
                Vector3     windNormalized = WindSpeed / WindSpeed.Length();
                Vector3     offset         = new Vector3(-windNormalized.X * extents.X + center.X, bounds.Max.Y + 5, -windNormalized.Z * extents.Z + center.Z);
                Vector3     perp           = new Vector3(-windNormalized.Z, 0, windNormalized.X);
                int         numClouds      = (int)(MathFunctions.RandInt(10, 100) * Intensity);

                for (int i = 0; i < numClouds; i++)
                {
                    Vector3 cloudPos = offset + perp * 5 * (i - numClouds / 2) + MathFunctions.RandVector3Cube() * 10;

                    Cloud cloud = new Cloud(World.ComponentManager, Intensity, 5, offset.Y + MathFunctions.Rand(-3.0f, 3.0f), cloudPos)
                    {
                        Velocity    = WindSpeed,
                        TypeofStorm = TypeofStorm
                    };
                }
                IsInitialized = true;
            }