Exemplo n.º 1
0
        //Sets the current value of the health bar (and runs the backlay)
        public void SetHealth(int hp)
        {
            //If hp is increasing then do so immediately
            if (hp > this.nodeHP.Value)
            {
                this.nodeHP.Value        = hp;
                this.nodeHPBacklay.Value = hp;
                return;
            }

            double damage = this.nodeHP.Value - (double)hp;

            this.nodeHP.Value = hp;

            //Character is dead, do not add backlay timer
            if (hp <= 0)
            {
                return;
            }

            //Setup timer to update the backlay
            SceneTreeTimer timer = GetTree().CreateTimer((
                                                             float)(this.healthbarDelayStart + damage / this.healthbarDelayRegression), false);

            timer.Connect("timeout", this, nameof(SetBacklayValue), new Godot.Collections.Array(new object[] { hp }));
        }
    public void HurtAnimation(float duration = 0.05f)
    {
        SceneTreeTimer timer = GetTree().CreateTimer(duration);

        timer.Connect("timeout", this, nameof(ResetMaterial));
        blockSprite.Modulate = new Color(1, 0.41f, 0.41f, 1);
    }
Exemplo n.º 3
0
    public void Blink(float duration = 0.05f)
    {
        SceneTreeTimer timer = GetTree().CreateTimer(duration);

        timer.Connect("timeout", this, nameof(ResetMaterial));
        body.Material = MoonHunter.Instance.WHITE_MATERIAL;
    }
Exemplo n.º 4
0
    public void Shoot(float duration = 0.5f)
    {
        ShowBody();
        SoundManager.Instance.LaserBeamAudioPlayer.Play();
        SceneTreeTimer timer = GetTree().CreateTimer(duration);

        timer.Connect("timeout", this, nameof(HideBody));
    }
Exemplo n.º 5
0
    public void Arm()
    {
        sprite.Modulate = new Color(1, 0, 0, 1);
        SceneTreeTimer timer = GetTree().CreateTimer(0.15f);

        timer.Connect("timeout", this, nameof(Explode));
        //Beep ?
    }
Exemplo n.º 6
0
        //Called when an animation is finished
        //Sets up a timer which calls creates a new strike after a random amount of time
        void _OnAnimationFinished(String anim)
        {
            //Create a timer, which will pause when the game is paused
            SceneTreeTimer timer = GetTree().CreateTimer(
                (float)Command.Random(this.minStrikeGap, this.maxStrikeGap), false);

            timer.Connect("timeout", this, nameof(this.Strike));
        }
Exemplo n.º 7
0
    public void UpdateCounters()
    {
        timer = GetTree().CreateTimer(updateTimeout);
        timer.Connect("timeout", this, "UpdateCounters");

        Text  = "Avg Tick time: " + Avg(ticks).ToString() + " uSec\n";
        Text += "Static Mem: " + (OS.GetStaticMemoryUsage() / (float)0x10_0000).ToString() + " Mb";

        ticks.Clear();
    }
Exemplo n.º 8
0
 public override void _Ready()
 {
     if (!Visible)
     {
         return;
     }
     listener = new SystemRuntimeEventListener();
     timer    = GetTree().CreateTimer(updateTimeout);
     timer.Connect("timeout", this, "UpdateCounters");
 }
Exemplo n.º 9
0
        private void LoseLife()
        {
            //Lost
            if (this.lives == 0)
            {
                this.nodeEnemy.Wins();
                return;
            }

            //Create short timer
            SceneTreeTimer tmr = GetTree().CreateTimer(1f, true);

            tmr.Connect("timeout", this, nameof(StartNewRound));
            GetTree().Paused = true;

            Lobby.state = Lobby.GameState.IN_GAME_NOT_PLAYING;
        }
Exemplo n.º 10
0
    public override void _Ready()
    {
        SceneTreeTimer t = GetTree().CreateTimer(maxLifetime);

        t.Connect("timeout", this, "Destroy");
    }