Update() public method

public Update ( ) : void
return void
Exemplo n.º 1
0
 private void Update()
 {
     _engine.Update();
     if (_playMusic)
     {
         _musicPlayer.Update();
     }
 }
Exemplo n.º 2
0
        private void Update()
        {
            MWEngine.Update();

            if (playMusic)
            {
                musicPlayer.Update();
            }
        }
Exemplo n.º 3
0
 public void Update(GameTime gameTime)
 {
     if (Game == null)
     {
         return;
     }
     ActiveSounds.UpdateSounds(gameTime);
     MusicPlayer.Update();
     FMOD.Error.Check(_system.update());
 }
Exemplo n.º 4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            MusicPlayer.Update(gameTime);
            fps.Update(gameTime);

            UserInterface.Active.Update(gameTime);

            MusicPlayer.MasterVolume = GameSettings.MasterVolume / 100f;
            MusicPlayer.MusicVolume  = (GameSettings.MusicVolume / 100f) * (MusicPlayer.MasterVolume);
            MusicPlayer.SFXVolume    = (GameSettings.EffectsVolume / 100f) * (MusicPlayer.MasterVolume);
        }
Exemplo n.º 5
0
    void Update()
    {
        MusicPlayer.Update();
        audioManager.Update();
        playerManager.Update();


        if (Input.GetKeyDown(KeyCode.R))
        {
            Restart();
        }
    }
Exemplo n.º 6
0
        protected override void Update(GameTime gameTime)
        {
            DeltaUpdate = gameTime.ElapsedGameTime.Milliseconds;

            this.screenPool.CallGuiControlUpdates(this);

            if (this.screenPool.screenState == ScreenPool.ScreenState.Playing)
            {
                this.levelData.Update(this);
                PlayerDataManager.Update();
                EnemyDrawer.UpdateTicks(Minijam32.DeltaUpdate);
            }

            musicPlayer.Update(this);

            base.Update(gameTime);
        }
Exemplo n.º 7
0
        public void StartGame()
        {
            Globals.TotalScore = 0;
            angleUpdate        = 0;
            _recordAchieved    = false;

            _player.Visible = true;
            _generator.Reset();
            _infoPanel.CurrentLevel         = _elemManager.Level = _generator.GenerateNext();
            _infoPanel.CurrentLevel.LevelId = 1;
            Globals.TotalScore = 0;
            _music.Update();
            Globals.Lives       = 3;
            Globals.IsFinnished = false;
            IsRunning           = true;
            _elapsedTime        = 0;
            OnGameStarted();
        }
Exemplo n.º 8
0
    protected override void OnUpdateFrame(FrameEventArgs eventArgs)
    {
        base.OnUpdateFrame(eventArgs);

        m_Camera.Update();
        MusicPlayer.Update();

        //m_Sun.transform.position =
        //    new Vector3(
        //        m_Sun.transform.position.X - 0.01f, m_Sun.transform.position.Y, m_Sun.transform.position.Z);
        //m_Sun.transform.eulerAngles =
        //    new Vector3(
        //        m_Sun.transform.eulerAngles.X + 1f,
        //        m_Sun.transform.eulerAngles.Y,
        //        m_Sun.transform.eulerAngles.Z);

        m_Moon.transform.localScale  = new Vector3(7.0f, 1.1f, 1.1f);
        m_Moon.transform.eulerAngles = new Vector3(0f, 0f, 0f);
        m_Moon.transform.position    = new Vector3(2f, 2f, 0f);

        m_Canvas.Update();
    }
Exemplo n.º 9
0
        private void Update()
        {
            MWEngine.Update();

            if (playMusic)
            {
                musicPlayer.Update();
            }

#if UNITY_EDITOR
            if (Input.GetKeyDown(KeyCode.P))
            {
                if (MWEngine.currentCell == null || !MWEngine.currentCell.isInterior)
                {
                    Debug.Log(MWEngine.GetExteriorCellIndices(Camera.main.transform.position));
                }
                else
                {
                    Debug.Log(MWEngine.currentCell.NAME.value);
                }
            }
#endif
        }
Exemplo n.º 10
0
        public static void Update(GameTime gameTime)
        {
            ElapsedSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds * TimeScale;
            TotalSeconds   = (float)gameTime.TotalGameTime.TotalSeconds;

            GameConsole.Clear();
            _fpsCounter.Update(gameTime);
            Input.Update(gameTime);
            Audio?.Update();
            Screen.Update();
            ScreenEffects.Instance.Update(gameTime);
            DebugRenderer.Update(gameTime);

            if (GameEngine.Input.WasPressed(Keys.P))
            {
                TakeScreenshot();
                //MessageRenderer.Instance.PostMainMessage("destroy.pix", 50, 0.7f, 0.003f, 1.4f);
            }

            if (musicPlayer != null)
            {
                musicPlayer.Update();
            }
        }
Exemplo n.º 11
0
    public override void Update()
    {
        base.Update();

        // Post-Initialization
        if (!init)
        {
            init    = true;
            project = new ProjectData(VoezEditor.activeProjectFolder);
            project.LoadAllProjectData();
            musicPlayer = new MusicPlayer();
            ui          = new EditorUI();
            InitiateSong();
            musicPlayer.PauseSong(); // wait for user to manually start the song with the play button
        }

        // Music Player updating
        sfxPlayer.Update();
        musicPlayer.Update();
        if (!musicPlayer.source.isPlaying && musicPlayer.hasStarted && !musicPlayer.paused)
        {
            currentFrame = 0f;
            if (project.songPath != null)
            {
                musicPlayer.PlayAudioClip(project.songPath);
            }
        }
        if (musicPlayer.source.isPlaying)
        {
            currentFrame += 1 * musicPlayer.playbackSpeed;
            // If editor playback time out of sync with music time, begin to speed up or slow down editor playback scrolling
            float nextTime = currentFrame / framesPerSecond;
            if (Mathf.Abs(musicPlayer.source.time - nextTime) > ((1f / VoezEditor.Editor.framesPerSecond) * VoezEditor.musicSyncThreshold))
            {
                if (musicPlayer.source.time > nextTime)
                {
                    if (syncSpeedup < 0f)
                    {
                        syncSpeedup += 0.25f;
                    }
                    else
                    {
                        syncSpeedup += 0.1f;
                    }
                }
                else
                {
                    if (syncSpeedup > 0f)
                    {
                        syncSpeedup -= 0.25f;
                    }
                    else
                    {
                        syncSpeedup -= 0.1f;
                    }
                }
            }
            else
            {
                syncSpeedup *= 0.5f;
                if (Mathf.Abs(syncSpeedup) < 0.25f)
                {
                    syncSpeedup = 0f;
                }
            }
            currentFrame += syncSpeedup * musicPlayer.playbackSpeed;
        }
        if (musicPlayer.source != null)
        {
            if (metronomeEnabled || hitSoundsEnabled)
            {
                musicPlayer.desiredVolume = Mathf.Lerp(musicPlayer.source.volume, 0.3f, 0.03f);
            }
            else
            {
                musicPlayer.desiredVolume = Mathf.Lerp(musicPlayer.source.volume, 1f, 0.01f);
            }
        }

        // Frame Advancing while Paused
        if (EditMode && !MenuOpen && !ui.bpmButton.toggled)
        {
            float delta = GetBPMTimeIncrement() * framesPerSecond;
            if (InputManager.UpTick())
            {
                currentFrame = Mathf.Min(currentFrame + delta, musicPlayer.source.clip.length * framesPerSecond);
            }
            if (InputManager.DownTick())
            {
                currentFrame = Mathf.Max(currentFrame - delta, 0);
            }
            if (InputManager.RightTick())
            {
                currentFrame = Mathf.Min(currentFrame + (delta * 4f), musicPlayer.source.clip.length * framesPerSecond);
            }
            if (InputManager.LeftTick())
            {
                currentFrame = Mathf.Max(currentFrame - (delta * 4f), 0);
            }
        }

        currentTime  = currentFrame / framesPerSecond;
        lastSongTime = songTime;
        songTime     = currentTime;

        // BPM Pulse Tracking
        if (musicPlayer.source.isPlaying)
        {
            int lastBeatFloor = Mathf.FloorToInt(SecondsToBeats(lastSongTime));
            int curBeatFloor  = Mathf.FloorToInt(SecondsToBeats(songTime));
            if (curBeatFloor > lastBeatFloor)
            {
                bpmPulse = true;
                if (metronomeEnabled)
                {
                    if (Mathf.FloorToInt(SecondsToBeats(songTime)) % 2 == 0)
                    {
                        sfxPlayer.metroSource.PlayOneShot(sfxPlayer.metroTick1);
                    }
                    else
                    {
                        sfxPlayer.metroSource.PlayOneShot(sfxPlayer.metroTick2);
                    }
                }
            }
            else
            {
                bpmPulse = false;
            }
        }
        else
        {
            bpmPulse = false;
        }

        // Update all active objects
        int updateIndex = updateList.Count - 1;

        while (updateIndex >= 0)
        {
            UpdatableObject obj = updateList[updateIndex];
            if (obj.readyForDeletion)
            {
                PurgeObject(obj);
            }
            else
            {
                obj.Update();
            }
            updateIndex--;
        }
        ui.Update();

        // Spawn Tracks
        for (int i = 0; i < project.tracks.Count; i += 1)
        {
            if (songTime >= project.tracks[i].start && songTime <= project.tracks[i].end && !TrackSpawned(project.tracks[i].id))
            {
                AddObject(new Track(project.tracks[i]));
            }
        }

        // Spawn Notes
        for (int i = 0; i < project.notes.Count; i += 1)
        {
            float effHold = 0f;
            if (project.notes[i].type == ProjectData.NoteData.NoteType.HOLD)
            {
                effHold = project.notes[i].hold;
            }
            if (songTime >= project.notes[i].time - Note.NOTE_DURATION && songTime <= project.notes[i].time + effHold && !NoteSpawned(project.notes[i].id))
            {
                AddObject(new Note(project.notes[i]));
            }
        }

        // Find track mouse is hovering over (or track closest to mouse if hovering over multiple)
        for (int i = 0; i < activeTracks.Count; i += 1)
        {
            activeTracks[i].activeHover = false;
        }
        if (EditMode && !MenuOpen)
        {
            float nearestDist  = int.MaxValue;
            Track nearestTrack = null;
            for (int i = 0; i < activeTracks.Count; i += 1)
            {
                float dist = Mathf.Abs(Input.mousePosition.x - activeTracks[i].pos.x);
                if (activeTracks[i].MouseOver && dist < nearestDist)
                {
                    nearestDist  = dist;
                    nearestTrack = activeTracks[i];
                }
            }
            if (nearestTrack != null && !ui.HoveringOverSubmenuItem())
            {
                nearestTrack.activeHover = true;
                if (!trackEditMode)
                {
                    ui.trackAdder.notePreviewVisible = true;
                    ui.trackAdder.pos.x = nearestTrack.pos.x;
                    ui.trackAdder.pos.y = ui.grid.SnapToGridY(Input.mousePosition.y);
                }

                // Add New Note to Hovered Track
                if (InputManager.leftMousePushed && !HoveringOverAnyNote() && !trackEditMode)
                {
                    float desiredSongTime = ui.grid.GetSongTimeAtGridY(Input.mousePosition.y);
                    desiredSongTime = Mathf.Clamp(desiredSongTime, 0f, musicPlayer.source.clip.length);
                    if (!TrackOccupiedAtTime(nearestTrack.ID, desiredSongTime))
                    {
                        ProjectData.NoteData newNote = new ProjectData.NoteData();
                        newNote.id    = GetUniqueTempNoteID();
                        newNote.time  = desiredSongTime;
                        newNote.track = nearestTrack.ID;
                        newNote.type  = selectedNoteType;
                        project.AddNote(newNote);
                        RefreshAllNotes();
                    }
                }
            }
            else
            {
                ui.trackAdder.notePreviewVisible = false;
            }
        }
        else
        {
            ui.trackAdder.notePreviewVisible = false;
        }

        if (readyToShutDown)
        {
            ShutDownProcess();
            VoezEditor.activeProcess = new ProjectsProcess();
        }
    }
Exemplo n.º 12
0
        protected override void Update(GameTime gameTime)
        {
            keyboardState = Keyboard.GetState();
            if (keyboardState.IsKeyDown(Keys.Escape) || keyboardState.IsKeyDown(Keys.D5))
            {
                Exit();
            }

            musicPlayer.Update(player.position.Y);

            for (int soundsPlayingIndex = 0;
                 soundsPlayingIndex < soundsPlaying.Count;
                 soundsPlayingIndex++)
            {
                if (soundsPlaying[soundsPlayingIndex].State != SoundState.Playing)
                {
                    soundsPlaying[soundsPlayingIndex].Dispose();
                    soundsPlaying.RemoveAt(soundsPlayingIndex);
                    soundsPlayingIndex--;
                }
            }


            Vector2 acceleration = Vector2.Zero;

            if (coins.Count == 0)
            {
                // Note(ian): Warp speed.
                acceleration.Y -= 1000f;
            }

            float verticalImpulse   = 300f;
            float horisontalImpulse = (verticalImpulse / 8f) * 5f;

            if (keyboardState.IsKeyDown(Keys.Up) || keyboardState.IsKeyDown(Keys.W))
            {
                acceleration.Y  = -verticalImpulse;
                player.hasMoved = true;
            }
            if (keyboardState.IsKeyDown(Keys.Down) || keyboardState.IsKeyDown(Keys.S))
            {
                acceleration.Y  = +verticalImpulse;
                player.hasMoved = true;
            }
            if (keyboardState.IsKeyDown(Keys.Left) || keyboardState.IsKeyDown(Keys.A))
            {
                acceleration.X  = -horisontalImpulse;
                player.hasMoved = true;
            }
            if (keyboardState.IsKeyDown(Keys.Right) || keyboardState.IsKeyDown(Keys.D))
            {
                acceleration.X  = +horisontalImpulse;
                player.hasMoved = true;
            }

            // Gravity
            if (player.hasMoved)
            {
                acceleration.Y += 100f;
            }

            if (numCoinBoosts > 0)
            {
                numCoinBoosts--;
                acceleration.Y -= 2000f;
            }

            acceleration.X += player.velocity.X * -player.drag.X;
            acceleration.Y += player.velocity.Y * -player.drag.Y;

            float   secondsElapsed      = (float)gameTime.ElapsedGameTime.TotalSeconds;
            Vector2 playerPositionDelta = (acceleration * 0.5f * (float)Math.Pow(secondsElapsed, 2)) +
                                          (player.velocity * secondsElapsed);

            player.position += playerPositionDelta;

            player.velocity = player.velocity + (acceleration * secondsElapsed);

            // Max Velocity
            float baseMaxSpeed = 150f;
            float maxSpeedDown = (baseMaxSpeed / 15f) * 35f;

            player.velocity.X = player.velocity.X < 0 ? (float)Math.Max(-baseMaxSpeed, player.velocity.X) : (float)Math.Min(baseMaxSpeed, player.velocity.X);
            player.velocity.Y = player.velocity.Y < 0 ? (float)Math.Max(-baseMaxSpeed, player.velocity.Y) : (float)Math.Min(maxSpeedDown, player.velocity.Y);

            if (player.position.X < 0)
            {
                player.position.X = 0;
            }
            if (player.position.Y < 0)
            {
                player.position.Y = 0;
            }
            if (player.position.X > mapSize.X)
            {
                player.position.X = mapSize.X;
            }
            if (player.position.Y > mapSize.Y)
            {
                player.position.Y = mapSize.Y;
            }


            int coinRestrictionIndex = (int)Math.Floor(player.coinCount / 4f);

            if (coinRestrictionIndex < Player.boundries.Length)
            {
                float maxHeight          = Player.boundries[coinRestrictionIndex];
                float convertedMaxHeight = GetConvertedPosition(new Vector2(0, maxHeight)).Y;
                if (player.position.Y < convertedMaxHeight)
                {
                    player.position.Y = convertedMaxHeight;
                }
            }

            float distanceToPickupCoin = 50;

            for (int coinIndex = 0;
                 coinIndex < coins.Count;
                 coinIndex++)
            {
                Coin    coin         = coins[coinIndex];
                Vector2 vectorToCoin = coin.position - player.position;
                if (vectorToCoin.Length() < distanceToPickupCoin)
                {
                    player.coinCount++;
                    PlaySound(sounds[coin.soundName]);
                    coins.Remove(coin);
                    coinIndex--;
                    numCoinBoosts++;
                }
            }

            lastKeyboardState = keyboardState;
        }
Exemplo n.º 13
0
    public override void Update()
    {
        base.Update();

        // Post-Initialization
        if (!init)
        {
            init = true;
            AddObject(new SolidBackground(Color.white));
            ProjectIcon activeIcon = null;
            icons = new ProjectIcon[24];
            for (int i = 0; i < icons.Length; i += 1)
            {
                int projectInd = IconIndToProjectInd(i) - 3;
                if (projectInd < 0 || projectInd >= projectDirectories.Count)
                {
                    icons[i] = new ProjectIcon(null, Vector2.zero, i);
                }
                else
                {
                    icons[i] = new ProjectIcon(projectDirectories[projectInd], Vector2.zero, i);
                    if (projectDirectories[projectInd] == VoezEditor.activeProjectFolder)
                    {
                        activeIcon = icons[i];
                    }
                }
                AddObject(icons[i]);
            }
            ui                   = new ProjectsUI();
            musicPlayer          = new MusicPlayer();
            musicPlayer.loopMode = true;
            if (activeIcon != null)
            {
                SetSelectedProject(activeIcon);
            }
        }

        // Control of scrolling the list around
        float snap = (ProjectIcon.size + GRID_MARGIN) * 0.5f;

        VoezEditor.projectScrollOff = Mathf.Lerp(VoezEditor.projectScrollOff, targetScroll, 0.1f);
        if (!Input.GetMouseButton(0))
        {
            mouseDragInit = false;
        }
        if (InputManager.leftMousePushed && !ui.HoveringOverSubmenuItem())
        {
            lastScrollOffset = targetScroll;
            mouseDragInit    = true;
        }
        if (InputManager.leftMouseReleased)
        {
            if ((InputManager.screenPosOnLeftMousePush.x - Input.mousePosition.x) < 0)
            {
                targetScroll = Mathf.Floor(targetScroll / snap) * snap;
            }
            else
            {
                targetScroll = Mathf.Ceil(targetScroll / snap) * snap;
            }
        }
        if (Input.GetMouseButton(0) && Vector2.Distance(InputManager.screenPosOnLeftMousePush, Input.mousePosition) > 16 && mouseDragInit)
        {
            targetScroll = lastScrollOffset + (InputManager.screenPosOnLeftMousePush.x - Input.mousePosition.x);
        }
        else
        {
            float multi = 1;
            if (Util.ShiftDown())
            {
                multi = 4;
            }
            if (InputManager.UpTick() || InputManager.RightTick())
            {
                targetScroll += snap * multi;
            }
            if (InputManager.DownTick() || InputManager.LeftTick())
            {
                targetScroll -= snap * multi;
            }
        }
        float maxTargetScroll = Mathf.Max((projectDirectories.Count / 2) * snap, snap * 5);

        if (targetScroll < 0)
        {
            targetScroll = 0;
        }
        if (targetScroll > maxTargetScroll)
        {
            targetScroll = maxTargetScroll;
        }


        musicPlayer.Update();
        LayoutProjectIcons();

        // Update all active objects
        int updateIndex = updateList.Count - 1;

        while (updateIndex >= 0)
        {
            UpdatableObject obj = updateList[updateIndex];
            if (obj.readyForDeletion)
            {
                PurgeObject(obj);
            }
            else
            {
                obj.Update();
            }
            updateIndex--;
        }
        ui.Update();

        if (readyToShutDown)
        {
            ShutDownProcess();
            VoezEditor.activeProcess = new EditorProcess();
        }
    }