• Mastering TypeScript-Second Edition[February 2017]

    What this book covers Chapter 1, TypeScript - Tools and Framework Options, sets the scene for beginning TypeScript development. It discusses the benefits of using TypeScript as a language and compiler, and then works through setting up a complete development environment using a number of popular IDEs. Chapter 2, Types, Variables, and Function Techniques, introduces the reader to the TypeScript language, starting with basic types and type annotations, and then moves on to discuss variables, functions, and advanced language features. Chapter 3, Interfaces, Classes, and Inheritance, builds on the work from the previous chapter, and introduces the object-oriented concepts and capabilities of interfaces, classes, and inheritance. It then shows these concepts at work through the Factory Design Pattern. Chapter 4, Decorators, Generics, and Asynchronous Features, discusses the more advanced language features of decorators and generics, before working through the concepts of asynchronous programming. It shows how the TypeScript language supports these asynchronous features through promises and the use of async await constructs. Chapter 5, Writing and Using Declaration Files, walks the reader through building a declaration file for an existing body of JavaScript code, and then lists some of the most common syntax used when writing declaration files. This syntax is designed to be a quick reference guide to the declaration file syntax, or a cheat sheet. Chapter 6, Third-Party Libraries, shows the reader how to use declaration files from the DefinitelyTyped repository within the development environment. It then moves on to show how to write TypeScript code that is compatible with three popular JavaScript frameworks-- Backbone, Angular 1, and ExtJs. Chapter 7, TypeScript Compatible Frameworks, takes a look at popular frameworks that have full TypeScript language integration. It explores the MVC paradigm, and then compares how this design pattern is implemented in Backbone, Aurelia, Angular 2, and React. Chapter 8, Test Driven Development, starts with a discussion on what Test Driven Development is, and then guides the reader through the process of creating various types of unit tests. Using the Jasmine library, it shows how to use data-driven tests, and how to test asynchronous logic. The chapter finishes with a discussion on test runners, test reporting, and using continuous integration build servers. Chapter 9, Testing TypeScript Compatible Frameworks, shows how to unit test, integration test, and acceptance test a sample application built with each of the TypeScript compatible frameworks. It discusses the concept of testability, and shows how subtle changes in application design and implementation can provide far better application test coverage. Chapter 10, Modularization, explores what modules are, how they can be used, and the two types of module generation that the TypeScript compiler supports--CommonJs and AMD. It then shows how modules can be used with module loaders, including Require and SystemJs. This chapter finishes with an in-depth look at using modules within Node, and builds a sample Express application. Chapter 11, Object-Oriented Programming, discusses the concepts of object-oriented programming, and then shows how to arrange application components to conform to object-oriented principles. It then takes an in-depth look at implementing object-oriented best practices by showing how the State and Mediator design patterns can be used to manage complex UI interactions. Chapter 12, Dependency Injection, discusses the concepts of Service Location and Dependency Injection, and how they can be used to solve common application design problems. It then shows how to implement a simple Dependency Injection framework using Decorators. Chapter 13, Building Applications, explores the fundamental building blocks of web application development, including generating HTML pages from Node and Express, writing and consuming REST endpoints, and data binding. It shows how to integrate an Express server, REST endpoints, and data binding with Aurelia, Angular 2, and React. Chapter 14, Let’s Get Our Hands Dirty, builds a single-page application using Angular 2 and Express by combining all of the concepts and components built throughout the book into a single application. These concepts include Test Driven Development, the State and Mediator Pattern, using Express REST endpoints, object-oriented design principles, modularization, and custom CSS animations.

    0
    129
    6.29MB
    2018-05-18
    9
  • Functional C#[January 2017].pdf

    Chapter 1, Tasting Functional Style in C#, introduces the functional programming approach by discussing its concepts and the comparison between functional and imperative programming. We also try to refactor a simple imperative code into a functional approach. Chapter 2, Walkthrough Delegates, covers the definition, syntax, and use of delegates. We also discuss the variance of delegates and the built-in delegate. Chapter 3, Expressing Anonymous Methods with Lambda Expressions, walks us through the concept of delegates and uses it to create and use an anonymous method. After we dig through the anonymous method, we can transform it into a lambda expression and then apply it to functional programming. Chapter 4, Extending Object Functionality with Extension Methods, elaborates the benefits of using the extension method in functional programming. Before that, we discuss the use of the extension method and also discuss how to get this new method in IntelliSense. Also, we try to invoke the extension method from other assemblies. Chapter 5, Querying Any Collection Easily with LINQ, enumerates the LINQ operator provided by C# and compares the two LINQ syntaxes: Fluent Syntax and Query Expression Syntax. We also discuss deferred execution in the LINQ process. Chapter 6, Enhancing the Responsiveness of the Functional Program with Asynchronous Programming, covers asynchronous programming for the functional approach. It will explain the Asynchronous Programming Model and the Task-based Asynchronous pattern. Chapter 7, Learning Recursion, explains the advantages of recursion over the loop sequence. We also discuss direct and indirect recursion in this chapter. Chapter 8, Optimizing the Code Using Laziness and Caching Techniques, covers the technique used to optimize the code in the functional approach. We talk about laziness thinking and the caching technique in order to optimize our code. Chapter 9, Working with Pattern, covers the advantages of using patterns compared to conventional switch-case operations. We discuss pattern matching and monad in this chapter. We use the pattern matching feature, which is the new feature provided by C# 7. Chapter 10, Taking an Action in C# Functional Programming, walks us through developing functional code based on given imperative code. We use our learning in the previous chapter to create an application using the functional approach. Chapter 11, Coding Best Practice and Testing the Functional Code, explains the best practice in the functional approach, including the creation of an honest signature and dealing with the side-effects. We also separate the code into domain logic and mutable shell and then test it using unit testing.

    0
    175
    2.84MB
    2018-03-19
    9
  • Artificial Intelligence With Python[January 2017]

    Artificial intelligence is becoming increasingly relevant in the modern world where everything is driven by data and automation. It is used extensively across many fields such as image recognition, robotics, search engines, and self-driving cars. In this book, we will explore various real-world scenarios. We will understand what algorithms to use in a given context and write functional code using this exciting book. We will start by talking about various realms of artificial intelligence. We’ll then move on to discuss more complex algorithms, such as Extremely Random Forests, Hidden Markov Models, Genetic Algorithms, Artificial Neural Networks, and Convolutional Neural Networks, and so on. This book is for Python programmers looking to use artificial intelligence algorithms to create real-world applications. This book is friendly to Python beginners, but familiarity with Python programming would certainly be helpful so you can play around with the code. It is also useful to experienced Python programmers who are looking to implement artificial intelligence techniques. You will learn how to make informed decisions about the type of algorithms you need to use and how to implement those algorithms to get the best possible results. If you want to build versatile applications that can make sense of images, text, speech, or some other form of data, this book on artificial intelligence will definitely come to your rescue! What this book covers Chapter 1, Introduction to Artificial Intelligence, teaches you various introductory concepts in artificial intelligence. It talks about applications, branches, and modeling of Artificial Intelligence. It walks the reader through the installation of necessary Python packages. Chapter 2, Classification and Regression Using Supervised Learning, covers various supervised learning techniques for classification and regression. You will learn how to analyze income data and predict housing prices. Chapter 3, Predictive Analytics with Ensemble Learning, explains predictive modeling techniques using Ensemble Learning, particularly focused on Random Forests. We will learn how to apply these techniques to predict traffic on the roads near sports stadiums. Chapter 4, Detecting Patterns with Unsupervised Learning, covers unsupervised learning algorithms including K-means and Mean Shift Clustering. We will learn how to apply these algorithms to stock market data and customer segmentation. Chapter 5, Building Recommender Systems, illustrates algorithms used to build recommendation engines. You will learn how to apply these algorithms to collaborative filtering and movie recommendations. Chapter 6, Logic Programming, covers the building blocks of logic programming. We will see various applications, including expression matching, parsing family trees, and solving puzzles. Chapter 7, Heuristic Search Techniques, shows heuristic search techniques that are used to search the solution space. We will learn about various applications such as simulated annealing, region coloring, and maze solving. Chapter 8, Genetic Algorithms, covers evolutionary algorithms and genetic programming. We will learn about various concepts such as crossover, mutation, and fitness functions. We will then use these concepts to solve the symbol regression problem and build an intelligent robot controller. Chapter 9, Building Games with Artificial Intelligence, teaches you how to build games with artificial intelligence. We will learn how to build various games including Tic Tac Toe, Connect Four, and Hexapawn. Chapter 10, Natural Language Processing, covers techniques used to analyze text data including tokenization, stemming, bag of words, and so on. We will learn how to use these techniques to do sentiment analysis and topic modeling. Chapter 11, Probabilistic Reasoning for Sequential Data, shows you techniques used to analyze time series and sequential data including Hidden Markov models and Conditional Random Fields. We will learn how to apply these techniques to text sequence analysis and stock market predictions. Chapter 12, Building A Speech Recognizer, demonstrates algorithms used to analyze speech data. We will learn how to build speech recognition systems. Chapter 13, Object Detection and Tracking, It covers algorithms related to object detection and tracking in live video. We will learn about various techniques including optical flow, face tracking, and eye tracking. Chapter 14, Artificial Neural Networks, covers algorithms used to build neural networks. We will learn how to build an Optical Character Recognition system using neural networks. Chapter 15, Reinforcement Learning, teaches the techniques used to build reinforcement learning systems. We will learn how to build learning agents that can learn from interacting with the environment. Chapter 16, Deep Learning with Convolutional Neural Networks, covers algorithms used to build deep learning systems using Convolutional Neural Networks. We will learn how to use TensorFlow to build neural networks. We will then use it to build an image classifier using convolutional neural networks.

    0
    181
    32.24MB
    2017-11-25
    9
  • Node.js Design Patterns Second Edition[July 2016]

    By reading this book, you will learn the following: The "Node way": How to use the right point of view when approaching a Node.js design problem. You will learn, for example, how different traditional design patterns look in Node.js, or how to design modules that do only one thing. A set of patterns to solve common Node.js design and coding problems: You will be presented with a "Swiss army knife" of patterns, ready-to-use in order to efficiently solve your everyday development and design problems. How to write modular and efficient Node.js applications: You will gain an understanding of the basic building blocks and principles of writing large and well-organized Node.js applications and you will be able to apply these principles to novel problems that don't fall within the scope of existing patterns. Throughout the book, you will be presented with several real-life libraries and technologies, such as LevelDb, Redis, RabbitMQ, ZMQ, Express, and many others. They will be used to demonstrate a pattern or technique, and besides making the example more useful, these will also give you great exposure to the Node.js ecosystem and its set of solutions. Whether you use or plan to use Node.js for your work, your side project, or for an open source project, recognizing and using well-known patterns and techniques will allow you to use a common language when sharing your code and design, and on top of that, it will help you get a better understanding of the future of Node.js and how to make your own contributions a part of it. What this book covers Chapter 1, Welcome to the Node.js Platform, serves as an introduction to the world of Node.js application design by showing the patterns at the core of the platform itself. It covers the Node.js ecosystem and its philosophy, a short introduction to Node.js version 6, ES2015, and the reactor pattern. Chapter 2, Node.js Essential Patterns, introduces the first steps towards asynchronous coding and design patterns with Node.js discussing and comparing callbacks and the event emitter (observer pattern). This chapter also introduces the Node.js module system and the related module pattern. Chapter 3, Asynchronous Control Flow Patterns with Callbacks, introduces a set of patterns and techniques for efficiently handling asynchronous control flow in Node.js. This chapter teaches you how to mitigate the "callback hell" problem using plain JavaScript and the async library. Chapter 4, Asynchronous Control Flow Patterns with ES2015 and Beyond, progresses with the exploration of asynchronous control flows introducing Promises, Generators, and Async- Await. Chapter 5, Coding with Streams, dives deep into one of the most important patterns in Node.js: streams. It shows you how to process data with transform streams and how to combine them into different layouts. Chapter 6, Design Patterns, deals with a controversial topic: traditional design patterns in Node.js. It covers the most popular conventional design patterns and shows you how unconventional they might look in Node.js. It also introduces the reader to some emerging design patterns that are specific only to JavaScript and Node.js. Chapter 7, Wiring Modules, analyzes the different solutions for linking the modules of an application together. In this chapter, you will learn design patterns such as Dependency Injection and service locator. Chapter 8, Universal JavaScript for Web Applications, explores one of the most interesting capabilities of modern JavaScript web applications: being able to share application code between the frontend and the backend. Across this chapter we learn the basic principles of Universal JavaScript by building a simple web application with React, Webpack, and Babel. Chapter 9, Advanced Asynchronous Recipes, takes a problem-solution approach to show you how some common coding and design challenges can be solved with ready-to-use solutions. Chapter 10, Scalability and Architectural Patterns, teaches you the basic techniques and patterns for scaling a Node.js application. Chapter 11, Messaging and Integration Patterns, presents the most important messaging patterns, teaching you how to build and integrate complex distributed systems using ZMQ and AMQP.

    0
    222
    11.14MB
    2017-11-25
    10
  • Procedural Content Generation For Unity Game Development[January 2016]

    This book is an introduction to Procedural Content Generation (PCG) and how it can be applied in the popular game engine, Unity3D. PCG is a powerful programming practice that is trending in modern video games. Though PCG is not a new practice, it has become even more powerful as technology has advanced and it looks to be a prominent component of future video games.Throughout the course of this book, we will be learning the basis of procedural content generation, including theory and practice. You will start by learning what PCG is and what its uses are. You will then move into learning about pseudo random numbers and how they work with PCG to create unique gameplay.After your introduction to PCG, you will dive in and build the core functionality of a 2D Roguelike game. This game will be heavily based on PCG practices so that you can experience what it takes to design and implement PCG algorithms. You will experience level generation, item generation, adaptive diffculty, music generation, and more. Lastly, we will move into 3D object generation by generating a 3D planet.The aim of this book is to teach you about the theory of PCG while providing some simplifed practical examples. By the end of the book, you should have a fundamental understanding of PCG and how it can be applied using Unity3D. This will all facilitate your further learning, research, and practice of PCG methods in video game development. What this book coversChapter 1, Pseudo Random Numbers, teaches you about the theory of procedural content generation (PCG). We will cover what PCG is and how it is used in video games. You will then learn about a useful component of randomization called Pseudo Random Numbers (PRN). We will cover what PRNs are, how they are used, and how they can help us implement PCG algorithms. Chapter 2, Roguelike Games, teaches you about a prime example of procedural content generation, Roguelike games. We will cover some history of the origin of PCG and Roguelike games. We will then set up the Unity project foundation of our very own Roguelike game.Chapter 3, Generating an Endless World, begins the implementation of your 2D Roguelike game. We will be creating a level that generates itself at runtime while the player explores. We will cover PCG algorithm design and useful data substructures. Then, we will put it together to implement the game world.Chapter 4, Generating Random Dungeons, implements the sublevels of our Roguelike game. We will cover a different approach to level generation as we generate a full level layout at runtime. You will learn about some common approaches to this technique and implement one for yourself.Chapter 5, Randomized Items, teaches you about randomly generating items. The items you generate will have differing properties so we will use some techniques to communicate this to the player. We will cover item spawning, interaction, and inventory storage.Chapter 6, Generating Modular Weapons, teaches you about and how to implement a random modular weapon system. You will build upon what you learned in the previous chapter to add more complexity to item generation. These items will comprise a small set of pieces that are assembled at runtime.Chapter 7, Adaptive Diffculty, crosses over into the feld of Artifcial Intelligence (AI)and teaches you about how AI and PCG are similar and related. You will learn about the PCG idea of adaptive diffculty, which is one part AI and one part PCG. You will then implement an adaptive diffculty system for your Roguelike game.Chapter 8, Generating Music, shows you how PCG can even contribute to the music and sound content of a game. You will learn a little music theory; just enough to design a PCG algorithm for music generation. Then, you will implement a music generator for your Roguelike game that can generate music at runtime. Chapter 9, Generating a 3D Planet, switches gears from 2D-based PCG to 3D-based PCG. We will have fnished our core 2D Roguelike functionality and be working on a new project. This chapter will introduce the fundamentals of 3D object generation. You will then implement a 3D planet generator. Plus, as a bonus, you will implement a frst person controller to take a closer look at your generated world.Chapter 10, Generating the Future, discusses the most common methods of PCG used today and some ways to further your learning in the subject. We will also summarize some of the key points of what you learned throughout the book and how they relate to these PCG methods. We will lastly take a look at some ways that we can improve these PCG methods for the future.

    0
    147
    5.93MB
    2017-11-25
    9
  • Python Machine Learning Blueprints[July 2016]

    Machine learning is rapidly becoming a fixture in our data-driven world. It is relied upon in fields as diverse as robotics and medicine to retail and publishing. In this book, you will learn how to build real-world machine learning applications step by step. Working through easy-to-understand projects, you will learn how to process various types of data and how and when to apply different machine learning techniques such as supervised or unsupervised learning. Each of the projects in this book provides educational as well as practical value. For example, you'll learn how to use clustering techniques to find bargain airfares and how to use linear regression to find a cheap apartment. This book will teach you how to use machine learning to collect, analyze, and act on massive quantities of data in an approachable, no-nonsense manner. What this book covers Chapter 1, The Python Machine Learning Ecosystem, delves into Python, which has a deep and active developer community, and many of these developers come from the scientific community as well. This has provided Python with a rich array of libraries for scientific computing. In this chapter, we will discuss the features of these key libraries and how to prepare your environment to best utilize them. Chapter 2, Build an App to Find Underpriced Apartments, guides us to build our first machine learning application, and we begin with a minimal but practical example: building an application to identify underpriced apartments. By the end of this chapter, we will create an application that will make finding the right apartment a bit easier. Chapter 3, Build an App to Find Cheap Airfares, demonstrates how to build an application that continually monitors fare pricing. Once an anomalous price appears, our app will generate an alert that we can quickly act on. Chapter 4, Forecast the IPO Market using Logistic Regression, shows how we can use machine learning to decide which IPOs are worth a closer look and which ones we may want to skip. Chapter 5, Create a Custom Newsfeed, covers how to build a system that understands your taste in news and will send you a personally tailored newsletter each day. Chapter 6, Predict whether Your Content Will Go Viral, examines some of the most shared content and attempts to find the common elements that differentiate it from the content that people are less willing to share. Chapter 7, Forecast the Stock Market with Machine Learning, discusses how to build and test a trading strategy. There are countless pitfalls to avoid when trying to devise your own system, and it is quite nearly an impossible task. However, it can be a lot of fun, and sometimes, it can even be profitable. Chapter 8, Build an Image Similarity Engine, helps you construct an advanced, image-based, deep learning application. We will also cover deep learning algorithms to understand why they are so important and why there is such a hype surrounding them. Chapter 9, Build a Chatbot, demonstrates how to construct a chatbot from scratch. Along the way, you'll learn more about the history of the field and its future prospects. Chapter 10, Build a Recommendation Engine, explores the different varieties of recommendation systems. We'll see how they're implemented commercially and how they work. We will also implement our own recommendation engine to find GitHub repos.

    0
    97
    38.15MB
    2017-11-25
    0
  • Unity Virtual Reality Projects.pdf

    Today, we are witnesses to the burgeoning of virtual reality (VR), an exciting new technology that promises to transform in a fundamental way how we interact with our information, friends, and the world at large. What is consumer virtual reality? By wearing a head-mounted display (such as goggles), you can view stereoscopic 3D scenes. You can look around by moving your head and walk around by using hand controls or motion sensors. You can engage in a fully immersive experience. It's like you're really in some other virtual world. This book takes a practical, project-based approach to teach you the speci cs of virtual reality development with the Unity 3D game engine. We walk through a series of hands-on projects, step-by-step tutorials, and in-depth discussions using Unity 5 and other free or open source software. While VR technology is rapidly advancing, we'll try to capture the basic principles and techniques that you can use to make your VR games and applications immersive and comfortable. You will learn how to use Unity to develop VR applications that can be experienced with devices such as the Oculus Rift or Google Cardboard. We'll cover technical considerations that are especially important and possibly unique to VR. By the end of this book, you will be equipped to develop rich, interactive virtual reality experiences using Unity. What this book covers Chapter 1, Virtually Everything for Everyone, is an introduction to the new technologies and opportunities in consumer virtual reality (VR) as regards games and non-gaming applications. Chapter 2, Objects and Scale, discusses how you can build a simple diorama scene. It introduces the Unity 3D game engine as well as Blender for 3D modeling and explores the issues of world coordinates and scale. Chapter 3, VR Build and Run, helps you con gure your project to run on a VR headset, such as the Oculus Rift and Google Cardboard (Android or iOS). Then, we go into detail about how the VR hardware and software works. Chapter 4, Gaze-based Control, explores the relationship between the VR camera and objects in the scene, including 3D cursors and gaze-based ray guns. This chapter also introduces Unity scripting in the C# programming language. Chapter 5, World Space UI, implements many examples of user interface (UI) for VR, which includes a heads-up display (HUD), info-bubbles, and in-game objects with a lot of code and explanations. Chapter 6, First-person Character, dissects the Unity character objects and components, which are used to build our own rst-person character with gaze-based navigation. Then, we'll explore the experience of having a rst-person virtual body and consider the issue of motion sickness. Chapter 7, Physics and the Environment, dives into the Unity physics engine, components, and materials as we learn to work with forces and gravity in a number of VR project examples and games. Chapter 8, Walk-throughs and Rendering, helps us build a 3D architectural space and implement a virtual walk-through. We also talk about rendering in Unity and performance optimizations. Chapter 9, Using All 360 Degrees, uses 360-degree media in a variety of projects, including globes, panoramas, and photospheres. We also have a discussion on how it all works. Chapter 10, Social VR Metaverse, explores the multiplayer implementations with VR using the Unity 5 networking components. We also have a look at VRChat as an example of an extensible platform for social VR. Chapter 11, What's Next?, in this chapter the author comments about the potential of this exciting technology.

    0
    250
    4.72MB
    2017-11-25
    10
  • Swift Essentials - Second Edition [eBook]

    Swift Essentials provides an overview of the Swift language and the tooling necessary to write iOS applications. From simple Swift commands on the command line using the open source version of Swift, to interactively testing graphical content on OS X with the Xcode Playground editor, Swift language and syntax is introduced by examples. This book also introduces end-to-end iOS application development on OS X with Xcode by showing how a simple iOS application can be created, followed by how to use storyboards and custom views to build a more complex networked application. The book concludes by providing a worked example from scratch that builds up a GitHub repository browser for iOS, along with an Apple Watch application. What this book covers Chapter 1, Exploring Swift, presents the open source version of Swift with the Swift Read-Evaluate-Print-Loop (REPL) and introduces the Swift language through examples of standard data types, functions, and looping. Chapter 2, Playing with Swift, demonstrates Swift Xcode Playgrounds as a means to interactively play with Swift code and see graphical results. It also introduces the playground format and shows how playgrounds can be documented. Chapter 3, Creating an iOS Swift App, shows how to create and test an iOS application built in Swift using Xcode, along with an overview of Swift classes, protocols, and enums. Chapter 4, Storyboard Applications with Swift and iOS, introduces the concept of Storyboards as a means of creating a multiscreen iOS application and shows how views in the Interface Builder can be wired to Swift outlets and actions. Chapter 5, Creating Custom Views in Swift, covers custom views in Swift using custom table views, laying out nested views, and drawing custom graphics and layered animations. Chapter 6, Parsing Networked Data, demonstrates how Swift can talk to networked services using both HTTP and custom stream-based protocols. Chapter 7, Building a Repository Browser, uses the techniques described in this book to build a repository browser that can display information about users' GitHub repositories. Chapter 8, Adding Watch Support, introduces the capabilities of the Apple Watch and shows how to build an extension for the iOS app to provide data directly on the watch. The Appendix, References to Swift-related Websites, Blogs, and Notable Twitter Users, provides additional references and resources to continue learning about Swift.

    0
    78
    4.34MB
    2017-11-25
    10
  • Unity.in.Action.Multiplatform.Game.Development.in.Csharp

    PART 1 PART 2 brief contents FIRST STEPS ................................................................ 1 PART 3 8 ■ STRONG FINISH . ...................................................... 193 1 ■ 2 ■ 3 ■ 4 ■ Getting to know Unity 3 Building a demo that puts you in 3D space 21 Adding enemies and projectiles to the 3D game 46 Developing graphics for your game 69 GETTING COMFORTABLE ........................................... 93 5 ■ 6 ■ 7 ■ Building a Memory game using Unity’s new 2D functionality 95 Putting a 2D GUI in a 3D game 119 Creating a third-person 3D game: player movement and animation 140 Adding interactive devices and items within the game 167 9 ■ 10 ■ 11 ■ 12 ■ Connecting your game to the internet 195 Playing audio: sound effects and music 222 Putting the parts together into a complete game 246 Deploying your game to players’ devices 276 v PART 1 FIRST STEPS . ................................................... 1 foreword xv preface xvii acknowledgments xix about this book xx 1 Getting to know Unity 3 1.1 Why is Unity so great? 4 Unity's strengths and advantages 4 ■ Downsides to be aware of 6 ■ Example games built with Unity 7 1.2 How to use Unity 9 Scene view, Game view, and the Toolbar 10 ■ Using the mouse and keyboard 11 ■ The Hierarchy tab and the Inspector 12 The Project and Console tabs 13 1.3 Getting up and running with Unity programming 14 How code runs in Unity: script components 15 ■ Using MonoDevelop, the cross-platform IDE 16 ■ Printing to the console: Hello World! 17 1.4 Summary 20 vii contents viii CONTENTS 2 Building a demo that puts you in 3D space 21 2.1 Before you start... 22 Planning the project 22 ■ Understanding 3D coordinate space 23 2.2 Begin the project: place objects in the scene 25 The scenery: floor, outer walls, inner walls 25 ■ Lights and cameras 27 ■ The player’s collider and viewpoint 29 2.3 Making things move: a script that applies transforms 30 Diagramming how movement is programmed 30 ■ Writing code to implement the diagram 31 ■ Local vs. global coordinate space 32 2.4 Script component for looking around: MouseLook 33 Horizontal rotation that tracks mouse movement 35 ■ Vertical rotation with limits 35 ■ Horizontal and vertical rotation at the same time 38 2.5 Keyboard input component: first-person controls 40 Responding to key presses 40 ■ Setting a rate of movement independent of the computer’s speed 41 ■ CharacterController for collision detection components for walking instead of flying 2.6 Summary 45 Moving the 42 ■ Adjusting 43 3 Adding enemies and projectiles to the 3D game 46 3.1 Shooting via raycasts 47 What is raycasting? 47 ■ Using the command ScreenPointToRay for shooting for aiming and hits 50 3.2 Scripting reactive targets 53 Determining what was hit 53 ■ it was hit 54 3.3 Basic wandering AI 55 48 ■ Adding visual indicators Alert the target that 56 ■ “Seeing” obstacles What is a prefab? 60 ■ Creating the enemy prefab 60 Instantiating from an invisible SceneController 61 3.5 Shooting via instantiating objects 63 Creating the projectile prefab 64 ■ Shooting the projectile and colliding with a target 65 ■ Damaging the player 67 3.6 Summary 68 Diagramming how basic AI works with a raycast 56 ■ Tracking the character’s state 58 3.4 Spawning enemy prefabs 60 PART 2 Whiteboxing explained 72 ■ Drawing a floor plan for the level 73 ■ Laying out primitives according to the plan 74 4.3 Texture the scene with 2D images 75 Choosing a file format 76 ■ Importing an image file 77 Applying the image 78 4.4 Generating sky visuals using texture images 80 What is a skybox? 80 ■ Creating a new skybox material 81 4.5 Working with custom 3D models 83 Which file format to choose? 83 ■ Exporting and importing the model 84 4.6 Creating effects using particle systems 86 Adjusting parameters on the default effect 87 ■ Applying a new texture for fire 88 ■ Attaching particle effects to 3D objects 90 4.7 Summary 91 GETTING COMFORTABLE ................................ 93 4 Developing graphics for your game 69 4.1 Understanding art assets 69 4.2 Building basic 3D scenery: whiteboxing 72 CONTENTS ix 5 Building a Memory game using Unity’s new 2D functionality 95 5.1 Setting everything up for 2D graphics 96 Preparing the project 97 ■ Displaying 2D images (aka sprites) 98 ■ Switching the camera to 2D mode 101 5.2 Building a card object and making it react to clicks 102 Building the object out of sprites 102 ■ Mouse input code 103 Revealing the card on click 104 5.3 Displaying the various card images 104 Loading images programmatically 104 ■ Setting the image from an invisible SceneController 105 ■ Instantiating a grid of cards 107 ■ Shuffling the cards 109 5.4 Making and scoring matches 110 Storing and comparing revealed cards 111 ■ Hiding mismatched cards 111 ■ Text display for the score 112 x CONTENTS 5.5 Restart button 114 Programming a UIButton component using SendMessage 115 Calling LoadLevel from SceneController 117 5.6 Summary 118 6 Puttinga2DGUIina3Dgame 119 6.1 Before you start writing code... 121 Immediate mode GUI or advanced 2D interface? 121 Planning the layout 122 ■ Importing UI images 122 6.2 Setting up the GUI display 123 Creating a canvas for the interface 123 ■ Buttons, images, and text labels 124 ■ Controlling the position of UI elements 127 6.3 Programming interactivity in the UI 128 Programming an invisible UIController 129 ■ Creating a pop-up window 131 ■ Setting values using sliders and input fields 133 6.4 Updating the game by responding to events 135 Integrating an event system 136 ■ Broadcasting and listening for events from the scene 137 ■ Broadcasting and listening for events from the HUD 138 6.5 Summary 139 7 Creating a third-person 3D game: player movement and animation 140 7.1 Adjusting the camera view for third-person 142 Importing a character to look at 142 ■ Adding shadows to the scene 144 ■ Orbiting the camera around the player character 145 7.2 Programming camera-relative movement controls 148 Rotating the character to face movement direction 149 Moving forward in that direction 151 7.3 Implementing the jump action 152 Applying vertical speed and acceleration 153 ■ Modifying the ground detection to handle edges and slopes 154 7.4 Setting up animations on the player character 158 Defining animation clips in the imported model 160 Creating the animator controller for these animations 162 Writing code that operates the animator 165 7.5 Summary 166 PART 3 8.4 Inventory UI for using and equipping items 186 Displaying inventory items in the UI 186 ■ Equipping a key to use on locked doors 188 ■ Restoring the player’s health by consuming health packs 190 8.5 Summary 191 STRONG FINISH ........................................... 193 CONTENTS xi 8 Adding interactive devices and items within the game 8.1 Creating doors and other devices 168 167 Doors that open and close on a keypress 168 ■ Checking distance and facing before opening the door 170 Operating a color-changing monitor 171 8.2 Interacting with objects by bumping into them 172 Colliding with physics-enabled obstacles 173 ■ Triggering the door with a pressure plate 174 ■ Collecting items scattered around the level 176 8.3 Managing inventory data and game state 178 Setting up player and inventory managers Programming the game managers 180 ■ in a collection object: List vs. Dictionary 178 Storing inventory 184 9 Connecting your game to the internet 195 9.1 Creating an outdoor scene 197 Generating sky visuals using a skybox 197 ■ Setting up an atmosphere that’s controlled by code 198 9.2 Downloading weather data from an internet service 201 Requesting WWW data using coroutines 203 ■ Parsing XML 207 ■ Parsing JSON 209 ■ Affecting the scene based on Weather Data 210 9.3 Adding a networked billboard 212 Loading images from the internet 212 ■ Displaying images on the billboard 214 ■ Caching the downloaded image for reuse 216 9.4 Posting data to a web server 217 Tracking current weather: sending post requests 218 ■ Server- side code in PHP 220 9.5 Summary 221 xii CONTENTS 10 Playing audio: sound effects and music 222 10.1 Importing sound effects 223 Supported file formats 223 ■ Importing audio files 225 10.2 Playing sound effects 226 Explaining what’s involved: audio clip vs. source vs. listener 226 ■ Assigning a looping sound Triggering sound effects from code 229 10.3 Audio control interface 230 Setting up the central AudioManager 230 ■ UI 232 ■ Playing UI sounds 236 10.4 Background music 236 228 Volume control Playing music loops 237 ■ Controlling music volume separately 240 ■ Fading between songs 242 10.5 Summary 245 11 Putting the parts together into a complete game 246 11.1 Building an action RPG by repurposing projects 247 Assembling assets and code from multiple projects 248 Programming point-and-click controls: movement and devices 250 ■ Replacing the old GUI with a new interface 255 11.2 Developing the overarching game structure 261 Controlling mission flow and multiple levels 262 ■ Completing a level by reaching the exit 265 ■ Losing the level when caught by enemies 268 11.3 Handling the player’s progression through the game 269 Saving and loading the player’s progress 269 ■ Beating the game by completing three levels 273 11.4 Summary 275 12 Deploying your game to players’ devices 276 12.1 Start by building for the desktop: Windows, Mac, and Linux 278 Building the application 279 ■ setting the game’s name and icon compilation 281 12.2 Building for the web 282 Unity Player vs. HTML5/WebGL file and a test web page 282 ■ Communicating with JavaScript in the browser 283 Adjusting Player Settings: 280 ■ Platform-dependent 282 ■ Building the Unity CONTENTS xiii 12.3 Building for mobile apps: iOS and Android 285 Setting up the build tools 286 ■ Texture compression 289 Developing plug-ins 290 12.4 Summary 298 afterword 299 appendix A appendix B appendix C appendix D Scene navigation and keyboard shortcuts 302 External tools used alongside Unity 304 Modeling a bench in Blender 308 Online learning resources 316 index 319

    5
    343
    11.35MB
    2017-11-25
    10
  • [新出炉]Unity 2017 游戏优化 英文原版

    Chris Dickinson 今年刚出的针对新版Unity (即Unity 2017)一些游戏优化方面的指导。是《Unity5 游戏优化》(美国亚马逊上此书好评如潮)的再升级版,截止至今天(20171125)连亚马逊都还没此书的资源,此书系本人于黑五当天在packtpub够购得。

    5
    366
    4.83MB
    2017-11-25
    43
关注 私信
上传资源赚积分or赚钱