예제 #1
0
        public void makeItRain(int startTime, int iterations)
        {
            // MAKE IT RAIN, BOYS
            // startTime: When do you want it to start?
            // iterations: How many times do you want the drops to wrap?

            // Does the collision map need to be updated?
            // Check if the list is not empty. If it's not empty, check the head's time
            // to see if it needs to be updated. After a successful update, pop the head.

            int iterationCount = 0;
            int timeElapsed    = 0;

            while (iterationCount < iterations)
            {
                // Something to consider for the regionList
                if (regionList.Count != 0)
                {
                    // Now check if we're at the correct time to trigger this.
                    if (startTime + timeElapsed >= regionList[0].startTime)
                    {
                        // Update the map with the given path...
                        importMap(regionList[0].path);
                        // And remove the head.
                        regionList.RemoveAt(0);
                    }
                }

                // Something to consider for the shifting
                // We can only update in RAINDROP_VELOCITY snapshots
                if (shiftList.Count != 0)
                {
                    // Now check if we're at the correct time to trigger this
                    if (startTime + timeElapsed >= shiftList[0].startTime)
                    {
                        // Update the map with the corresponding shift.
                        // However, duration goes one-by-one so...
                        NoNoRegion.shiftMap(shiftList[0].tweenDistX, shiftList[0].tweenDistY, shiftList[0].wrappingFlag);

                        // Then update the duration counter.
                        // The duration counter works as iterations of RAINDROP_VELOCITY
                        shiftList[0].duration  -= 1;
                        shiftList[0].startTime += BeatmapConstants.RAINDROP_VELOCITY;
                        if (shiftList[0].duration <= 0)
                        {
                            // And if it's empty, remove the head.
                            shiftList.RemoveAt(0);
                        }
                    }
                }

                // Calling all droplets to duty.
                // The raindrop will only drop if our given time is an iteration based off RAINDROP_VELOCITY
                if (timeElapsed % BeatmapConstants.RAINDROP_VELOCITY == 0)
                {
                    for (int x2 = 0; x2 < cloud.Length; x2++)
                    {
                        cloud[x2].drop(startTime + timeElapsed + rng.Next(BeatmapConstants.DROP_VARIANCE * -1, BeatmapConstants.DROP_VARIANCE),
                                       rng.Next(BeatmapConstants.SCREEN_LEFT, BeatmapConstants.SCREEN_RIGHT),
                                       BeatmapConstants.SCREEN_TOP - BeatmapConstants.SCREEN_TOP_OFFSET,
                                       NoNoRegion,
                                       false);
                    }
                    // Increment the iteration count.
                    iterationCount++;
                }

                // Queue for the next wrap.
                timeElapsed++;
            }
        }