|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 |
using
UnityEngine;using
System.Collections;/// <summary>/// 角色选择组件/// </summary>public
class CharacterChoise : MonoBehaviour { public
Occupation occupation;//职业信息 public
Character character;//角色信息 public
Transform perspective;//相机视角 public
Transform look;//视点 Animator animator;//当前动画组件 #region 高光组件 public
HighlightableObject highLight;//高光组件 public
Color highColor;//高光颜色 #endregion void
Start() { //获取移动点 perspective = GameObject.Find(occupation.ToString() + "_perspective").transform; look = transform.Find("look"); //初始化角色信息 if(character == null){ switch(occupation){ case
Occupation.Assassin: character = new
Assassin();initHighLight(Color.magenta); break; case
Occupation.Berserker: character = new
Berserker();initHighLight(Color.blue); break; case
Occupation.Enchanter: character = new
Enchanter();initHighLight(Color.yellow); break; case
Occupation.Paladin: character = new
Paladin();initHighLight(Color.green); break; } character.initAtt(); } animator = GetComponent<Animator>(); } /// <summary> /// 摆姿势(选中) /// </summary> public
void Pose(){ if(animator != null){ animator.SetBool("IsIdle",false); animator.SetBool("IsPose",true); }else{ animation.CrossFade("Attack"); } } /// <summary> /// 空闲(未选中) /// </summary> public
void Idle(){ if(animator != null){ animator.SetBool("IsIdle",true); animator.SetBool("IsPose",false); }else{ animation.CrossFade("Idle"); } } /// <summary> /// 初始化高光组件 /// </summary> void
initHighLight(Color color){ highLight = gameObject.AddComponent<HighlightableObject>(); highColor = color; } /// <summary> /// 鼠标进入:高光 /// </summary> void
OnMouseEnter(){ highLight.ConstantOn(highColor); } /// <summary> /// 鼠标离开:无光 /// </summary> void
OnMouseExit(){ highLight.ConstantOff(); }} |
原文:http://www.cnblogs.com/xiao-wei-wei/p/3547364.html