zoukankan      html  css  js  c++  java
  • 角色选择组件

    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();
    	}
    }
    

      

  • 相关阅读:
    Python学习之路—2018/6/27
    Python学习之路—2018/6/26
    python面试315问
    day4(css优先级)
    date3(form表单,今天html结束,css)
    date2(html)
    day1
    mysql数据库(7day)
    mysql数据库(day6)索引,ORM框架
    mysql数据库(day5)-视图,触发器,存储过程
  • 原文地址:https://www.cnblogs.com/xiao-wei-wei/p/3547364.html
Copyright © 2011-2022 走看看