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 _Input(InputEvent inputEvent)
    {
        if (inputEvent.IsAction("shoot"))
        {
            bool isPressed = inputEvent.IsPressed();
            Emitting     = isPressed;
            shooterizing = isPressed;

            if (isPressed && !_player.IsPlaying())
            {
                _player.Play();
            }
            else if (!isPressed && _player.IsPlaying())
            {
                _player.Stop();
            }
        }
    }
Ejemplo n.º 3
0
    public override void _Ready()
    {
        global    = GetNode("/root/Global");
        menuAudio = (AudioStreamPlayer)global.GetNode("MenuAudioStreamPlayer");

        if (!menuAudio.IsPlaying())
        {
            CheckButton toggleButton = (CheckButton)GetNode("/root/OptionsMenuScene/OptionsMenuButtons/menuMusic");
            GD.Print(toggleButton + toggleButton.Name);
            toggleButton.Pressed = false;
        }
    }
Ejemplo n.º 4
0
    public override void _Process(float delta)
    {
        if (state == TextState.Displaying)
        {
            visibleChars += TEXT_SPEED * delta;
            if (Input.IsActionJustPressed("ui_accept"))
            {
                visibleChars = textBox.Text.Length;
            }

            textBox.VisibleCharacters = Mathf.FloorToInt(visibleChars);
            if (visibleChars >= textBox.Text.Length)
            {
                if (currentDialog.Sounds.Length > 0)
                {
                    state      = TextState.WaitingForSound;
                    soundIndex = -1;
                }
                else
                {
                    TextFinished();
                }
            }
        }
        else if (state == TextState.WaitingForSound)
        {
            if (!player.IsPlaying())
            {
                soundIndex++;
                if (currentDialog.Sounds.Length <= soundIndex)
                {
                    TextFinished();
                }
                else
                {
                    player.Stream = ResourceLoader.Load(currentDialog.Sounds[soundIndex]) as AudioStream;
                    player.Play();
                }
            }
        }
        else if (state == TextState.Waiting)
        {
            if (Input.IsActionJustPressed("ui_accept") && currentOptions.Count == 0)
            {
                arrow.Visible = false;
                arrowAnim.Stop();
                DisplayOrExit(currentDialog.Next);
            }
        }

        void TextFinished()
        {
            if (currentOptions.Count == 0)
            {
                arrow.Visible = true;
                arrowAnim.Play("Bounce");
            }
            else
            {
                for (int i = 0; i < currentOptions.Count && i < buttons.Length; i++)
                {
                    buttons[i].Visible = true;
                }
                player.Stream = ResourceLoader.Load("res://sounds/dialog_open.ogg") as AudioStream;
                player.Play();
            }
            state = TextState.Waiting;
            currentDialog.Script?.Invoke();
        }
    }