Esempio n. 1
0
        //朝向判断
        public virtual float UsefulView(ICharactor theTarget)
        {
            var direction = Vector3.Normalize(theTarget.transform.position - transform.position);
            var value     = Vector3.Dot(direction, transform.forward);
            var rad       = Mathf.Acos(value);      //反余弦函数求弧度

            return(rad * Mathf.Rad2Deg);            //转换为度数返回
        }
Esempio n. 2
0
        //被敌人攻击
        public override void UnderAttack(ICharactor theTarget)
        {
            var dir   = Vector3.Normalize(theTarget.transform.position - transform.position);
            var value = UsefulView(theTarget);

            //背面
            if (value >= 0 && value < 60)
            {
                //没有找到相应的动画,用正面被攻击的替代
                MyActionManager.General.GetDamageAnimation(0, 0);                 //触发被攻击动画
            }

            //侧面
            else if (value >= 60 && value < 120)
            {
                //右
                if (dir.x > 0)
                {
                    MyActionManager.General.GetDamageAnimation(-1, 0);                     //触发被攻击动画
                }
                //左
                else if (dir.x < 0)
                {
                    MyActionManager.General.GetDamageAnimation(1, 0);                     //触发被攻击动画
                }
            }

            //正面
            else if (value >= 120 && value <= 180)
            {
                MyActionManager.General.GetDamageAnimation(0, 0);                 //触发被攻击动画
            }

            //计算伤害值
            CharactorAttr.GetRemainHp(theTarget);
            if (CharactorAttr.GetNowHp() <= 0)
            {
                MyActionManager.General.GetDeadAnimation();                 //触发死亡动画
            }

//			Debug.Log("最大生命值" + CharactorAttr.GetMaxHp());
//			Debug.Log("当前生命值" + CharactorAttr.GetNowHp());
//			Debug.Log("当前伤害" + GetAtkValue());
        }
        //----------------------------------------------------------


        #region Unity Messages

        private void Start()
        {
            _charactor = transform.parent.GetComponent <ICharactor>();
        }
Esempio n. 4
0
 //通知AI有角色被移除
 protected void RemoveAi(ICharactor theTarget)
 {
     CharactorAi.RemoveAiTarget(theTarget);
 }
Esempio n. 5
0
 public virtual void LookTarget(ICharactor theTarget)
 {
     //盯住目标
 }
Esempio n. 6
0
 public virtual void UnderAttack(ICharactor theTarget)
 {
     //被敌人攻击
 }
Esempio n. 7
0
        //----------------------------------------------------------------------


        #region Virtual_Methods

        public virtual void Attack(ICharactor theTarget)
        {
            _weapon.WeaponAttack(theTarget);
        }
Esempio n. 8
0
 //锁定目标
 public override void LookTarget(ICharactor theTarget)
 {
     var direction = theTarget.transform.position - transform.position;
     var lookRotation = Quaternion.LookRotation(direction);
     transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, 0.1f);
 }
Esempio n. 9
0
 //攻击
 public override void Attack(ICharactor theTarget)
 {
     MyAnimator.SetTrigger("LAttack");
 }