Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Ouya Unity Game Development

You're reading from   Ouya Unity Game Development Understanding Unity means you can quickly get the know-how to develop games for the Android-based Ouya console. This is the guide that will take you all the way from setting up the software to monetizing your games.

Arrow left icon
Product type Paperback
Published in Oct 2013
Publisher Packt
ISBN-13 9781783559701
Length 118 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Gary Riches Gary Riches
Author Profile Icon Gary Riches
Gary Riches
Arrow right icon
View More author details
Toc

Level complete detection


It's all well and good having three levels, but without a mechanism to move between them they are useless. We are going to add a check to see if the player has finished a level, if they have then increment the level counter and load the next level in the array. We only need to do the check at the end of every move; to do so every frame would be redundant.

We'll write the following method first and then explain it:

// If this method returns true then we have finished the level
boolhaveFinishedLevel () {
  // Initialise the counter for how many crates are on goal 
  // tiles
  int cratesOnGoalTiles = 0;
  // Loop through all the rows in the current level
  for (int i = 0; i< levels[currentLevel].Length; i++) {
    // Get the tile ID for the column and pass it the switch 
    // statement
    for (int j = 0; j < levels[currentLevel][i].Length; j++) {
      switch (levels[currentLevel][i][j]) {
        case 5:
        // Do we have a match for a crate on goal 
 ...
lock icon The rest of the chapter is locked
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.
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 $19.99/month. Cancel anytime
Banner background image