首页 > 其他 > 详细

角色选择组件

时间:2014-02-13 12:37:44      阅读:390      评论:0      收藏:0      [点我收藏+]
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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!