Ejemplo n.º 1
0
        /// <summary>
        /// Zooms the gameplay to imitate Intralism's zoom method.
        /// </summary>
        /// <param name="gameplayEngine">The gameplay engine to modify.</param>
        private void HandleIntralizooms(GameplayEngine gameplayEngine)
        {
            FindNextEvent(gameplayEngine);

            // If the next event is less than the current time
            // then deactivate this event as it is no longer needed.

            // This is similar to how Intralism handles PlayerDistance, where it has a
            // local PlayerDistance that is what the player sees, and a semi-constant "PlayerDistance"
            // That is changed by the most recent SetPlayerDistance map event.
            Active = !(nextEvent != null && nextEvent.Time < gameplayEngine.Time);

            // Get smoothDeltaTime and return if there was no change in deltaTime
            double smoothDeltaTime = PulsarcTime.SmoothDeltaTime;

            if (smoothDeltaTime == 0 || !Active)
            {
                return;
            }

            // Resize the crosshair
            gameplayEngine.Crosshair.Resize(
                PulsarcMath.Lerp(
                    // Starting position (current position)
                    currentZoomLevel,
                    // Ending position (zoomLevel)
                    ZoomLevel,
                    // Amount to lerp by (Pulsarc: deltaTime(ms) / 200 = Intralism: deltaTime(s) * 5)
                    (float)smoothDeltaTime / 200f));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Perform the actions this ZoomEvent is assigned to.
        /// </summary>
        /// <param name="gameplayEngine">The currently playing Gameplay Engine to modify the zoom of.</param>
        /// <exception cref="WrongEventTypeException"></exception>
        public override void Handle(GameplayEngine gameplayEngine)
        {
            // if the startZoomLevel hasn't been set, set it now.
            if (startZoomLevel == -1)
            {
                startZoomLevel = gameplayEngine.Crosshair.Diameter;
            }

            currentZoomLevel = gameplayEngine.Crosshair.Diameter;

            // Use the correct handling method depending on this
            // ZoomEvent's ZoomType
            switch (ZoomType)
            {
            case ZoomType.Intralizoom:
                HandleIntralizooms(gameplayEngine);
                break;

            case ZoomType.Step:
                HandleStepZoom(gameplayEngine);
                break;

            case ZoomType.Linear:
                HandleLinearZooms(gameplayEngine);
                break;

            default:
                throw new WrongEventTypeException($"Invalid zoom type! ZoomTypes can be from -1 to 1, and the type called was {(int)ZoomType}!");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// When clicked, start playing the beatmap.
        /// </summary>
        public void OnClick()
        {
            // If already selected, start a game.
            if (IsSelected)
            {
                GameplayEngine gameplay = new GameplayEngine();
                ScreenManager.AddScreen(gameplay);
                gameplay.Init(Beatmap);
            }
            // If newly selected, play the song.
            else
            {
                if (AudioManager.songPath == Beatmap.GetFullAudioPath())
                {
                    return;
                }

                AudioManager.songPath  = Beatmap.GetFullAudioPath();
                AudioManager.audioRate = Utils.Config.GetFloat("Gameplay", "SongRate");
                AudioManager.StartLazyPlayer();

                if (Beatmap.PreviewTime != 0)
                {
                    AudioManager.DeltaTime(Beatmap.PreviewTime);
                }

                //PulsarcLogger.Important($"Now Playing: {AudioManager.songPath}");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Currently not used. Keeping in case it proves useful in the future.
        /// Find all events in gameplayEngine that share the same type as this Event.
        /// </summary>
        /// <param name="gameplayEngine">The gameplayEngine to look through</param>
        protected void FindAllSimilarEvents(GameplayEngine gameplayEngine)
        {
            // Only need to call this once, inherited classes can set similarEventsCalled to false if they want to call again.
            if (similarEventsCalled)
            {
                return;
            }

            similarEvents       = gameplayEngine.CurrentBeatmap.Events.FindAll(SameEventType);
            similarEventsCalled = true;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Currently not used. Keeping in case it proves useful in the future.
        /// Find all events in gameplayEngine that share the same type as this Event
        /// and have a greater time than this event.
        /// </summary>
        /// <param name="gameplayEngine">The gameplayEngine to look through</param>
        protected void FindAllSimilarFutureEvents(GameplayEngine gameplayEngine)
        {
            if (futureEventsCalled)
            {
                return;
            }

            FindAllSimilarEvents(gameplayEngine);

            futureEvents       = similarEvents.FindAll(GreaterEventTime);
            futureEventsCalled = true;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Find the next event in gameplayEngine that shares the same type as this Event
        /// and has a greater time than this event.
        /// </summary>
        /// <param name="gameplayEngine">The gameplayEngine to look through</param>
        protected void FindNextEvent(GameplayEngine gameplayEngine)
        {
            if (foundNextEvent)
            {
                return;
            }

            FindAllSimilarEvents(gameplayEngine);

            nextEvent      = gameplayEngine.CurrentBeatmap.Events.Find(GreaterEventTime);
            foundNextEvent = true;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// This method is called when the RetryButton is clicked on, it restarts
        /// the map using the Beatmap provided.
        /// </summary>
        /// <param name="beatmap">The Beatmap to play.</param>
        public void OnClick(Beatmap beatmap)
        {
            // Remove current screen
            ScreenManager.RemoveScreen(true);

            // Make new gameplay screen using the beatmap provided.
            GameplayEngine gameplay = new GameplayEngine();

            gameplay.Init(beatmap);

            // Add the new gameplay screen.
            ScreenManager.AddScreen(gameplay);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Zooms the gameplay linearly from the starting position to the end position.
        /// </summary>
        /// <param name="gameplayEngine">The gameplay engine to modify.</param>
        private void HandleLinearZooms(GameplayEngine gameplayEngine)
        {
            // Find the amount of time between the activation time to the end time.
            double deltaTime = EndTime - Time;

            // Find the amount of zoom between the start zoom to the end zoom.
            float deltaZoom = ZoomLevel - startZoomLevel;

            // Find the amount of time between now and the event time
            double deltaCurrentTime = gameplayEngine.Time - Time;

            // Find the percentage of time that has past between the event time and the end time
            double zoomFactor = 1 - ((deltaTime - deltaCurrentTime) / deltaTime);

            // Find what the current zoom should be.
            float currentZoom = startZoomLevel + (deltaZoom * (float)zoomFactor);

            // If deltaZoom is negative, and currentZoom is less than ZoomLevel, then change currentZoom to ZoomLevel
            // If deltaZoom is positive, and currentZoom is greater than ZoomLevel, then change currentZoom to ZoomLevel
            // This makes sure zoom doesn't go over or under its intended level
            bool negative = deltaZoom < 0;

            if (negative && currentZoom < ZoomLevel)
            {
                currentZoom = ZoomLevel;
            }
            else if (!negative && currentZoom > ZoomLevel)
            {
                currentZoom = ZoomLevel;
            }

            // Resize the crosshair
            gameplayEngine.Crosshair.Resize(currentZoom);

            // Active as long as currentZoom hasn't reached zoom level
            // The above if-block makes sure that currentZoom will equal ZoomLevel eventually.
            Active = currentZoom != ZoomLevel;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// An abstract method for how this Event should act while it's being handled.
 /// </summary>
 /// <param name="gameplayEngine">The currently running GameplayEngine this event being handled in.</param>
 public abstract void Handle(GameplayEngine gameplayEngine);
Ejemplo n.º 10
0
 /// <summary>
 /// Zooms the gameplay instantaneously to this ZoomEvents zoom level
 /// </summary>
 /// <param name="gameplayEngine">The gameplay engine to modify.</param>
 private void HandleStepZoom(GameplayEngine gameplayEngine)
 {
     gameplayEngine.Crosshair.Resize(ZoomLevel);
     Active = false;
 }
Ejemplo n.º 11
0
 public override void Handle(GameplayEngine gameplayEngine)
 {
     throw new NotImplementedException();
 }