Book Image

Mastering Unity 2D Game Development - Second Edition

By : Ashley Godbold, Simon Jackson
Book Image

Mastering Unity 2D Game Development - Second Edition

By: Ashley Godbold, Simon Jackson

Overview of this book

The Unity engine has revolutionized the gaming industry, by making it easier than ever for indie game developers to create quality games on a budget. Hobbyists and students can use this powerful engine to build 2D and 3D games, to play, distribute, and even sell for free! This book will help you master the 2D features available in Unity 5, by walking you through the development of a 2D RPG framework. With fully explained and detailed C# scripts, this book will show you how to create and program animations, a NPC conversation system, an inventory system, random RPG map battles, and full game menus. After your core game is complete, you'll learn how to add finishing touches like sound and music, monetization strategies, and splash screens. You’ll then be guided through the process of publishing and sharing your game on multiple platforms. After completing this book, you will have the necessary knowledge to develop, build, and deploy 2D games of any genre!
Table of Contents (20 chapters)
Mastering Unity 2D Game Development - Second Edition
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface

Setting up our battle state manager


The most unique and important part of a turn-based battle system is the turns. Controlling the turns is incredibly important and we will need something to handle the logic behind the actual turns for us. We'll accomplish this by creating a battle state machine.

The battle state manager

Starting back in our BattleScene, we need to create a state machine using all of Mecanim's handy features. Although we will still only be using a fraction of the functionality with the RPG sample, I advise you to investigate and read more about its capabilities.

Navigate to the Assets\Animation\Controllers folder and create a new Animator Controller called BattleStateMachine, then we can begin putting together the battle state machine. The following screenshot shows you the states, transitions, and properties that we will need:

As shown in the preceding screenshot, we have created eight states to control the flow of a battle with two Boolean parameters to control its transition...