Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering Unity 2D game development

You're reading from   Mastering Unity 2D game development Mastering Unity 2D Game Development will give your game development skills a boost and help you begin creating and building an RPG with Unity 2D game framework

Arrow left icon
Product type Paperback
Published in Aug 2014
Publisher
ISBN-13 9781849697347
Length 474 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
 Jackson Jackson
Author Profile Icon Jackson
Jackson
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Mastering Unity 2D Game Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
1. Overview FREE CHAPTER 2. Character Building 3. Getting Animated 4. The Game World 5. NPCs and Interactions 6. The Big Wild World 7. Encountering Enemies and Running Away 8. Shopping for Weapons 9. Getting Ready to Fight 10. The Battle Begins 11. Onward Wary Traveler 12. Deployment and Beyond Additional Resources Index

One last thing


Now that the player has left home, found some nasty goblins, and run away, it would be nice if he didn't encounter anymore until he next leaves home.

So using the additional flag PlayerReturningHome we set in the GameState class, we can set this in the battle manager when the player hits the button. We also then need to unset this when the player leaves home again. So, update the OnGUI method in the battle manager to set the PlayerReturningHome flag to true.

Then for the home scene, set the flag to false when the player leaves. This can be achieved by either editing an existing script in the home scene or adding a new one to change the flag state in the OnDestroy method mentioned earlier, or update the NavigationManager script to set the flag when the player travels home. It is your choice. In the sample code, I have added this to the NavigationManager script, as shown in the updated NavigateTo method here:

public static void NavigateTo(string destination)
{
if (destination ...
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 £13.99/month. Cancel anytime
Visually different images