Learning C# by developing games with unity 3D beginner's guide learn the fundamentals of C# to create scripts for your GameObjects

The beauty of this book is that it assumes absolutely no knowledge of coding at all. Starting from very first principles it will end up giving you an excellent grounding in the writing of C# code and scripts. You've actually been creating scripts in your mind your whole life, you just didn'...

Descripción completa

Detalles Bibliográficos
Autor principal: Norton, Terry (-)
Formato: Libro electrónico
Idioma:Inglés
Publicado: Birmingham, England : Packt Publishing 2013.
Edición:1st edition
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009628049506719
Tabla de Contenidos:
  • Intro
  • Learning C# by Developing Games with Unity 3D Beginner's Guide
  • Table of Contents
  • Learning C# by Developing Games with Unity 3D Beginner's Guide
  • Credits
  • About the Author
  • 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
  • Time for action - heading
  • What just happened?
  • Pop quiz - heading
  • Have a go hero - heading
  • Reader feedback
  • Customer support
  • Downloading the example code
  • Errata
  • Piracy
  • Questions
  • 1. Discovering Your Hidden Scripting Skills
  • Prerequisite knowledge for using this book
  • Dealing with scriptphobia
  • Teaching behaviors to GameObjects
  • Choosing to use C# instead of UnityScript
  • Reason 1 for choosing C# - vast amount of documentation on the Internet
  • Reason 2 for choosing C# - flexibility to use Unity scripts and regular C# code files
  • Reason 3 for choosing C# - coding rules are specific
  • Maneuvering around Unity's documentation
  • Time for action - opening the Reference Manual documentation for the transform Component
  • What just happened?
  • Time for action - opening the scripting reference documentation for the transform component
  • What just happened?
  • Are we really supposed to know all that stuff?
  • What is all that information?
  • Working with C# script files
  • Time for action - create a C# script file
  • What just happened?
  • Introducing the MonoDevelop code editor
  • Syncing C# files between MonoDevelop and Unity
  • Time for action - opening LearningScript in MonoDevelop
  • What just happened?
  • Watching for a possible "gotcha" when creating script files in Unity
  • Fixing sync if it isn't working properly
  • Pop quiz - dealing with scripts
  • Summary.
  • 2. Introducing the Building Blocks for Unity Scripts
  • Using the term method instead of function
  • Understanding what a variable does in a script
  • Naming a variable
  • A variable name is just a substitute for a value
  • Time for action - creating a variable and seeing how it works
  • What just happened?
  • Time for action - changing the number 9 to a different number
  • What just happened?
  • Have a go hero - changing the value of myNumber
  • Using a method in a script
  • What is a method?
  • Time for action - learning how a method works
  • What's in this script file?
  • Method names are substitutes too
  • What just happened?
  • Have a go hero - changing the output of the method
  • Introducing the class
  • By using a little Unity magic, a script becomes a Component
  • A more technical look at the magic
  • Even more Unity magic
  • Have a go hero - finding Start and Update in the Scripting Reference
  • Components communicating using the Dot Syntax
  • What's with the dots?
  • Pop quiz - knowing the C# building blocks
  • 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
  • Time for action - making a variable private
  • What just happened?
  • Naming your variables properly
  • Begin variable names with lowercase
  • Using multi-word variable names
  • Have a go hero - viewing multi-word variables in the Inspector panel
  • Declaring a variable and its type
  • The most common built-in variable types
  • Time for action - assigning values while declaring the variable
  • What just happened?
  • Where you declare a variable is important.
  • Variable scope - determining where a variable can be used
  • Pop quiz - knowing how to declare a variable
  • Summary
  • 4. Getting into the Details of Methods
  • Ending a method definition using curly braces
  • Using methods in a script
  • Naming methods properly
  • Begin method names with an uppercase letter
  • Using multi-word names for a method
  • Parentheses are part of the method name
  • Defining a method properly
  • The minimum requirements for defining a method
  • Understanding parentheses - why are they there?
  • Time for action - adding code between the parentheses
  • What just happened?
  • Specifying a method's parameters
  • How many parameters can a method have?
  • Calling a method
  • Using arguments in the parentheses of a method
  • Returning a value from a method
  • Time for action - returning a value from AddTwoNumbers()
  • What just happened?
  • Have a go hero - add two more numbers together
  • Calling a method is a logic detour
  • Using Unity's Update and Start methods
  • The Start method is called one time
  • The Update method is called over and over and over…
  • Pop quiz - understanding method operation
  • Summary
  • 5. Making Decisions in Code
  • Testing conditions with an if statement
  • Testing if conditions are true or false
  • Time for action - create a couple of if statements
  • What just happened?
  • Using the NOT operator to change the condition
  • Checking many conditions in an if statement
  • Time for action - create if statements with more than one condition to check
  • What just happened?
  • Have a go hero - change the value assigned to temperature
  • Have a go hero - change theBearMadeBigPottyInTheWoods to false
  • Using an if-else statement to execute alternate code
  • Time for action - add "else" to the if statement
  • What just happened?
  • Pop quiz - understanding if statements.
  • Making decisions based on user input
  • Storing data in an array, a List, or a Dictionary
  • Storing items in an array
  • Storing items in a List
  • Time for action - create a List of pony names
  • What just happened?
  • Have a go hero - add another pony to the List
  • Storing items in a Dictionary
  • Time for action - create a dictionary of pony names and keys
  • What just happened?
  • Using a Collection Initializer to add items to a List or Dictionary
  • Time for action - adding ponies using a Collection Initializer
  • What just happened?
  • Pop quiz - understanding an array and a List
  • Looping though lists to make decisions
  • Using the foreach loop
  • Time for action - using foreach loops to retrieve data
  • What just happened?
  • Using the for loop
  • Time for action - selecting a pony from a List using a for loop
  • What just happened?
  • Using the while loop
  • Time for action - finding data and breakout of the while loop
  • What just happened?
  • Have a go hero - changing the pony name being searched
  • Summary
  • 6. Using Dot Syntax for Object Communication
  • Using Dot Syntax is like addressing a letter
  • Simplifying the dots in Dot Syntax
  • Using access modifiers for variables and methods
  • Working with objects is a class act
  • Using Dot Syntax in a script
  • Accessing a Component's own variables and methods
  • Time for action - accessing a variable in the current Component
  • What just happened?
  • Accessing another Component on the current GameObject
  • Time for action - communicating with another Component on the Main Camera
  • What just happened?
  • Accessing other GameObjects and their Components
  • Time for action - creating two GameObjects and a new script
  • What just happened?
  • On LearningScript:
  • Have a go hero - creating and using a new variable named capsuleComp.
  • Accessing GameObjects using drag-and-drop versus writing code
  • Time for action - trying drag-and-drop to assign a GameObject
  • What just happened?
  • Pop quiz - understanding communication between objects
  • Summary
  • 7. Creating the Gameplay is Just a Part of the Game
  • Applying your new coding skills to a State Machine
  • Understanding the concepts of a State Machine
  • Benefits of by using a State Machine
  • Following the State Machine logic flow
  • Delegating game control to a State
  • Switching to another State when called to do so
  • Keeping track of the active State
  • Creating Components objects and C# objects
  • Unity creates Components behind the scenes
  • Instantiate a class to create an object
  • Time for action - creating a script and a class
  • What just happened?
  • Time for action - instantiating the BeginState class
  • What just happened?
  • Specifying a file's location with a namespace declaration
  • Locating code files with a using statement
  • Introducing the C# interface
  • The State Machine and the interface guarantee
  • Time for action - implementing an interface
  • What just happened?
  • Have a go hero - adding another method to the interface
  • Pop quiz - using a State Machine for game control
  • Summary
  • 8. Developing the State Machine
  • Creating four State classes
  • Time for action - modifying BeginState and add three more States
  • What just happened?
  • Setting up the StateManager controller
  • Studying an example of inheritance
  • Enter the IStateBase interface again
  • Time for action - modify StateManager
  • What just happened?
  • Summarizing the code flow
  • Adding another State
  • Time for action - modifying PlayState to add another State
  • What just happened?
  • Adding OnGUI to the StateManager class
  • Time for action - adding OnGUI to StateManager
  • What just happened?.
  • Changing the active State and controlling the Scene.