Behavior trees & The C# programming language for Java programmers

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 12 Introduction to ASP.NET.
Advertisements

Air Force Institute of Technology Electrical and Computer Engineering
Programming Paradigms and languages
C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.
Lecture 10: Part 1: OO Issues CS 540 George Mason University.
Written by: Dr. JJ Shepherd
INNER WORKINGS OF UNITY 3D. WHAT WE ARE GOING TO COVER Intro to Unity Physics & Game Objects Cameras & Lighting Textures & Materials Quaternions and Rotation.
Introduction to the C# Programming Language for the VB Programmer.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Information Technology Center Hany Abdelwahab Computer Specialist.
C#/.NET Jacob Lewallen. C# vs.NET.NET is a platform. Many languages compile to.NET: –VB.NET –Python.NET –Managed C++ –C#
Chapter 9 Interactive Multimedia Authoring with Flash - Introduction to Programming “Computers and Creativity” Richard D. Webster, COSC 109 Instructor.
JavaServer Pages Syntax Harry Richard Erwin, PhD CSE301/CIT304.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Programming Language C++ Xulong Peng CSC415 Programming Languages.
SE 350 – Programming Games Lecture 7: Programming with Unity Lecturer: Gazihan Alankuş Please look at the last slide for assignments (marked with TODO)
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
How to Create a Videogame By: Connor McCann. Java Java is one of many programming languages Java is used to run web browsers and most PC video games I.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Web Games Programming Unity Scripting Fundamentals.
USING UNITY JAVASCRIPT. CONVENTIONS AND SYNTAX IN JAVASCRIPT Case Sensitivity All keywords like var or function must be in lowercase. All variable names,
Agenda Object Oriented Programming Reading: Chapter 14.
Prepared by: Elsy Torres Shajida Berry Siobhan Westby.
USING UNITY JAVASCRIPT. CONVENTIONS AND SYNTAX IN JAVASCRIPT Case Sensitivity All keywords like var or function must be in lowercase. All variable names,
Java The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since A programming.
Applications Development
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Copyright Curt Hill Variables What are they? Why do we need them?
Bill Campbell, UMB Microsoft's.NET C# and The Common Language Runtime.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
RUBY by Ryan Chase.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Lecture 7 February 24, Javadoc version and author Tags These go in the comments before named classes. –Put your SS# on a separate line from the.
Written by: Dr. JJ Shepherd
GameDevClub CODE CHEAT SHEET NOTE: ALL OF THE CODE IS CASE-SENSITIVE AND THE SYNTAX IS STRICT SO A LOT OF YOUR ERRORS WILL PROBABLY COME FROM TYPOS If.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
Java & C++ Comparisons How important are classes and objects?? What mechanisms exist for input and output?? Are references and pointers the same thing??
Java: Variables and Methods By Joshua Li Created for the allAboutJavaClasses wikispace.
Expressive Intelligence Studio // Center for Games and Playable Media // Unity Pro John Murray Expressive.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Intro to Programming STARS College of Communication and Information Florida State University Written by: Hannah Brock Alissa Ovalle Nicolaus Lopez Martin.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
Sophomore Scholars Java
CIS 068 JAVA vs. C++ Main Differences CIS 068.
Information and Computer Sciences University of Hawaii, Manoa
Collision Theory and Logic
Creating and Using Objects, Exceptions, Strings
Basic Introduction to C#
Chapter 10 Programming Fundamentals with JavaScript
Learning to Program D is for Digital.
Collision Theory and Logic
Selenium WebDriver Web Test Tool Training
CS230 Tutorial Week 3.
CS360 Windows Programming
Chapter 5 Structures.
11/10/2018.
Lesson 2: Building Blocks of Programming
Chapter 10 Programming Fundamentals with JavaScript
Starting JavaProgramming
Updating an Animated Scene
Conditional Statements
PHP.
Review CSE116 2/21/2019 B.Ramamurthy.
Week 6: Time and triggers!
Fundaments of Game Design
Variables and Java vs C++
Unity Game Development
1D Arrays and Lots of Brackets
1D Arrays and Lots of Brackets
SPL – PS2 C++ Memory Handling.
Presentation transcript:

Behavior trees & The C# programming language for Java programmers CS 185C Behavior trees & The C# programming language for Java programmers

In this day in Video Games...

State-Based Scripting – Behavior Trees Allows ”choose the highest priority of the following states” Allows ”do the following states in order” Can execute multiple states at a time Each state knows if it is relevant or not Can sequence states

State-Based Scripting – Behavior Trees Cutman

State-Based Scripting – Behavior Trees Each node can be successful, failed, or in progress Different node types (shapes) have different rules

State-Based Scripting – Behavior Trees Harder to write Easier to understand and modify Easy to change different node priorities Easy to break a node up into two steps

State-Based Scripting – Behavior Trees Same Batman boss characters

Questions?

Unity3D Scripting UnityScript JavaScript-inspired JavaScript is commonly used for web page scripting Internally, everything is using .NET via Mono

Unity3D Scripting C# Most popular .NET language Static typed, object oriented ”Microsoft Java” Microsoft has added a lot of nifty new syntax, but Unity's version lags behind

C# Example using UnityEngine; using System.Collections; public class BackAndForthClass : MonoBehaviour { public float speed = 6; // Update is called once per frame void Update() { if( transform.position.x > 40 || transform.position.x < -40 ) { transform.Rotate( 0, 180, 0 ); transform.Translate( -10, 0, 0 ); speed = Random.Range( 6f, 10f ); } transform.Translate( -speed * Time.deltaTime, 0, 0 );

C# Overview Almost exactly the same as Java Classes Methods Members Public vs Private Comments Primitive Types Branching, Loops Interface

C# - Classes Represent a ”behavior” or concept In Unity most classes inherit from MonoBehavior public class CLASSNAME : PARENT { public float MEMBER = 6; int ANOTHER_MEMBER = 0; void METHOD() { // code would go here } public float OTHER_METHOD(float PARAM1, float PARAM2) {

C# - Comments Note for humans, ignored by the computer // A single line comment /* A different single line comment */ /* A mulitple line comment */

C# - Types bool true or false (boolean in Java) int number (1, 2, 3) float numer with a decimal point (2.5, 3.14) string text (String in Java) object an unknown thing (Object in Java) Array a collection of objects Vector3 3D position Quaternion 3D rotation

C# - Branching, Loops Do things conditionally, or multiple times if( CONDITION ) { // Stuff only run if condition is true } else if( CONDITION2 ) { // Stuff only run if condition2 is true, condition is false } else { // Stuff run if condition and condition2 are both false } while( CONDITION ) { // Stuff run until condition becomes false for( INIT; CONDITION; INCREMENT ) { // Stuff run until condition becomes false, useful for arrays

C# - Branching, Loops Do things conditionally, or multiple times if( CONDITION ) { // Stuff only run if condition is true } else if( CONDITION2 ) { // Stuff only run if condition2 is true, condition is false } else { // Stuff run if condition and condition2 are both false } while( CONDITION ) { // Stuff run until condition becomes false for( INIT; CONDITION; INCREMENT ) { // Stuff run until condition becomes false, useful for arrays

C# - Event Handling Events in Unity are just method calls Important events: Update FixedUpdate OnTriggerEnter OnCollisionEnter Many other ”OnX”

C# Example using UnityEngine; using System.Collections; public class BackAndForthClass : MonoBehaviour { public float speed = 6; // Update is called once per frame void Update() { if( transform.position.x > 40 || transform.position.x < -40 ) { transform.Rotate( 0, 180, 0 ); transform.Translate( -10, 0, 0 ); speed = Random.Range( 6f, 10f ); } transform.Translate( -speed * Time.deltaTime, 0, 0 );

C# Example using UnityEngine; using System.Collections; public class BackAndForthClass : MonoBehaviour { public float speed = 6; void Update() { transform.Translate( -speed * Time.deltaTime, 0, 0 ); } void OnTriggerEnter( Collider c ) { transform.Rotate( 0, 180, 0 ); transform.Translate( -10, 0, 0 ); speed = Random.Range( 6f, 10f );

Questions?

C# - struct Looks and acts just like a class, EXCEPT when passed to a function, it is copied Allocated on the stack as opposed to the heap public struct Vector3 { public float x; public float y; public float z; // helper methods public void Normalize() { // code goes here }

C# - Operator Overloading Lets you use math symbols (+, -, *, /) instead of calling methods. Vector3 operator+ operator- operator* operator/ operator== operator!=

C# - Properties Make things look like fields but behave like methods. public float Length { get { return Mathf.Sqrt( x*x + y*y + z*z ); } set { float old = Mathf.Sqrt( x*x + y*y + z*z ); float scale = value / old; x *= scale; y *= scale; z *= scale; }

C# - goto C# supports goto. Goes to a specific named label. public object findAndProcessDuplicate(object[] a) { for( int i = 0; i < a.Length; i++ ) { for( int j = i + 1; j < a.Length; j++ ) { if( a[i] == a[j] ) { Process(a[i]); goto done; } done: afterProcessing();

Questions?

Let's look at a real example. C# Let's look at a real example.