You are previewing Learning C# Programming with Unity 3D.
O'Reilly logo
Learning C# Programming with Unity 3D

Book Description

Designed to give you enough familiarity in a programming language to be immediately productive, Learning C# Programming with Unity 3D provides the basics of programming and brings you quickly up to speed. Organized into easy-to-follow lessons, the book covers how C# is used to make a game in Unity3D. After reading this book, you will be armed with the knowledge required to feel confident in learning more. You’ll have what it takes to at least look at code without your head spinning.

Writing a massive multiplayer online role-playing game is quite hard, of course, but learning how to write a simple behavior isn’t. Like drawing, you start off with the basics such as spheres and cubes. After plenty of practice, you’ll be able to create a real work of art. This applies to writing code—you start off with basic calculations, then move on to the logic that drives a complex game. By the end of this book, you will have the skills to be a capable programmer, or at least know what is involved with how to read and write code.

Although you could go online and find videos and tutorials, there is a distinct advantage when it comes to learning things in order and in one place. Most online tutorials for C# are scattered, disordered, and incohesive. It’s difficult to find a good starting point, and even more difficult to find a continuous list of tutorials to bring you to any clear understanding of the C# programming language. This book not only gives you a strong foundation, but puts you on the path to game development.

Table of Contents

  1. Acknowledgments
  2. Chapter 1 - Introduction: What This Book Is About
    1. 1.1 Why Read a Book: Why This Book May or May Not Be for You
      1. 1.1.1 Do I Need to Know Math?
      2. 1.1.2 Programming as a Form of Expression
      3. 1.1.3 Games as a Stage with Lights
    2. 1.2 Personal Information
      1. 1.3.1 Mechanical Computers
      2. 1.3.2 Logic
      3. 1.3.3 Computer Science
      4. 1.3.4 Software
      5. 1.3.5 Modern Computer Language
      6. 1.3.6 The Future of Computer Languages
    3. 1.4 C#: A Flexible Programming Language
      1. 1.4.1 C# Paradigm
      2. 1.4.2 Unity 3D: A Brief History of Game Engines
      3. 1.4.3 Why Use Unity 3D to Learn?
      4. 1.4.4 How Does Unity 3D Use C#?
        1. 1.4.4.1 How to Tell Unity 3D What to Do
    4. 1.5 What Is Programming?
      1. 1.5.1 What Does C# Look Like?
      2. 1.5.2 Learning to Copy and Paste
    5. 1.6 Compiling: Turning Words into Computer Instruction
    6. 1.7 What We’ve Learned
    7. 1.8 Leveling Up
  3. Chapter 2 - Before You Begin
    1. 2.1 What Will Be Covered in This Chapter
    2. 2.2 Downloading and Installing: It Is Free
    3. 2.3 Unity 3D Overview: What We’re Looking At
      1. 2.3.1 The Main Panel
        1. 2.3.1.1 Toolbar
        2. 2.3.1.2 Hierarchy Panel
        3. 2.3.1.3 Scene and Game View
        4. 2.3.1.4 Inspector Panel
        5. 2.3.1.5 Project and Console Panel
      2. 2.3.2 Creating a New Project
      3. 2.3.3 A New Unity 3D Project
        1. 2.3.3.1 Assets Directory
        2. 2.3.3.2 Library Directory
        3. 2.3.3.3 Project Settings Directory
        4. 2.3.3.4 Temp Directory
      4. 2.3.4 Summary
    4. 2.4 Sample Code
      1. 2.4.1 Code Fragments
      2. 2.4.2 Are Errors Bad?
        1. 2.4.2.1 Compile-Time and Run-Time Errors
      3. 2.4.3 How to Follow Along
      4. 2.4.4 Summary
    5. 2.5 Working with C#: Game Engines
      1. 2.5.1 Getting Project Files
      2. 2.5.2 Creating and Assigning a New C# File: Now It’s Your Turn
      3. 2.5.3 Naming Your New File
      4. 2.5.4 Using Your New File
      5. 2.5.5 Unity 3D Tools
      6. 2.5.6 Running Live Code
      7. 2.5.7 Saving a Scene
      8. 2.5.8 Opening a Scene
      9. 2.5.9 Summary
    6. 2.6 What We’ve Learned
    7. 2.7 Leveling Up
  4. Chapter 3 - First Steps
    1. 3.1 What Will Be Covered in This Chapter
    2. 3.2 Review
    3. 3.3 Tokens
      1. 3.3.1 Writing C#
      2. 3.3.2 Separator Tokens
      3. 3.3.3 Operator Tokens
      4. 3.3.4 Other Operator Tokens
      5. 3.3.5 Literals
      6. 3.3.6 Transitive and Non-Transitive Operations
      7. 3.3.7 Putting It All Together
      8. 3.3.8 What We’ve Learned
    4. 3.4 Statements and Expressions
      1. 3.4.1 Expressions
      2. 3.4.2 How Code Is Executed
      3. 3.4.3 Thinking in Algorithms
        1. 3.4.3.1 Wash, Rinse, Repeat
      4. 3.4.4 What We’ve Learned
    5. 3.5 Keywords
      1. 3.5.1 Class
      2. 3.5.2 What We’ve Learned
    6. 3.6 White Space
      1. 3.6.1 Pick a Flavor
      2. 3.6.2 What We’ve Learned
    7. 3.7 Code Blocks
      1. 3.7.1 What We’ve Learned
    8. 3.8 Classes
      1. 3.8.1 Objects
      2. 3.8.2 What We’ve Learned
    9. 3.9 Variables
      1. 3.9.1 Identifiers
      2. 3.9.2 Data
      3. 3.9.3 Declaring a Variable
        1. 3.9.3.1 A Basic Example
      4. 3.9.4 Dynamic Initialization
      5. 3.9.5 What We’ve Learned
    10. 3.10 Variable Names
      1. 3.10.1 UsingVariables in Unity 3D
      2. 3.10.2 Variable Assignment
      3. 3.10.3 Putting It Together
      4. 3.10.4 What We’ve Learned
    11. 3.11 Types: A First Look
      1. 3.11.1 Value and Reference Types
      2. 3.11.2 What We’ve Learned
    12. 3.12 Strong Typing
      1. 3.12.1 Dynamic Typing
      2. 3.12.2 What We’ve Learned
    13. 3.13 Type Casting, Numbers
      1. 3.13.1 Explicit versus Implicit Casting
        1. 3.13.1.1 A Basic Example
      2. 3.13.2 What We’ve Learned
    14. 3.14 Comments
      1. 3.14.1 Line Numbers
      2. 3.14.2 Code Folding
      3. 3.14.3 Summary Comments
      4. 3.14.4 Navigating in Code
      5. 3.14.5 What We’ve Learned
    15. 3.15 Leveling Up: Moving On to Basics
  5. Chapter 4 - Basics: The Building Blocks of Code
    1. 4.1 What Will Be Covered in This Chapter
    2. 4.2 Review
    3. 4.3 Building Up a Game Idea: Working with What You Know
      1. 4.3.1 Design from Experience
        1. 4.3.1.1 Know Yourself
      2. 4.3.2 Primary Activity
      3. 4.3.3 Moment to Moment
      4. 4.3.4 Actions to Functions
      5. 4.3.5 Compromise
      6. 4.3.6 Starting with Controls
      7. 4.3.7 What We’ve Learned
    4. 4.4 Creating a Class
      1. 4.4.1 Class Declaration
        1. 4.4.1.1 A Basic Example
        2. 4.4.1.2 Value and Reference Types
      2. 4.4.2 Adding Data Fields
      3. 4.4.3 Access Modifiers and the Dot Operator
      4. 4.4.4 Class Scope
      5. 4.4.5 Class Members
      6. 4.4.6 What We’ve Learned
    5. 4.5 Directives
      1. 4.5.1 Libraries
      2. 4.5.2 Ambiguous NameSpaces
      3. 4.5.3 What We’ve Learned
    6. 4.6 Functions
      1. 4.6.1 What Are Functions?
      2. 4.6.2 Unity 3D Entry Points
      3. 4.6.3 Writing a Function
        1. 4.6.3.1 A Basic Example
      4. 4.6.4 More on White Space and Tabs
      5. 4.6.5 What We’ve Learned
    7. 4.7 Order of Operation: What Is Calculated and When
      1. 4.7.1 Evaluating Numbers
        1. 4.7.1.1 Math
        2. 4.7.1.2 Operator Evaluation
      2. 4.7.2 What We’ve Learned
    8. 4.8 Scope: A First Look
      1. 4.8.1 Class Scope
      2. 4.8.2 Function Scope
      3. 4.8.3 What We’ve Learned
    9. 4.9 This
      1. 4.9.1 A Basic Example
      2. 4.9.2 When This Is Necessary
      3. 4.9.3 Awkward Names
      4. 4.9.4 What We’ve Learned
    10. 4.10 Turning Ideas into Code—Part 1
      1. 4.10.1 Mouse Input
      2. 4.10.2 GameObject
      3. 4.10.3 What We’ve Learned
    11. 4.11 Logic and Operators
      1. 4.11.1 Booleans
      2. 4.11.2 Equality Operators
        1. 4.11.2.1 A Basic Example
      3. 4.11.3 If and Branching
        1. 4.11.3.1 Not!
      4. 4.11.4 Flowcharts
      5. 4.11.5 Relational Operators
        1. 4.11.5.1 Else
        2. 4.11.5.2 Else If
      6. 4.11.6 Rearranging Logic
        1. 4.11.6.1 Flawed Logic
        2. 4.11.6.2 Unreachable Code
      7. 4.11.7 Another Look at Scope
      8. 4.11.8 What We’ve Learned
    12. 4.12 Loops
      1. 4.12.1 Unary Operators
      2. 4.12.2 While
      3. 4.12.3 For
      4. 4.12.4 Do–While
      5. 4.12.5 Postfix and Prefix Notation
      6. 4.12.6 Using Loops
      7. 4.12.7 Loops within Loops
      8. 4.12.8 Runaway Loops
      9. 4.12.9 Breakpoints: A First Look
      10. 4.12.10 What We’ve Learned
    13. 4.13 Scope, Again
      1. 4.13.1 Visibility or Accessibility
        1. 4.13.1.1 A Basic Example
      2. 4.13.2 Global Scope
      3. 4.13.3 What We’ve Learned
    14. 4.14 Warnings versus Errors
      1. 4.14.1 Warnings
      2. 4.14.2 Errors
      3. 4.14.3 Understanding the Debugger
      4. 4.14.4 What We’ve Learned
    15. 4.15 Leveling Up: Fundamentals
      1. 4.15.1 Style Guides
  6. Chapter 5 - Fundamentals
    1. 5.1 What Will Be Covered in This Chapter
    2. 5.2 Review
      1. 5.2.1 Modular Code
    3. 5.3 Inheritance: A First Look
      1. 5.3.1 Class Members
      2. 5.3.2 Instancing
        1. 5.3.2.1 A Basic Example
      3. 5.3.3 Parent and Child
      4. 5.3.4 Object
        1. 5.3.4.1 A Type Is Not an Object
      5. 5.3.5 != null
      6. 5.3.6 What We’ve Learned
    4. 5.4 Instancing
      1. 5.4.1 Class Initialization
      2. 5.4.2 New
      3. 5.4.3 Constructors
      4. 5.4.4 What We’ve Learned
    5. 5.5 Static
      1. 5.5.1 A Basic Example
      2. 5.5.2 Static Variables
        1. 5.5.2.1 A Basic Example
      3. 5.5.3 Static Functions
      4. 5.5.4 Putting It All Together
      5. 5.5.5 What We’ve Learned
    6. 5.6 Turning Ideas into Code—Part 2
      1. 5.6.1 Input Manager
      2. 5.6.2 What We’ve Learned
    7. 5.7 Jump Statements
      1. 5.7.1 Return
        1. 5.7.1.1 A Basic Example
      2. 5.7.2 Returning Objects
      3. 5.7.3 A Class Is a Type
      4. 5.7.4 Null Is Not Void
      5. 5.7.5 What We’ve Learned
    8. 5.8 Operators and Conditions
      1. 5.8.1 Conditional Operators && and ||
        1. 5.8.1.1 A Basic Example
      2. 5.8.2 What We’ve Learned
    9. 5.9 Arrays: A First Look
      1. 5.9.1 Fixed-Sized Arrays
        1. 5.9.1.1 A Basic Example
      2. 5.9.2 Foreach
        1. 5.9.2.1 A Basic Example
      3. 5.9.3 Dynamic Initialization
      4. 5.9.4 Using the While Loop with Arrays
        1. 5.9.4.1 Setting Array Values
        2. 5.9.4.2 Getting Array Values
      5. 5.9.5 What We’ve Learned
    10. 5.10 Jump Statements: Break and Continue
      1. 5.10.1 A Basic Example
        1. 5.10.1.1 Continue
      2. 5.10.2 ZombieData
      3. 5.10.3 Foreach—Again
      4. 5.10.4 What We’ve Learned
    11. 5.11 Multidimensional Arrays
      1. 5.11.1 Columns and Rows
        1. 5.11.1.1 A Basic Example
      2. 5.11.2 A Puzzle Board
      3. 5.11.3 Checking Range
      4. 5.11.4 What We’ve Learned
    12. 5.12 Array List
      1. 5.12.1 A Basic Example
      2. 5.12.2 ArrayList.Contains()
      3. 5.12.3 Remove
      4. 5.12.4 Sort and Reverse
      5. 5.12.5 What We’ve Learned
    13. 5.13 Strings
      1. 5.13.1 Declaring a String
        1. 5.13.1.1 A Basic Example
      2. 5.13.2 Escape Sequences
      3. 5.13.3 Verbatim Strings: @
      4. 5.13.4 String Format
      5. 5.13.5 What We’ve Learned
    14. 5.14 Combining What We’ve Learned
      1. 5.14.1 Timers
      2. 5.14.2 Adding in Classes
      3. 5.14.3 What We’ve Learned
    15. 5.15 Source Version Control
      1. 5.15.1 Modern Version Control
      2. 5.15.2 The Repository
      3. 5.15.3 GitHub
      4. 5.15.4 What We’ve Learned
      5. 5.15.5 Project Files
    16. 5.16 Setting Up a Repository
      1. 5.16.1 Push
      2. 5.16.2 Gitignore
      3. 5.16.3 Pull
      4. 5.16.4 Contributors
      5. 5.16.5 What We’ve Learned
    17. 5.17 Leveling Up: On to the Cool Stuff
  7. Chapter 6 - Intermediate
    1. 6.1 What Will Be Covered in This Chapter
    2. 6.2 Review
    3. 6.3 Pseudocode
      1. 6.3.1 Thinking It Through
      2. 6.3.2 Class Members
        1. 6.3.2.1 A Basic Example
        2. 6.3.2.2 Thinking like a Programmer
      3. 6.3.3 Return
        1. 6.3.3.1 A Basic Example
      4. 6.3.4 Arguments aka Args (Not Related to Pirates)
        1. 6.3.4.1 The Basic Example
        2. 6.3.4.2 Multiple Args
        3. 6.3.4.3 Using Args
      5. 6.3.5 Assignment Operators
        1. 6.3.5.1 A Basic Example
      6. 6.3.6 What We’ve Learned
    4. 6.4 Class Constructors
      1. 6.4.1 A Basic Example
      2. 6.4.2 What We’ve Learned
      3. 6.4.3 What We’ve Learned
    5. 6.5 Arrays Revisited
      1. 6.5.1 Using Arrays in Unity 3D
        1. 6.5.1.1 Starting with 0
        2. 6.5.1.2 Mathf
        3. 6.5.1.3 Time
      2. 6.5.2 Instancing with AddComponent();
      3. 6.5.3 Type Casting Unity 3D Objects
      4. 6.5.4 What We’ve Learned
    6. 6.6 Enums
      1. 6.6.1 Using Enums
      2. 6.6.2 Combining What We’ve Learned
      3. 6.6.3 What We’ve Learned
    7. 6.7 Switch
      1. 6.7.1 A Basic Example
      2. 6.7.2 Default:
      3. 6.7.3 What We’ve Learned
      4. 6.7.4 Fall Through
      5. 6.7.5 goto Case
      6. 6.7.6 Limitations
      7. 6.7.7 What We’ve Learned
    8. 6.8 Structs
      1. 6.8.1 Structs
      2. 6.8.2 Struct versus Class
      3. 6.8.3 Without Structs
      4. 6.8.4 Handling Structs
      5. 6.8.5 Accessing Structs
      6. 6.8.6 Global Access
      7. 6.8.7 What We’ve Learned
    9. 6.9 Class Data
      1. 6.9.1 Character Base Class
      2. 6.9.2 Const
      3. 6.9.3 Readonly
      4. 6.9.4 What We’ve Learned
    10. 6.10 Namespaces
      1. 6.10.1 A Basic Example
      2. 6.10.2 Directives in Namespaces
      3. 6.10.3 Ambiguous References
      4. 6.10.4 Alias Directives
      5. 6.10.5 Putting Namespaces to Work
      6. 6.10.6 Extending Namespaces
      7. 6.10.7 What We’ve Learned
    11. 6.11 Functions Again
      1. 6.11.1 Parameter Lists
        1. 6.11.1.1 A Basic Example
      2. 6.11.2 Side Effects
      3. 6.11.3 Multiple Arguments
      4. 6.11.4 Useful Parameters
        1. 6.11.4.1 The Rule of Three
      5. 6.11.5 Foreach versus For
      6. 6.11.6 What We’ve Learned
    12. 6.12 Unity 3D Execution Order
      1. 6.12.1 A Basic Example
      2. 6.12.2 Component Execution Order
      3. 6.12.3 What We’ve Learned
    13. 6.13 Inheritance Again
      1. 6.13.1 Function Overrides
        1. 6.13.1.1 A Basic Example
      2. 6.13.2 Class Inheritance
        1. 6.13.2.1 Sharing Common Attributes
      3. 6.13.3 Object
      4. 6.13.4 What We’ve Learned
    14. 6.14 Type Casting Again
      1. 6.14.1 (<Type>) versus "as"
      2. 6.14.2 User-Defined Type Conversion
      3. 6.14.3 Implicit versus Explicit Type Conversion
      4. 6.14.4 Break
      5. 6.14.5 What We’ve Learned
    15. 6.15 Working with Vectors
      1. 6.15.1 Vectors Are Objects
      2. 6.15.2 Stepping through MonsterGenerator
      3. 6.15.3 Gizmos
        1. 6.15.3.1 A Basic Example
      4. 6.15.4 Using Gizmos
        1. 6.15.4.1 Building Up Parameters
      5. 6.15.5 Optimizing
      6. 6.15.6 What We’ve Learned
    16. 6.16 goto Labels
      1. 6.16.1 A Basic Example
      2. 6.16.2 Zombie State Machine
      3. 6.16.3 This as a Reference to Yourself
      4. 6.16.4 HumanState Based on ZombieState
      5. 6.16.5 The Is Keyword
      6. 6.16.6 What We’ve Learned
    17. 6.17 More on Arrays
      1. 6.17.1 Length and Count
        1. 6.17.1.1 A Basic Example
      2. 6.17.2 Foreach: A Reminder
      3. 6.17.3 Discovery
      4. 6.17.4 Putting It Together
      5. 6.17.5 What We’ve Learned
    18. 6.18 Out Parameter
      1. 6.18.1 A Basic Example
      2. 6.18.2 Simple Sort (Bubble Sort)
      3. 6.18.3 Simple Sort Proof
      4. 6.18.4 What We’ve Learned
    19. 6.19 Ref Parameter
      1. 6.19.1 A Basic Example
      2. 6.19.2 Code Portability Side Effects
      3. 6.19.3 What We’ve Learned
    20. 6.20 Type Casting Numbers
      1. 6.20.1 Number Types
      2. 6.20.2 Integers
        1. 6.20.2.1 Signed Numbers
      3. 6.20.3 Floating Point
      4. 6.20.4 What We’ve Learned
    21. 6.21 Types and Operators
      1. 6.21.1 GetType()
      2. 6.21.2 More Type Casting
      3. 6.21.3 Type Aliasing
      4. 6.21.4 Boxing and Unboxing
    22. 6.22 Operator Overloading
      1. 6.22.1 A Basic Example
      2. 6.22.2 Overloading *
      3. 6.22.3 Overloading <
      4. 6.22.4 What We’ve Learned
    23. 6.23 Controlling Inheritance
      1. 6.23.1 Sealed
        1. 6.23.1.1 A Basic Example
      2. 6.23.2 Abstract
        1. 6.23.2.1 A Basic Example
      3. 6.23.3 Abstract: Abstract
      4. 6.23.4 Putting This to Use
      5. 6.23.5 What We’ve Learned
    24. 6.24 Leveling Up
  8. Chapter 7 - Advanced
    1. 7.1 What Will Be Covered in This Chapter
    2. 7.2 Review
      1. 7.2.1 Moving Forward
    3. 7.3 MonoDevelop
      1. 7.3.1 Find in Files
      2. 7.3.2 Word Processors
      3. 7.3.3 Mono History
    4. 7.4 Function Overloading
      1. 7.4.1 A Closer Look at Functions
        1. 7.4.1.1 A Basic Example
      2. 7.4.2 Function Signature
      3. 7.4.3 Different Signatures
      4. 7.4.4 Putting It Together
      5. 7.4.5 Not Quite Recursion
      6. 7.4.6 DrawWord
      7. 7.4.7 What We’ve Learned
    5. 7.5 Accessors (or Properties)
      1. 7.5.1 Value
        1. 7.5.1.1 A Basic Example
      2. 7.5.2 Set Event
      3. 7.5.3 Read-Only Accessor
      4. 7.5.4 Simplification
      5. 7.5.5 What We’ve Learned
    6. 7.6 Base Classes: Another Look
      1. 7.6.1 Generalization—Base Classes
      2. 7.6.2 Specialization
      3. 7.6.3 Base
      4. 7.6.4 Partial
      5. 7.6.5 Protected, Private, and Public
      6. 7.6.6 What We’ve Learned
    7. 7.7 Optional Parameters
      1. 7.7.1 Using Optionals
        1. 7.7.1.1 A Basic Example
      2. 7.7.2 Optional Arguments
      3. 7.7.3 Named Parameters
        1. 7.7.3.1 A Basic Example
      4. 7.7.4 Combining What We’ve Learned
      5. 7.7.5 What We’ve Learned
    8. 7.8 Delegate Functions
      1. 7.8.1 Delegates
        1. 7.8.1.1 A Basic Example
      2. 7.8.2 Delegate Signatures
      3. 7.8.3 Stacking Delegates
      4. 7.8.4 Using Delegates
      5. 7.8.5 What We’ve Learned
    9. 7.9 Interface
      1. 7.9.1 Early Planning
        1. 7.9.1.1 A Basic Example
        2. 7.9.1.2 Using Accessors
      2. 7.9.2 Interface Methods
        1. 7.9.2.1 Breaking a Fixing
      3. 7.9.3 Multiple Interfaces
      4. 7.9.4 IComparer
      5. 7.9.5 Using IComparer
      6. 7.9.6 What We’ve Learned
    10. 7.10 Class Constructors Revisited
      1. 7.10.1 A Basic Example
      2. 7.10.2 When to Create a New Class
        1. 7.10.2.1 Add in a Private zposition Offset
      3. 7.10.3 Static Functions
        1. 7.10.3.1 Using a Delegate Function
      4. 7.10.4 What We’ve Learned
    11. 7.11 Preprocessor Directives
      1. 7.11.1 A Basic Example
      2. 7.11.2 UNITY_EDITOR
      3. 7.11.3 Warning
      4. 7.11.4 Organizing
      5. 7.11.5 What We’ve Learned
    12. 7.12 Exceptions
      1. 7.12.1 A Basic Example
      2. 7.12.2 Exception Messages
      3. 7.12.3 Custom Exceptions
      4. 7.12.4 Finally
      5. 7.12.5 Try–Catch and Finally in Use
      6. 7.12.6 What We’ve Learned
    13. 7.13 IEnumerator
      1. 7.13.1 Enumeration
        1. 7.13.1.1 A Basic Example
        2. 7.13.1.2 What Doesn’t Work
      2. 7.13.2 Implementing IEnumerator
      3. 7.13.3 What We’ve Learned
    14. 7.14 Generics
      1. 7.14.1 Generic Functions
        1. 7.14.1.1 A Basic Example
        2. 7.14.1.2 Why T?
      2. 7.14.2 Making Use of Generic Functions
      3. 7.14.3 Generic Types
      4. 7.14.4 Var
      5. 7.14.5 Multiple Generic Values
      6. 7.14.6 What We’ve Learned
    15. 7.15 Events
      1. 7.15.1 A Basic Example
      2. 7.15.2 A Proper Event
      3. 7.15.3 EventArgs
      4. 7.15.4 Update () to Event
      5. 7.15.5 Generic EventArg
      6. 7.15.6 What We’ve Learned
    16. 7.16 Unity-Friendly Classes
      1. 7.16.1 Extensions
      2. 7.16.2 A Basic Example
      3. 7.16.3 Inheriting from Object
      4. 7.16.4 OnUpdate
      5. 7.16.5 What We’ve Learned
    17. 7.17 Destructors
      1. 7.17.1 A Basic Example
      2. 7.17.2 Clearing Out Objects
      3. 7.17.3 What We’ve Learned
    18. 7.18 Concurrency or Coroutines
      1. 7.18.1 Yield
        1. 7.18.1.1 A Basic Example
      2. 7.18.2 Setting Up Timers
      3. 7.18.3 Random Decisions with Logic
      4. 7.18.4 Stopping a Coroutine
      5. 7.18.5 What We’ve Learned
    19. 7.19 Dictionary, Stacks, and Queues
      1. 7.19.1 A Basic Example
      2. 7.19.2 ContainsKey
      3. 7.19.3 Stacks
        1. 7.19.3.1 A Basic Example
      4. 7.19.4 Queues
      5. 7.19.5 What We’ve Learned
    20. 7.20 Callbacks
      1. 7.20.1 A Basic Example
      2. 7.20.2 Dynamic Callback Assignment
      3. 7.20.3 WWW
      4. 7.20.4 What We’ve Learned
    21. 7.21 Lambda Expressions
      1. 7.21.1 Anonymous Expressions
        1. 7.21.1.1 A Basic Example
      2. 7.21.2 Lambda Expressions
        1. 7.21.2.1 A Basic Example
      3. 7.21.3 When Lambdas Are Useful
      4. 7.21.4 Lambda Statements
      5. 7.21.5 What We’ve Learned
    22. 7.22 Leveling Up
  9. Chapter 8 - Extended
    1. 8.1 What We’ll Be Covering in This Chapter
    2. 8.2 Review
    3. 8.3 Readability Optimizations and Idioms
      1. 8.3.1 ?: Notation
      2. 8.3.2 If
      3. 8.3.3 Smell
        1. 8.3.3.1 Comments
        2. 8.3.3.2 One Responsibility Rule
        3. 8.3.3.3 Duplicated Code
        4. 8.3.3.4 Long Names
      4. 8.3.4 What We’ve Learned
    4. 8.4 Source Control Revisited
      1. 8.4.1 Diff and Merge
      2. 8.4.2 KDiff3
      3. 8.4.3 Avoiding Conflicts
      4. 8.4.4 What We’ve Learned
    5. 8.5 Debugging
      1. 8.5.1 Debugging Accessors
      2. 8.5.2 Locals
      3. 8.5.3 Call Stack
      4. 8.5.4 Watch List
      5. 8.5.5 What We’ve Learned
    6. 8.6 Recursion
      1. 8.6.1 A Basic Example
      2. 8.6.2 Understanding Recursion
      3. 8.6.3 In Practice
      4. 8.6.4 Recursion Types
      5. 8.6.5 What We’ve Learned
    7. 8.7 Reflection
      1. 8.7.1 A Basic Example
      2. 8.7.2 Reflection MethodInfo
      3. 8.7.3 What We’ve Learned
    8. 8.8 LINQ
      1. 8.8.1 Lambdas and Arrays
        1. 8.8.1.1 A Basic Example
      2. 8.8.2 Var
      3. 8.8.3 LINQ From
      4. 8.8.4 Strange Behaviors in LINQ
      5. 8.8.5 Greedy Operator
      6. 8.8.6 What We’ve Learned
    9. 8.9 Bitwise Operators
      1. 8.9.1 Big Endian and Little Endian
      2. 8.9.2 Signed or Unsigned
      3. 8.9.3 Bitwise Or |
      4. 8.9.4 Enums and Numbers
      5. 8.9.5 Bitwise And &
      6. 8.9.6 Bitwise Exclusive Or ^ (xor)
      7. 8.9.7 Setting Bitwise Flags
      8. 8.9.8 Bitwise Shortcuts | = and ^ =
      9. 8.9.9 Bits in Numbers
      10. 8.9.10 Bit Shifting >> and <<
      11. 8.9.11 What We’ve Learned
    10. 8.10 Bitwise Math
      1. 8.10.1 Two’s Complement
      2. 8.10.2 Unary Operator ~
      3. 8.10.3 Bitwise Addition and Subtraction
      4. 8.10.4 Bitwise Multiplication
      5. 8.10.5 Bitwise Tricks
      6. 8.10.6 What We’ve Learned
    11. 8.11 Attributes
      1. 8.11.1 A Basic Example
      2. 8.11.2 Custom Attributes
      3. 8.11.3 Finding Custom Attributes
      4. 8.11.4 Attribute Constructor
      5. 8.11.5 Multiple Attributes
      6. 8.11.6 Putting Attributes to Work
      7. 8.11.7 Attribute Flags
      8. 8.11.8 What We’ve Learned
    12. 8.12 Architectures and Organization
      1. 8.12.1 Planning Structure
      2. 8.12.2 Fixing Namespaces
      3. 8.12.3 Namespace and Directory Structure
      4. 8.12.4 Using Partial
      5. 8.12.5 Refactoring
      6. 8.12.6 What We’ve Learned
    13. 8.13 Design Patterns
      1. 8.13.1 Creational Design Patterns
        1. 8.13.1.1 Singleton Pattern
      2. 8.13.2 Structural Design Patterns
      3. 8.13.3 Behavioral Design Patterns
      4. 8.13.4 What We’ve Learned
    14. 8.14 Continuing on Your Own
  10. Chapter 9 - Stuff We Couldn’t Cover
    1. 9.1 The Extern and Unsafe Keywords
    2. 9.2 Dynamic
      1. 9.2.1 Dynamic versus Var
  11. Chapter 10 - Good Luck