Game Development Reference
In-Depth Information
17
18 //Is orc friendly to player
19 public bool isFriendly = false;
20
21 //--------------------------------------------------
22 // Use this for initialization
23 void Start ()
24 {
25 //Get transform of orc
26 ThisTransform = transform;
27 }
28 //--------------------------------------------------
29 // Update is called once per frame
30 void Update ()
31 {
32 }
33 //--------------------------------------------------
34 //State actions for orc
35 public void AttackMelee()
36 {
37 //Do melee attack here
38 }
39 //--------------------------------------------------
40 public void AttackRange()
41 {
42 //Do range attack here
43 }
44 //--------------------------------------------------
45 }
The following are the comments for code sample 1-10:
Line 04 : Here, the class keyword is used to define a class named Orc .
This class derives from MonoBehaviour . The next section of this chapter
will consider inheritance and derived classes further.
Lines 09-19 : Several variables and an enum are added to the Orc class.
The variables are of different types, but all are related to the concept of
an orc.
Lines 35-45 : The orc has two methods: AttackMelee and AttackRange .
More information on classes and their usage in C# can be found at
http://msdn.microsoft.com/en-gb/library/x9afc042.aspx .
 
Search WWH ::




Custom Search