コード例 #1
0
ファイル: UIControl.cs プロジェクト: IndieRonin/Guardian
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        UnitDeathEvent.RegisterListener(UnitDeath);
        WinEvent.RegisterListener(WinTriggered);
        LoseEvent.RegisterListener(LoseTriggered);

        //Grab all the references for the scenes
        menuPanel    = GetNode <Node2D>("Menu");
        winPanel     = GetNode <Node2D>("Win");
        losePanel    = GetNode <Node2D>("Lose");
        creditsPanel = GetNode <Node2D>("Credits");
        uiPanel      = GetNode <Node2D>("UI");
        background   = GetNode <Sprite>("Background");


        //Grab a refference to all the buttons that we have
        startBtn     = GetNode <Button>("Start");
        exitBtn      = GetNode <Button>("Exit");
        menuBtn      = GetNode <Button>("Menubtn");
        smallExitBtn = GetNode <Button>("SmallExit");
        creditsBtn   = GetNode <Button>("Creditsbtn");

        //The buttons for the menu
        startBtn.Connect("pressed", this, nameof(ShowUI));
        exitBtn.Connect("pressed", this, nameof(ExitGame));
        menuBtn.Connect("pressed", this, nameof(ShowMenu));
        smallExitBtn.Connect("pressed", this, nameof(ExitGame));
        creditsBtn.Connect("pressed", this, nameof(ShowCredits));

        //Hide all the scenes at start up
        HideAll();
        ShowMenu();
    }
コード例 #2
0
ファイル: Main.cs プロジェクト: IndieRonin/Guardian
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //Grabs the map scene from the Scene tree on the games start up
        mapScene           = ResourceLoader.Load("res://Scenes/Map.tscn") as PackedScene;
        playerScene        = ResourceLoader.Load("res://Scenes/Player.tscn") as PackedScene;
        crystalScene       = ResourceLoader.Load("res://Scenes/Crystal.tscn") as PackedScene;
        enemySpawnerScene  = ResourceLoader.Load("res://Scenes/EnemySpawner.tscn") as PackedScene;
        UIScene            = ResourceLoader.Load("res://Scenes/UI.tscn") as PackedScene;
        missilePickupScene = ResourceLoader.Load("res://Scenes/MissilePickup.tscn") as PackedScene;
        MainEvent.RegisterListener(UIEventFired);
        UnitDeathEvent.RegisterListener(EndGame);
        WinEvent.RegisterListener(WinTriggered);
        LoseEvent.RegisterListener(LostTriggered);

        ui      = UIScene.Instance();
        ui.Name = "UI";
        AddChild(ui);
    }