Пример #1
0
        public override void _Ready()
        {
            _payment     = GetNode <GooglePlayBilling>("GooglePlayBilling");
            _alertDialog = GetNode <AcceptDialog>("AlertDialog");
            _label       = GetNode <Label>("Label");

            if (_payment.IsAvailable)
            {
                _label.Text += $"\n\n\nTest item SKU: {TestItemSku}";

                // No params.
                _payment.Connect(nameof(GooglePlayBilling.Connected), this, nameof(OnConnected));
                // No params.
                _payment.Connect(nameof(GooglePlayBilling.Disconnected), this, nameof(OnDisconnected));
                // Response ID (int), Debug message (string).
                _payment.Connect(nameof(GooglePlayBilling.ConnectError), this, nameof(OnConnectError));
                // Purchases (Dictionary[]).
                _payment.Connect(nameof(GooglePlayBilling.PurchasesUpdated), this, nameof(OnPurchasesUpdated));
                // Response ID (int), Debug message (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseError), this, nameof(OnPurchaseError));
                // SKUs (Dictionary[]).
                _payment.Connect(nameof(GooglePlayBilling.SkuDetailsQueryCompleted), this, nameof(OnSkuDetailsQueryCompleted));
                // Response ID (int), Debug message (string), Queried SKUs (string[]).
                _payment.Connect(nameof(GooglePlayBilling.SkuDetailsQueryError), this, nameof(OnSkuDetailsQueryError));
                // Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseAcknowledged), this, nameof(OnPurchaseAcknowledged));
                // Response ID (int), Debug message (string), Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseAcknowledgementError), this, nameof(OnPurchaseAcknowledgementError));
                // Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseConsumed), this, nameof(OnPurchaseConsumed));
                // Response ID (int), Debug message (string), Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseConsumptionError), this, nameof(OnPurchaseConsumptionError));
                _payment.StartConnection();
            }
            else
            {
                ShowAlert("Android IAP support is not enabled. Make sure you have enabled 'Custom Build' and installed and enabled the GodotGooglePlayBilling plugin in your Android export settings! This application will not work.");
            }
        }
Пример #2
0
        public override void _Ready()
        {
            _googlePlayBilling = GetNode <GooglePlayBilling>("GooglePlayBilling");

            _buyPotionButton   = GetNode <Button>("VBoxContainer2/BuyPotionButton");
            _totalPotionsLabel = GetNode <Label>("VBoxContainer/Label");

            _panel        = GetNode <Panel>("Panel");
            _processLabel = GetNode <Label>("Panel/ProcessLabel");
            _thanksLabel  = GetNode <Label>("Panel/ThanksLabel");

            _playerLife = GetNode <ProgressBar>("Sprite/ProgressBar");

            _playerLifeStyleBoxFlat         = _playerLife.Get("custom_styles/fg") as StyleBoxFlat;
            _playerLifeStyleBoxFlat.BgColor = Colors.Red.LinearInterpolate(Colors.Green, 1);

            _playerLife.Value = 1;

            _panel.Hide();
            _processLabel.Hide();
            _thanksLabel.Hide();
            _buyPotionButton.Hide();
            _totalPotionsLabel.Text = $"{_totalPotion} Potions";
        }