Reader small image

You're reading from  Ouya Unity Game Development

Product typeBook
Published inOct 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781783559701
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Gary Riches
Gary Riches
author image
Gary Riches

Gary Riches is a longstanding member of the iOS developer community. He has a keen interest not only in established sections of the industry such as gaming but also in emerging technologies such as Ouya, GameStick, and others. Filled with a passion to program on new systems, he has just become a registered Wii U developer and will also create content for Xbox One and PlayStation 4. To target so many platforms he uses Unity, which he learned while working on the Augmented Reality SBook for Saddington Baynes. When not building software for other companies, he builds his own business by creating photo manipulation apps such as Zombify Me, games such as Aztec Antics and Amazed, and also works on educational apps and games such as Nursery Rhymes: Volume 1, 2, and 3.
Read more about Gary Riches

Right arrow

Chapter 6. Show Me the Money!

We now have a game. You could give it away for free but the Ouya also supports In-App Purchase. There are two types of In-App Purchase:

  • An entitlement: This is a great way of letting players try out your game and then, if they like it, unlocking new features or levels with a one-off payment.

  • A consumable: This is usually represented as coins, gems, or some other kind of in-game currency. They can be used, and as the name suggests, consumed.

This chapter assumes you have set up a company and entered all your tax information on the Ouya website. If not then you can only give your game away for free and you can skip this chapter.

Setting up your purchase


Before we can dive in to Unity and get started with coding, we're going to have to use the Ouya website to create our In-App Purchase. Log in to the Ouya Developer Portal at https://devs.ouya.tv/developers and click on the Products option from the top menu. It will take you to a screen where you need to complete the following fields:

  • Identifier: Call it SokobanUnlock.

  • Name: This is the name that the player will see. Call it Sokoban – Full Unlock.

  • Price: It can be difficult choosing the price for your game. It's better to start a little higher, that way you can always offer sales at a later date. Set it to 1.99.

  • Type: This is going to be a one off purchase so set it to Entitlement.

When you've entered all that information, click on Create Product and you'll be taken back to the Products screen.

The Ouya store will pay you when your game earns over $150, and the payments will come 30 days after the month in which the money was earned. The Ouya store takes 30% of the...

Setting up your game


To perform any In-App Purchase, your game must also be signed with a key.der file. Ouya will generate this file for you after you create a listing for your game on their website.

While we're on the Ouya website, let's do that too. Go to https://devs.ouya.tv/developers/games and click on Add a Game. Add the values to the following fields:

  • Title: Sokoban 3D, if this is taken use a name of your liking—currently the Ouya platform is allowing duplicate application names although this is likely to change.

  • Android package name: com.generic.sokoban, if this is taken use a name of your liking. Currently the Ouya platform is allowing you to submit duplicate bundle IDs although this is also likely to change. If you do change your bundle ID then revisit Chapter 2, Setting Up Unity and the Ouya Plugin, and follow the steps to set up your new bundle ID in Unity.

  • OUYA exclusive: No – if your app is going to only come out on Ouya then set this to Yes. We will be converting our game to...

Implementing the Ouya payment framework


The Ouya examples provide a really good stub class for your In-App Purchase needs, we'll import that in to our project as a base for the code. The file is located in the folder where you installed the Ouya Unity repository to in Chapter 2, Setting Up Unity and the Ouya Plugin. From inside that folder navigate to Assets\Ouya\Examples\Scripts and drag the OuyaShowProducts file in to the Scripts folder in our Project panel. Double-click on it to edit it in MonoDevelop, and have a look at the method names to become familiar with the method names that we will need to call and respond to. At the moment we're going to use the script as it is. There is some code already in the script that will build a Graphical User Interface (GUI) and display a menu system for seeing your products.

Back in Unity, open your SetUp scene and add a new, empty game object to it. Call it IAP and drag your OuyaShowProducts script on to it. We need to make sure that this new, empty...

Submitting your game


We're almost ready to submit our game but we just need to do one final thing: replace the icon. The default Ouya icon is at (your game project folder)\Assets\Plugins\Android\res\drawable-xhdpi\ouya_icon.png and it's a 732 x 412 pixels PNG file. Replace it with the icon of your choice and then go to the build settings by navigating to File | Build Settings… and click on Build and type a name for the file in the text field, and then click on Save.

Now that's saved we need to go back to the My Games page on the Ouya website and click on Edit. Add some screenshots; they need to be 1280 pixels wide by 720 pixels high and you need a minimum of three; can submit up to nine. Scroll down to the bottom and click on Upload APK, then follow the on-screen instructions, once the upload is complete click on Save. This will take you back to the My Games page where you'll most likely see that Ouya are still verifying your APK. Give it a few minutes and then refresh the page, the warnings...

Summary


Our game is now complete! Pour yourself a drink of your choice and give your game a play. It's pretty sweet, huh? We have successfully implemented an entitlement In-App Purchase but what about the other type mentioned at the start of this chapter? You can read all the Ouya documentation on In-App Purchases at https://devs.ouya.tv/developers/docs/purchasing. Next, let's look at what it takes to get our app running on an Android phone or tablet.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Ouya Unity Game Development
Published in: Oct 2013Publisher: PacktISBN-13: 9781783559701
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Gary Riches

Gary Riches is a longstanding member of the iOS developer community. He has a keen interest not only in established sections of the industry such as gaming but also in emerging technologies such as Ouya, GameStick, and others. Filled with a passion to program on new systems, he has just become a registered Wii U developer and will also create content for Xbox One and PlayStation 4. To target so many platforms he uses Unity, which he learned while working on the Augmented Reality SBook for Saddington Baynes. When not building software for other companies, he builds his own business by creating photo manipulation apps such as Zombify Me, games such as Aztec Antics and Amazed, and also works on educational apps and games such as Nursery Rhymes: Volume 1, 2, and 3.
Read more about Gary Riches