Example #1
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");
    }