Beispiel #1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1(args))
     {
         game.Run();
     }
 }
        /*
        "premium_upgrade",
        ReservedTestProductIDs.Purchased,
        ReservedTestProductIDs.Canceled,
        ReservedTestProductIDs.Refunded,
        ReservedTestProductIDs.Unavailable,
        */

        /// <summary>
        /// See parent.
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Create the interface used to interact with Google Play.
            mGooglePlayClient = new GamesClient.Builder(this, this, this)
                .SetGravityForPopups((int)(GravityFlags.Bottom | GravityFlags.CenterHorizontal))
                .Create();

            pGooglePlayClient.RegisterConnectionCallbacks (this);
            pGooglePlayClient.IsConnectionFailedListenerRegistered (this);

            // Create a new connection to the Google Play Service
            mBillingConnection = new InAppBillingServiceConnection (this, InAppBillingKey.Key);
            pBillingConnection.OnConnected += async () => {

                // Clear out the test purchase so that it can be tested again. Remove this 
                // to test starting with test purchase already completed.
                //bool response = pBillingConnection.BillingHandler.ConsumePurchase("inapp:"+ PackageName +":android.test.purchased");

                // Attach to the various error handlers to report issues
                pBillingConnection.BillingHandler.OnGetProductsError += (int responseCode, Bundle ownedItems) => {
                    Console.WriteLine("Error getting products");
                };

                pBillingConnection.BillingHandler.OnInvalidOwnedItemsBundleReturned += (Bundle ownedItems) => {
                    Console.WriteLine("Invalid owned items bundle returned");
                };

                pBillingConnection.BillingHandler.OnProductPurchasedError += (int responseCode, string sku) => {
                    Console.WriteLine("Error purchasing item {0}",sku);
                };

                pBillingConnection.BillingHandler.OnPurchaseConsumedError += (int responseCode, string token) => {
                    Console.WriteLine("Error consuming previous purchase");
                };

                pBillingConnection.BillingHandler.InAppBillingProcesingError += (message) => {
                    Console.WriteLine("In app billing processing error {0}",message);
                };

                // Load inventory or available products
                await GetInventory();

                // Load any items already purchased
                UpdatePurchasedItems();
            };

			// Create our OpenGL view, and display it
			Game1.Activity = this;
			var g = new Game1 ();
			SetContentView (g.Window);
			g.Run ();
        }