Expandable Item Classes ch 3

Slides:



Advertisements
Similar presentations
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 18 Indexing Structures for Files.
Advertisements

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Part 1 Conditionals and Loops.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 11.9 Curvature and Normal Vectors.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Limits.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 11.5 Lines and Curves in Space.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1 Functions.
Copyright © 2011 Pearson Education, Inc. Publishing as Longman.
Copyright © 2007 Pearson Education, Inc., publishing as Pearson Addison Wesley.
Transcendental Functions
Functions of Several Variables
Chapter 1 Functions Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Chapter 3 Derivatives Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
© 2015 Pearson Education, Inc.
Chapter 3 Differentiation
Copyright © 2008 Pearson Education, Inc
© 2010 Pearson Education, Inc. All rights reserved
Chapter 9 Power Series Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Chapter 2 Limits Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
© 2015 Pearson Education, Inc.
Sequences and Infinite Series
Copyright © 2005 Pearson Education, Inc
Integration Techniques
Inventory ch 4 Richard Gesick.
Chapter 17 Linked Lists.
Chapter 19 Binary Search Trees.
Operations Multiplying Dividing
11.7 Motion in Space Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Chapter 4 Inheritance.
Further Applications of Integration
© 2010 Pearson Education, Inc. All rights reserved
Chapter 14 Graphs and Paths.
Chapter 3 Integration Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Lecture 3 Richard Gesick
Copyright © 2006 Pearson Education, Inc
Chapter 10 Datapath Subsystems.
Applications of the Derivative
Chapter 5 Integration Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
11.8 Length of Curves Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Chapter 20 Hash Tables.
Chapter 2 Limits and Continuity
Mathematical Models: Building Functions
Copyright © 2011 Pearson Education, Inc
Applications of Definite Integrals
Chapter 1 Preliminaries
Copyright © 2006 Pearson Education, Inc
Searching for Guinea Pig B: Case Study in Online Research
2.2 The Algebra of Functions
Chapter 1 Functions Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Chapter 15 Multiple Integrals
Chapter 5 Algorithm Analysis.
Copyright © 2006 Pearson Education, Inc
Vector-Valued Functions and Motion in Space
The Facts to Be Explained
Copyright © 2006 Pearson Education, Inc
Alternate Proofs of Selected HO Theorems
Conic Sections and Polar Coordinates
Chemistry Ch. 10 Review and worksheets
Introduction: Some Representative Problems
2.3 The Composition of Functions
Circuit Characterization and Performance Estimation
Copyright © 2006 Pearson Education, Inc
The Classical Model with Many Goods
Chapter 2 Part 1 Data and Expressions.
Chapter 6 Dynamic Programming.
Chapter 2 Reference Types.
Chapter 4 Greedy Algorithms.
Copyright © 2011 Pearson Education, Inc
Chapter 5 Integration Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Presentation transcript:

Expandable Item Classes ch 3 Richard Gesick

Objectives Creating customizable classes for items Learning how GameObjects can interact with each other through sending messages Creating a Projectile item class Utilizing a classification system for all objects to decide what they do Using trigger-based collisions for the Melee and Projectile item classes Using two types of movement for projectile items

Projectiles The first example: GameObject instantiatedProjectile = Instantiate(bullet, new Vector3(transform.position.x, transform.position.y + 1, transform.position.z + 1), transform.rotation) as GameObject; Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Projectiles GameObject instantiatedProjectile = Instantiate(shot, shotSpawn.position, shotSpawn.rotation) as GameObject; Destroy(instantiatedProjectile, 5f); Or GameObject go = GameObject.Find("shotspawn"); GameObject instantiatedProjectile = Instantiate(bullet, go.transform.position, go.transform.rotation) as GameObject;

KeyValuePair C# struct KeyValuePair<Tkey, Tval> foreach( KeyValuePair<string, string> kvp in openWith ) { Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); }

More KeyValuePair Uses parallel lists which is not normally a good idea but is probably the easiest way to handle this List<KeyValuePair<int, string>> items = new List<KeyValuePair<int, string>>(); List<KeyValuePair<int, int>> itemCount = new List<KeyValuePair<int, int>>(); . . . items.Add(new KeyValuePair<int, string>(i, invItems[i])); itemCount.Add(new KeyValuePair<int, int>(i, 0)); Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Sending Messages From a destroy by contact method void OnTriggerEnter(Collider col) { if (col.gameObject.name == "Eathan") col.gameObject.SendMessage("changeHealth", 10); Destroy(this.gameObject); } . . . Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Triggers and actions void OnTriggerEnter(Collider col) { switch(col.gameObject.tag) case "Enemy": if(meleeType != MeleeType.Potion) . . . break; case "Environment": if(meleeType == MeleeType.Potion) . . . break; } Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Different movements public MovementType moveType = MovementType.None; // reassigned in the inspector void Update() { switch(moveType) case MovementType.Basic: BasicMovement(); break; case MovementType.Drop: DropMovement(); break; } Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley