售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Mastering Unity 2D Game Development
Table of Contents
Mastering Unity 2D Game Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Overview
Getting assets
Collection of sites
Welcome to 2D
The new 2D mode
Sprites
Sprite Renderer
Sprite Editor
Spritesheets
Texture atlases
Sprite meshes
The Box2D physics system
The new animation Dope Sheet
Other Unity 4.3 improvements
Improved Mecanim performance
The Windows Phone API improvements and Windows 8.1 support
Dynamic Nav Mesh (Pro version only)
Editor updates
MonoDevelop 4.01
Movie textures
Summary
2. Building a Character
Getting your project started – the right way
Structure
Object naming
Understanding components
Accessing components using a shortcut
A better way to use components – referencing
An even better way
Creating the project
Classes
The object-orientated design
The game structure
The common game object
The player object
More later
Planning behaviors
Behaviors for the common game object
Behaviors for the player's character
Introducing the Unity sprite system
Importing sprites
Texture type – sprite
Sprite Mode – single/multiple
Packing tag
Pixels to units
The Sprite Editor button
Sprite Editor
Sprite splitter (slicer)
Automatic
Grid (manual)
View controls
Sprite region manipulation
Putting it together
Importing our main character
The hero
Controlling the hero
Going further
Summary
3. Getting Animated
Sprite animation
Animation components
Animation controllers
Animation clips
The Animator component
Setting up animation controllers
Setting up animation clips
Manual animation clip creation
Automatic animation clip creation
Animator Dope Sheet
The time/recording controls
Selecting the animation clip
The sample rate (frames per second)
Animation properties
Timeline
Dope/curve view
Putting it together
Setting up the animation controller
Adding your first animation clip (idle)
Adding another animation clip (run)
Connecting animation states
Accessing controllers from a script
Extra credit
Getting curvy
Going further
Summary
4. The Game World
Backgrounds and layers
To slice or not to slice
The town background
The town buildings
The extra scenery
Building the scene
Adding the town background
Sprite sorting layers
Sprite sorting order
Updating the scene Sorting Layers
Working with the camera
Comparing Update, FixedUpdate, and LateUpdate
The perils of resolution
A better FollowCamera script
Transitioning and bounds
Towns with borders
Journeying onwards
Planning for the larger picture
Backgrounds and active elements
Parallaxing
Foreground objects
Shaders and 2D
Going further
Summary
5. NPCs and Interactions
Considering an RPG
Advanced programming techniques
Singletons and managers
The manager approach – using empty game objects
The singleton approach – using the C# singleton pattern
Communicating between game objects
Delegates
The configurable method pattern
The delegation pattern
Compound delegates
Events
Messaging
A better way
Background tasks and Coroutines
Enter Coroutines
IEnumerator
Yielding
Starting Coroutines
Closing the gap
Serialization and scripting
Saving and managing asset data
Using the serialized files in the editor
Accessing the .asset files in the code
Putting it all together
Getting the NPC's talking
The conversation object
Saving and serializing the object for later
The Conversation Component
Building a basic conversation system
The manager
Starting a conversation
Displaying the conversation
Adding more
Connecting the dots
Going further
Summary
6. The Big Wild World
The larger view
Types of maps
Fixed maps
Generated maps
In-game generated maps
2D doesn't mean you have to use only 2D
Going procedural
Screen space and world space
Putting it together
Adding the map
Adding places of interest
Creating the MapPoint prefabs for reuse
Updating the NavigationPrompt script
Updating the NavigationManager script
Traveling by click or touch
Managing input
Managing input priorities
Managing input order
Getting curvy
Fixing the start location
Traveling too far
Transitions
Updating level loading to use fading
Updating build settings to include new scenes
Going further
Summary
7. Encountering Enemies and Running Away
Event systems
Exploring randomness
Planning for random code/generation
True randomness
Basic Artificial Intelligence
State machines
Defining states
Simple singular choice
Planning for multiple cases
State managers
Sensors
Putting it together
Building the new scene
Adding the first enemy
Spawning the horde
Getting back home
The missing random piece
One last thing
Going further
Summary
8. Shopping for Weapons
Why do we shop?
The power of an item
Building your shop
Laying out your inventory
Rule of '99
Encumbrance system
Slot-based system
A mini game
Real world
Getting paid
Paid
Paid with trial
Ad supported
In-app purchase
In-game currency
Putting it together
Gathering the shop assets
Building the shop scene
Creating inventory items
Managing the shop
Adding 2D button behaviors
Updating the player inventory definition
Stocking the shop
Leaving the shop
Entering the shop
Managing your inventory
Adding the Player inventory behavior
Going further
Summary
9. Getting Ready to Fight
Efficient RPG UI overlays
The adventurer's overlay
A context-sensitive overlay
Modern floating UI approach
Balancing the need
Putting it together
The battle state manager
Getting to the state manager in the code
Starting the battle
Adding a little flair
Bring on the GUI
The command bar
The command button
Adding the command bar to the scene
Selecting the weapon
Selecting a command button
Managing the selections from the command bar
Updating the BattleManager state with selections
Updating the BattleManager state with a weapon
Going further
Summary
10. Fight and Gain XP
Proving ground
Leveling up
Balancing
Putting it together
Preparing the BattleManager script
Beefing up the enemy
The enemy profile/controller
Updating the Goblin prefab
Setting up the enemy profile in the code
Selecting a target
The selection circle prefab
Adding selection logic to the EnemyController class
Attack! Attack!
The pesky Goblin reacts with 3D particles
Mixing up 2D and 3D
Particle effects and 2D
Adding the deathly sprites
Creating the material for the particle effect
Restructuring the Goblin prefab
Adding the particles
The death animation
Adding particles to the animation
Connecting the dots
Making the new GoblinEnemy game object a prefab and adding it to the battle
Houston, we have a problem!
Mecanim AI considerations
Animation, states, and looping
The final run-through
Going further
Summary
11. Onward Wary Traveler
Extending the editor
The property drawers
Property drawers examples
Built-in property drawers
Custom property drawers
Custom editors
The editor window
Gizmos
Building your editor menus
Adding a MenuItem attribute
Enabling/disabling a MenuItem attribute
Adding shortcut keys to a MenuItem attribute
Adding contextual MenuItems
Running scripts in the Editor folder
Alternative approaches
The [InitialiseOnLoad] attribute
The EditorApplication callbacks
Mixing it up
Building in-game menu structures
The screens
Splash screens
Loading screens
The main menu
Save slots/level selections
Settings pages
About the screen
Privacy policy
Pause screens
Additionals (purchasing, achievements, leaderboards, and so on)
Social
The flow
Working with settings
Using PlayerPrefs
Serializing your data
Saving data to disk
Modeling your saved data
Making your game save and load functions
Testing your Save and Load functions
Backing up to the Web
Going further
Summary
12. Deployment and Beyond
Handling platform differences
Preprocessor directives
Updating the save system for another platform
Build note
Getting access to Unity
Accessing the UnityEngine namespace
The static classes
Access to the platform
Static events in your Unity project
Embedding platform DLLs
The editor plugin (.NET only)
The platform plugin
Accessing the plugin
Native plugins (Pro only)
Pushing code from Unity3D
Processing assets
Processing the build
Building your assets
Packaging gotchas
Marketing your game
Summary
A. Additional Resources
Scripting resources
Extending the editor
Even more AI
Procedural generation
Advanced coding
Other scripting resources
Useful assets
Sources of art and SFX
Highlights from the Web
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜