前言
在上一篇简单的分析完战斗流程,接下来,将仔细分析,每个环节的代码,这一篇研究UI层面的交互,即流程中的第一步
目标:实现,按住技能在人物周围显示技能范围,
步骤
1 按压触发,这里使用NGUI
UIEventListener.Get(技能图标).onPress = PressSkillButton;
void PressSkillButton(GameObject o, bool ispress)
{
if (o == 此技能图标)
{
if (ispress)
{
//执行图标动画
o.transform.parent.GetComponent<Animator>().Play("press");
//方法在PartyAI中定义
PlayerPartyAI.instance.PressSkillButton( 角色索引,技能索引 );
}
else
{
//松手,如果是点击操作
if (ButtonUpOnThis(o))
{ //播放动画
o.transform.parent.GetComponent<Animator>().Play("click");
//方法在PartyAI中定义
PlayerPartyAI.instance.InputSkilButton(角色索引,技能索引 );
}
else o.transform.parent.GetComponent<Animator>().Play("idle");
}
}
}
2 技能范围显示,要做一个prefab,技能范围,分为扇形攻击:技能角度,技能范围(长度),直线型攻击:技能宽度,技能范围(长度),所以要定义两个接口,
using UnityEngine;
using System.Collections;
//[ExecuteInEditMode]
public class BattleSkillRange : MonoBehaviour {
public float skillAngle = 10f;
public