public override void _Ready()
    {
        asteroidPool      = GetNode("AsteroidPool") as Node;
        commandStartPoint = GetNode("CommandStartPoint") as Position2D;
        deathSound        = GetNode("DeathSound") as AudioStreamPlayer;
        bgm                 = GetNode("BGM") as AudioStreamPlayer;
        gameplayHUD         = GetNode("GameplayHUD") as GameplayHUDObject;
        gameOverHUD         = GetNode("GameOverHUD") as GameOverHUD;
        ship                = GetNode("Ship") as ShipObject;
        commandExecutePoint = GetNode("CommandExecutePoint") as CommandExecutePoint;

        messageTimer  = GetNode("GameplayHUD/MessageTimer") as Timer;
        blackHolePool = GetNode("BlackHolePool") as Node;
        spawnTimer    = GetNode("SpawnTimer") as Timer;

        this.globals = (Autoload)GetNode("/root/Autoload");

        this.globals.Randomize();
        ship.Connect("Hit", this, "GameOver");
        gameOverHUD.Connect("BackToMainMenu", this, "GotoMainmenu");
        gameOverHUD.Connect("RestartGame", this, "RestartGameplay");
        commandExecutePoint.Connect("CallRight", this, "ForceShipTurnRight");
        commandExecutePoint.Connect("CallLeft", this, "ForceShipTurnLeft");
        commandExecutePoint.Connect("CallShoot", this, "ForceShipShootLaser");

        SetProcess(true);
        NewGame();
        StartNextLevel();
    }
Example #2
0
    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");
    }