Book Image

OUYA Game Development by Example

By : John Donovan
Book Image

OUYA Game Development by Example

By: John Donovan

Overview of this book

The OUYA console and development kit gives you the power to publish video games for the players, creating a console marketplace of the gamers, for the gamers, and by the gamers. Using the OUYA developer kit and the Unity3D game engine, even beginners with a captivating game idea can bring it to life with a hint of imagination. OUYA Game Development by Example uses a series of feature-based, step-by-step tutorials that teach beginners how to integrate essential elements into a game engine and then combine them to form a polished gaming experience.
Table of Contents (18 chapters)
OUYA Game Development by Example Beginner's Guide
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – saving and loading successful purchases


As entitlements such as full game unlocks are only purchased once and are expected to be part of a game forever, we need to save the record of our purchase when it's made and check if it exists every time the game is booted up. This is where we'll make use of the OUYA storage API that we mentioned in Chapter 6, Saving Data to Create Longer Games, because the data stored in it can exist even after the game is uninstalled and reinstalled. This way, a full game will still be unlocked even on a second installation. Perform the following steps to save and load successful purchases:

  1. Add the following lines to your OuyaPurchaseOnSuccess callback function to store a value for the passed-in product:

    public void OuyaPurchaseOnSuccess(OuyaSDK.Product product)
    {
      OuyaSDK.OuyaJava.JavaPutGameData(product.name, product.identifier);
    }

    We used two properties of the product variable, the name and the identifier, to set the key and value of the data...