万本电子书0元读

万本电子书0元读

顶部广告

Learning C# by Developing Games with Unity 5.x - Second Edition电子书

售       价:¥

8人正在读 | 0人评论 9.8

作       者:Greg Lukosek

出  版  社:Packt Publishing

出版时间:2016-03-31

字       数:58.2万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Develop your first interactive 2D platformer game by learning the fundamentals of C# About This Book Get to grips with the fundamentals of *ing in C# with Unity Create an awesome, 2D platformer game from scratch using the principles of object-oriented programming and coding in C# This is a step-by-step guide to learn the fundamentals of C# *ing to develop GameObjects and master the basics of the new UI system in Unity Who This Book Is For The book is targeted at beginner level Unity developers with no programming experience. If you are a Unity developer and you wish to learn how to write C# *s and code by creating games, then this book is for you. What You Will Learn Understand the fundamentals of variables, methods, and code syntax in C# Get to know about techniques to turn your game idea into working project Use loops and collections efficiently in Unity to reduce the amount of code Develop a game using the object-oriented programming principles Generate infinite levels for your game Create and code a good-looking functional UI system for your game Publish and share your game with users In Detail Unity is a cross-platform game engine that is used to develop 2D and 3D video games. Unity 5 is the latest version, released in March 2015, and adds a real-time global illumination to the games, and its powerful new features help to improve a game’s efficiency. This book will get you started with programming behaviors in C# so you can create 2D games in Unity. You will begin by installing Unity and learning about its features, followed by creating a C# *. We will then deal with topics such as unity *ing for you to understand how codes work so you can create and use C# variables and methods. Moving forward, you will find out how to create, store, and retrieve data from collection of objects. You will also develop an understanding of loops and their use, and you’ll perform object-oriented programming. This will help you to turn your idea into a ready-to-code project and set up a Unity project for production. Finally, you will discover how to create the GameManager class to manage the game play loop, generate game levels, and develop a simple UI for the game. By the end of this book, you will have mastered the art of applying C# in Unity. Style and approach This is a step-by-step guide to developing a game from scratch by applying the fundamentals of C# and Unity *ing.
目录展开

Learning C# by Developing Games with Unity 5.x Second Edition

Table of Contents

Learning C# by Developing Games with Unity 5.x Second Edition

Credits

About the Author

About the Reviewer

www.PacktPub.com

eBooks, discount offers, and more

Why subscribe?

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. Discovering Your Hidden Scripting Skills and Getting Your Environment Ready

Prerequisite knowledge to use this book

Dealing with scriptphobia

Downloading Unity

Obtaining a free license

Teaching behavior to GameObjects

Using Unity's documentation

Do I need to know all that?

C# documentation – where to find it? Do I need it at all?

The Unity community – asking others for help

Working with C# script files

Lots of files can create a mess

Why does my Project tab look different?

Creating a C# script file

Introducing the MonoDevelop code editor

Syncing C# files between MonoDevelop and Unity

Opening LearningScript in MonoDevelop

The namespace – highlighted in blue

The class definition – highlighted in green

Watching for possible gotchas while creating script files in Unity

Fixing synchronization if it isn't working properly

Adding our script to GameObject

Instance? What is it?

Summary

2. Introducing the Building Blocks for Unity Scripts

Understanding what a variable is and what it does

Naming a variable

A variable name is just a substitute for a value

Creating a variable and seeing how it works

Declaration

Assignment

Click on Play!

Changing variables

Watching for a possible gotcha when using public variables

What is a method?

Using the term "method" instead of "function"

Method names are substitutes, too

Introducing the class

Inheritance

The Start(), Update(), and Awake() methods and the execution order

Components that communicate using dot syntax

What's with the dots?

Making decisions in code

Using the NOT operator to change the condition

Checking many conditions in an if statement

Using else if to make complex decisions

Making decisions based on user input

Paper and pencil are powerful tools


Summary

3. Getting into the Details of Variables

Writing C# statements properly

Understanding component properties in Unity's Inspector

Variables become component properties

Unity changes script and variable names slightly

Changing a property's value in the Inspector panel

Displaying public variables in the Inspector panel

Private variables

Naming your variables properly

Beginning variable names with lowercase

Using multiword variable names

Declaring a variable and its type

The most common built-in variable types

Assigning values while declaring a variable

Where you declare a variable is important

Variable scope – determining where a variable can be used

Summary

4. Getting into the Details of Methods

Using methods in a script

Naming methods properly

Beginning method names with an uppercase letter

Using multiword names for a method

Parentheses are part of the method's name

Defining a method the right way

The minimum requirements for defining a method

Understanding parentheses – why are they there?

Specifying a method's parameters

How many parameters can a method have?

Returning a value from a method

Returning the value

Example

Summary

5. Lists, Arrays, and Dictionaries

What is an array?

Declaring an array

Storing items in the List

Common operations with Lists

List<T> versus arrays

Retrieving the data from the Array or List<T>

Checking the size

ArrayList

Dictionaries

Accessing values

How do I know what's inside my Hashtable?

Summary

6. Loops

Introduction to loops

The foreach loop

The for loop

An example

The while loop

while versus for loops

Loops in statements

Modulo

Searching for data inside an array

Breaking the loop

Summary

7. Object, a Container with Variables and Methods

Working with objects is a class act

Few facts

Example

Instantiating an object

Bored yet?

Using methods with objects

Custom constructors

Overloading

Summary

8. Let's Make a Game! – From Idea to Development

Your first game – avoiding the trap of the never-ending concept

The idea

Game mechanics and core components

Breaking a complex idea into smaller parts

Jake on the mysterious planet – the feature list

Procedural level generation

An animated 2D character

Physics

Mouse and touch controls

Collectables and obstacles

Scoring

UI – the user interface

Target platform and resolution

Target screen resolution

Summary

9. Starting Your First Game

Setting up a new Unity project for our game

Backup

Keeping your project clean

Preparing the player prefab

Rigidbody2D

CircleCollider2D

PlayerController

User input

Jump

Animator

Running

Code

PlayerController.cs

Summary

10. Writing GameManager

Gameplay loops

Singleton class

Starting the game

Setting up input keys

Using triggers

Restarting the game

Setting up the player starting position

Code in this chapter

Summary

11. The Game Level

Generating levels versus designed levels

Creating a level chunk

Planning the LevelGenerator class

Writing LevelGenerator

Commenting on your code

Creating a copy of the level piece

Instantiating

Vector3

Testing LevelGenerator

Extending the level

The code used in this chapter

Summary

12. The User Interface

Introducting the Unity UI

Views

Constructing the view UI – how to keep things clean

Target screen resolution

Recognizing events

Buttons

A simple button

Image

The Button component

Interaction

The Button action

Hiding and showing the Canvas

Reference exceptions

GameView

Game Over

The code in this chapter

Summary

13. Collectables — What Next?

Collectables

The coin prefab

The Collectable class

High score and persisting data

The Update function and UI values

What next?

The code in this chapter

Summary

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部