Ejemplo n.º 1
0
    public void Extinguish(int delta)
    {
        var mat       = (ParticlesMaterial)ProcessMaterial;
        var newAmount = mat.Gravity.y + delta;

        if (newAmount >= MinParticleAmount)
        {
            GetParent().RemoveChild(this);
            _world.RemoveFire(this);
            _flacker = false;
        }
        else
        {
            mat.Gravity = new Vector3(0, newAmount, 0);
            if (!_flacker)
            {
                _flacker          = true;
                _flackerTimeCount = 0;
            }
            if (_sound.IsPlaying() && _sound.GetPlaybackPosition() > 0.2)
            {
                _sound.Seek(0);
            }
            else
            {
                if (!_sound.IsPlaying())
                {
                    _sound.Play();
                }
            }
        }
    }
Ejemplo n.º 2
0
 public override void _Process(float delta)
 {
     if (_AudioStream.Playing)
     {
         _Percent = _AudioStream.GetPlaybackPosition() / _AudioStream.Stream.GetLength();
     }
     Update();
 }
Ejemplo n.º 3
0
 public void SetPause()
 {
     GetNode <Timebar>("Timebar").Paused = true;
     GetNode <HBoxContainer>("HUD/Margin/Center/PauseContainer").Hide();
     GetNode <HBoxContainer>("HUD/Margin/Center/PlayContainer").Show();
     _LastSongPosition = _Audioplayer.GetPlaybackPosition();
     _Audioplayer.Stop();
     Paused = true;
     // GetNode<DrawPaths>("DrawPaths").Pause();
 }
Ejemplo n.º 4
0
 public void SetPause()
 {
     GetNode <Timebar>("Timebar").Paused = true;
     GetNode <HBoxContainer>("HUD/Margin/Center/PauseContainer").Hide();
     GetNode <HBoxContainer>("HUD/Margin/Center/PlayContainer").Show();
     _LastSongPosition = _Audioplayer.GetPlaybackPosition();
     _Audioplayer.Stop();
     Paused = true;
     foreach (Joint joint in ActiveJoints)
     {
         joint.Pause();
     }
 }
Ejemplo n.º 5
0
        public override void _Process(float delta)
        {
            var time = 0.0;

            time = audioStreamPlayer.GetPlaybackPosition() + AudioServer.GetTimeSinceLastMix()
                   - AudioServer.GetOutputLatency() + (1 / COMPENSATE_HZ) * COMPENSATE_FRAMES;
            var beat = (int)(time * bmp / 60.0);

            var seconds      = (int)time;
            var secondsTotal = (int)audioStreamPlayer.Stream.GetLength();

            beatBPM.Text =
                $"BEAT: {beat % bars + 1} / {bars} TIME: {seconds / 60} : {seconds % 60} / {secondsTotal / 60} : {secondsTotal % 60} / BEAT: {beat}";
            if (beat != beatPrevius)
            {
                pulse?.Invoke(beat);
            }
            beatPrevius = beat;
        }
Ejemplo n.º 6
0
    private AudioStreamPlayer findOldestSoundEffectPlayer()
    {
        AudioStreamPlayer lastPlayer = null;

        for (int index = 0; index < soundEffectPlayers.Length; index++)
        {
            if (lastPlayer == null)
            {
                lastPlayer = soundEffectPlayers[index];
            }

            if (soundEffectPlayers[index].GetPlaybackPosition() > lastPlayer.GetPlaybackPosition())
            {
                lastPlayer = soundEffectPlayers[index];
            }
        }

        return(lastPlayer);
    }
    public override void _PhysicsProcess(float delta)
    {
        base._PhysicsProcess(delta);

        // check if the wave nearest the player has passed the global z-axis zero point
        // At that point it is not longer cutable, and must be removed
        var nearestWave = WaveInstances.FirstOrDefault();

        if (nearestWave != null &&
            nearestWave.GlobalTransform.origin.z >= 1)
        {
            // wave should have faded-out by now, so remove it from the scene.
            WaveInstances.Remove(nearestWave);

            nearestWave.Remove();
            nearestWave.QueueFree();
        }
        else if (nearestWave != null &&
                 nearestWave.GlobalTransform.origin.z >= 0)
        {
            nearestWave.SetForRemoval();
        }

        // check for a collision with the ribbon
        // Check all waves within 1m of global origin for cuts
        foreach (var waveInstance in WaveInstances)
        {
            if (waveInstance.GlobalTransform.origin.z > -1)             // only check for cuts when wave is near player origin
            {
                waveInstance.SetActive();

                if (waveInstance.WaveCut(RibbonPoints))
                {
                    // todo - if all the segments are cut, play a special sound effect?
                }
            }
        }

        // check if it's time to emit another wave
        // Previously attempted to do this with a Timer, and also with OS.ticks() method, but both fell out of sync with audio over duration of track.
        // Using GetPlaybackPosition() to time wave emission seems to be effective
        // todo - investigate method here: https://docs.godotengine.org/en/stable/tutorials/audio/sync_with_audio.html#using-the-sound-hardware-clock-to-sync
        if (Active &&
            AudioStreamPlayer.GetPlaybackPosition() >= NextEmissionTime - WARP_TIME)
        {
            // Initialise a new wave
            var waveInstance = WaveScene.Instance() as Wave;
            WaveSpawnPoint.AddChild(waveInstance);

            waveInstance.Initialise(WaveSequence.GetNextWave());
            WaveInstances.Add(waveInstance);

            // "warp" the wave in quickly...
            WaveMovementTween.InterpolateProperty(waveInstance, "translation:z", -30, 0, WARP_TIME);

            // ...then move the wave towards the player at a reasonable speed (n.b. this tween starts after a delay)
            var animationDuration = 3f;
            WaveMovementTween.InterpolateProperty(waveInstance, "translation:z", 0, 3, animationDuration, delay: WARP_TIME);

            if (waveInstance.RotationRateRad != 0)
            {
                // some waves will also rotate as they move toward the player (n.b. this tween starts after a delay)
                var rotationStart = waveInstance.Rotation.z;
                var rotationEnd   = waveInstance.Rotation.z + (waveInstance.RotationRateRad * animationDuration);
                WaveMovementTween.InterpolateProperty(waveInstance, "rotation:z", rotationStart, rotationEnd, animationDuration, delay: WARP_TIME);
            }

            WaveMovementTween.Start();

            var nextWaveDelay = WaveSequence.GetNextWaveDelay();
            if (nextWaveDelay.HasValue)
            {
                NextEmissionTime += nextWaveDelay.Value;
            }
            else
            {
                // no waves left in sequence
                Active = false;
            }
        }
    }