/// <summary> /// Resets the PlayArea /// </summary> public void Reset() { if (IsReset) { return; } Time = 0f; Course.ForEach(s => s.QueueFree()); Course.Clear(); var start = Start.Instance() as Segment; start.Position = new Vector2(0, 0); start.FreedEvent += OnSegmentFreed; Course.Add(start); CallDeferred("add_child", start); //await ToSignal(start, "ready"); RunnerDetector.Position = new Vector2(1920, 0); DeathLaser.Position = new Vector2(-30, 0); BatchTimer.Stop(); BatchTimer.WaitTime = Timeout; IsReset = true; }
private void OnPlayerDeath() { _musicPlayer.Stream = _gameOverMusic; _musicPlayer.Play(); _wizzard.OnPlayerDeath(); _monsterSpawnTimer.Stop(); var timer = new Timer { OneShot = true, Autostart = true, WaitTime = 2 }; timer.Connect("timeout", this, nameof(GameOver)); AddChild(timer); }
public override void _Ready() { ship = GetNode("PlayerShip") as ShipObject; Position2D temp = GetNode("PlayerShipPoints/2") as Position2D; commandStartPoint = GetNode("CommandPanel/CommandStartPoint") as Position2D; commandExecutionPoint = GetNode("CommandPanel/CommandExecutionPoint") as CommandExecutionPointObject; reefSpawnTimer = GetNode("ReefSpawnTimer") as Timer; reefPool = GetNode("ReefPool") as Node; remainingNMileLabel = GetNode("CommandPanel/RemainingNMileLabel") as Label; messageLabel = GetNode("MessageLabel") as Label; messageTimer = GetNode("MessageTimer") as Godot.Timer; weaterStatusLabel = GetNode("CommandPanel/WeaterStatusLabel") as Label; gameOverSound = GetNode("GameOverSound") as AudioStreamPlayer; missionCompleteSound = GetNode("MissionCompleteSound") as AudioStreamPlayer; bgm = GetNode("BGM") as AudioStreamPlayer; this.globals = (Autoload)GetNode("/root/Autoload"); this.globals.Randomize(); ship.SetStartPosition(temp.Position, Int32.Parse(temp.Name)); velocity = commandVelocity[weatherFactor]; reefSpawnTimer.Start(); distanceFromGoal *= 60; //multiply with 60 because frame-per-sec principle this.globals.missionComplete = false; difficult = 0; weatherFactor = 0; messageLabel.Hide(); messageTimer.Stop(); SetWeatherStatusLabel(); gameOverSound.Stop(); missionCompleteSound.Stop(); bgm.Stop(); bgm.Play(); commandExecutionPoint.Connect("CallRight", this, "ForceShipTurnRight"); commandExecutionPoint.Connect("CallLeft", this, "ForceShipTurnLeft"); ship.Connect("Hit", this, "DoGameOver"); }