예제 #1
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        healthbar = GetNode <TextureProgress>("Health");
        ammobar   = GetNode <TextureProgress>("Ammo");

        SendHealthEvent.RegisterListener(UpdateHealth);
        SendAmmoEvent.RegisterListener(UpdateAmmo);
    }
예제 #2
0
    private void AddAmmo(TileDestroyEvent tdei)
    {
        //Check if the tile destroyed bool is true
        if (tdei.tileDestroyed)
        {
            //Add ammo if a tile was destroyed
            ammo++;
        }
        else
        {
            if (ammo > 0)
            {
                //Create a ne bullet
                bullet = bulletScene.Instance();
                //Set the direction of the bullet when instanced
                AddChild(bullet);
                ammo--;
            }
        }
        SendAmmoEvent saei = new SendAmmoEvent();

        saei.ammo = ammo;
        saei.FireEvent();
    }
예제 #3
0
 public override void _ExitTree()
 {
     SendHealthEvent.UnregisterListener(UpdateHealth);
     SendAmmoEvent.UnregisterListener(UpdateAmmo);
 }
예제 #4
0
 private void UpdateAmmo(SendAmmoEvent saei)
 {
     ammobar.Value = saei.ammo;
 }