//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); }
public void Blink(float duration = 0.05f) { SceneTreeTimer timer = GetTree().CreateTimer(duration); timer.Connect("timeout", this, nameof(ResetMaterial)); body.Material = MoonHunter.Instance.WHITE_MATERIAL; }
public void Shoot(float duration = 0.5f) { ShowBody(); SoundManager.Instance.LaserBeamAudioPlayer.Play(); SceneTreeTimer timer = GetTree().CreateTimer(duration); timer.Connect("timeout", this, nameof(HideBody)); }
public void Arm() { sprite.Modulate = new Color(1, 0, 0, 1); SceneTreeTimer timer = GetTree().CreateTimer(0.15f); timer.Connect("timeout", this, nameof(Explode)); //Beep ? }
//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)); }
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(); }
public override void _Ready() { if (!Visible) { return; } listener = new SystemRuntimeEventListener(); timer = GetTree().CreateTimer(updateTimeout); timer.Connect("timeout", this, "UpdateCounters"); }
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; }
public override void _Ready() { SceneTreeTimer t = GetTree().CreateTimer(maxLifetime); t.Connect("timeout", this, "Destroy"); }