public IEnumerator ToHurt(RoleTransferAttackInfo attackInfo)
        {
            if (m_StateMachine == null)
            {
                yield break;
            }
            SkillEntity      skillEntity      = SkillDBModel.Instance.Get(attackInfo.SkillId);
            SkillLevelEntity skillLevelEntity = SkillLevelDBModel.Instance.GetSkillLevelBySkillIdAndLevel(attackInfo.SkillId, attackInfo.SkillLevel);

            if (skillEntity == null || skillLevelEntity == null)
            {
                yield break;
            }
            yield return(new WaitForSeconds(skillEntity.ShowHurtEffectDelaySecond));

            //减血
            //m_Role.HeadBar.BloodTextAni(attackInfo.HurtValue);
            m_Role.CurRoleInfo.CurrentHP -= attackInfo.HurtValue;
            if (m_Role.CurRoleInfo.CurrentHP < 0)
            {
                m_Role.CurRoleInfo.CurrentHP = 0;
                m_Role.ToDie();
                if (OnHurt != null)
                {
                    OnHurt();
                }
                yield break;
            }
            if (OnHurt != null)
            {
                OnHurt();
            }
            //播放受伤特效
            int   fontSize = 1;
            Color color    = Color.red;

            if (attackInfo.IsCri)
            {
                fontSize = 2;
                color    = Color.yellow;
            }
            if (!m_Role.IsRigibody)
            {
                //m_StateMachine.ChangeState(RoleStateType.Hurt);
            }
        }
        private RoleTransferAttackInfo CalculationHurtValue(AttackType attackType, RoleCtrl enemy, SkillEntity skillEntity, SkillLevelEntity skillLevelEntity)
        {
            RoleTransferAttackInfo attackInfo = new RoleTransferAttackInfo();

            attackInfo.AttackRoleID   = m_Role.CurRoleInfo.RoleId;
            attackInfo.BeAttaclRoleID = enemy.CurRoleInfo.RoleId;
            attackInfo.IsCri          = false;
            float damage = 0;

            if (attackType == AttackType.PhyAttack)
            {
                damage = m_Role.CurRoleInfo.PhyAtk - enemy.CurRoleInfo.PhyDef;
            }
            else
            {
                attackInfo.SkillId    = skillEntity.Id;
                attackInfo.SkillLevel = skillLevelEntity.Level;
                //物理系攻击
                if (skillEntity.SkillType == 0)
                {
                    damage = m_Role.CurRoleInfo.PhyAtk * skillLevelEntity.HurtValueRate - enemy.CurRoleInfo.PhyDef;
                }
                else
                {
                    //魔法系攻击
                    damage = m_Role.CurRoleInfo.MgicAtk * skillLevelEntity.HurtValueRate - enemy.CurRoleInfo.MgicDef;
                }
                damage /= 10;
                bool isCri = Random.Range(1, 101) < m_Role.CurRoleInfo.Cri;
                attackInfo.IsCri = isCri;
                if (isCri)
                {
                    damage *= m_Role.CurRoleInfo.CriValue;
                }
                if (damage <= 0)
                {
                    damage = 1;
                }
            }
            attackInfo.HurtValue = (int)damage;
            return(attackInfo);
        }
        public bool ToAttackBySkillId(AttackType attackType, int skillId)
        {
            if (m_Role.StateMachine.CurrentRoleStateType == RoleStateType.Die)
            {
                return(false);
            }
            if (m_EnemyList == null)
            {
                m_EnemyList = new List <RoleCtrl>();
            }
            m_Role.StateMachine.IsNormalAtk = false;
            m_EnemyList.Clear();
            m_AttackPosList.Clear();
            if (m_Role.CurRoleType == RoleType.Hero || m_Role.CurRoleType == RoleType.Monster)
            {
                SkillLevelEntity sklillLevleEntity = null;
                SkillEntity      skillEntity       = null;
                if (attackType == AttackType.PhyAttack)
                {
                    m_Role.StateMachine.IsNormalAtk = true;
                }
                else
                {
                    skillEntity = SkillDBModel.Instance.Get(skillId);
                    m_Role.StateMachine.SkillIndex = 0;
                    if (skillEntity == null)
                    {
                        return(false);
                    }
                    if (m_Role.LockEnemy != null && m_Role.CurRoleType == RoleType.Monster)
                    {
                        //这里重新做,暂时只打锁定目标
                        //TODO
                        sklillLevleEntity = SkillLevelDBModel.Instance.GetSkillLevelBySkillIdAndLevel(skillEntity.Id, 1);
                        m_EnemyList.Add(m_Role.LockEnemy);
                    }
                    else if (m_Role.CurRoleType == RoleType.Hero)
                    {
                        int skillLevel = ((HeroInfo)m_Role.CurRoleInfo).GetSkillLevel(skillEntity.Id);
                        sklillLevleEntity = SkillLevelDBModel.Instance.GetSkillLevelBySkillIdAndLevel(skillEntity.Id, skillLevel);
                        SearchEnemys(m_Role.AttackOrigin, skillEntity.AttackArea, skillEntity.AttackRange);
                    }
                }

                m_Role.StateMachine.ChangeState(RoleStateType.Attack);
                for (int i = 0; i < m_EnemyList.Count; i++)
                {
                    RoleTransferAttackInfo info = CalculationHurtValue(attackType, m_EnemyList[i], skillEntity, sklillLevleEntity);
                    m_EnemyList[i].ToHurt(info);
                }
                //生成攻击特效
                if (!string.IsNullOrEmpty(skillEntity.AttackEffect))
                {
                    GameObject go = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.Effect, "RoleEffect/" + skillEntity.AttackEffect, isCache: true);
                    go.transform.SetParent(m_Role.transform);
                    go.transform.localPosition = Vector3.zero;
                    AttackEffectBase effect = go.GetComponent <AttackEffectBase>();
                    effect.Init(m_Role, "RoleEffect/" + skillEntity.AttackEffect, m_EnemyList, m_AttackPosList);
                }
            }
            return(false);
        }
 /// <summary>
 /// 切换到受伤画面
 /// </summary>
 public void ToHurt(RoleTransferAttackInfo attackInfo)
 {
     StartCoroutine(m_Hurt.ToHurt(attackInfo));
 }