コード例 #1
0
    public override void _Ready()
    {
        Position2D pos = GetParent().GetNode <Position2D>("Spawn");

        currentCheckpoint = pos.GetGlobalPosition();
        lifeCount         = 4;
    }
コード例 #2
0
    public void Shoot()
    {
        PlayerBulletObject bulletObj = (PlayerBulletObject)bullets.Instance();

        bulletContainer.AddChild(bulletObj);
        bulletObj.StartAt(GetRotation(), muzzle.GetGlobalPosition());
        shootSound.Play();
    }
コード例 #3
0
    public override void _Process(float delta)
    {
        Node       player = GetParent().GetNode("Player");
        Position2D spawn  = (Position2D)GetNode("Spawn");

        if (this.OverlapsBody(player))
        {
            player.Set("currentCheckpoint", spawn.GetGlobalPosition());
        }

        if (spawn.GetGlobalPosition() == (Vector2)player.Get("currentCheckpoint"))
        {
            GetNode <Sprite>("Active").SetVisible(true);
        }
        else
        {
            GetNode <Sprite>("Active").SetVisible(false);
        }
    }
コード例 #4
0
    public void _on_TimerCoin_timeout()
    {
        //    GD.Print("Saatnya Spawn Koin");
        TimerCoin.Stop();

        RigidBody2D SpawnCoin = (RigidBody2D)CoinCollectable.Instance();

        GetParent().AddChild(SpawnCoin);

        Position2D CoinSpawn = (Position2D)GetNode("CoinSpawn");

        SpawnCoin.SetPosition(CoinSpawn.GetGlobalPosition());
    }
コード例 #5
0
ファイル: Root.cs プロジェクト: NelDav/SEgame
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //Connecting the Shoot signal with the on_Player_Shoot handler.
        GetNode("Player/SalmonWeapon").Connect("shoot", this, nameof(on_Player_Shoot));
        Position2D  spawn  = (Position2D)GetNode("MapScene/Spawn");
        RigidBody2D player = (RigidBody2D)GetNode("Player");

        player.SetPosition(spawn.GetGlobalPosition());

        // Turn off the Menu Music
        var global    = GetNode("/root/Global");
        var menuAudio = (AudioStreamPlayer)global.GetNode("MenuAudioStreamPlayer");

        menuAudio.Stop();
    }