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 IEnumerator ToMoveIE(List <Node> path, Action endCallBack) { IsRigibody = true; for (int i = 0; i < path.Count; i++) { bool isRun = true; Vector2 startPos = new Vector2(transform.position.x, transform.position.y); Vector2 endPos = GridManager.Instance.GetScalePos(path[i].Position, GridManager.Instance.YScale); float distance = Vector2.Distance(transform.position, endPos); float time = distance / Speed; float process = 0; float timer = 0; //六个方向 Node selfNode = GridManager.Instance.GetNodeByPos(transform.position); if (selfNode == path[i]) { continue; } float row = path[i].Row - selfNode.Row; float colum = path[i].Column - selfNode.Column; m_Aniamtor.SetTrigger("ToRun"); if (row == 0 && colum == -1) { m_Aniamtor.SetInteger("RunType", 0); m_Dirction = Dirction.Left; //Debug.Log("左"); } else if (row == 1 && colum == -1) { m_Aniamtor.SetInteger("RunType", 1); m_Dirction = Dirction.LeftUp; //Debug.Log("左上"); } else if (row == 1 && colum == 0) { m_Aniamtor.SetInteger("RunType", 2); m_Dirction = Dirction.RightUp; //Debug.Log("右上"); } else if (row == 0 && colum == 1) { m_Aniamtor.SetInteger("RunType", 3); m_Dirction = Dirction.Right; //Debug.Log("右"); } else if (row == -1 && colum == 1) { m_Aniamtor.SetInteger("RunType", 4); m_Dirction = Dirction.RightDown; //Debug.Log("右下"); } else if (row == -1 && colum == 0) { m_Aniamtor.SetInteger("RunType", 5); m_Dirction = Dirction.LeftDown; //Debug.Log("左下"); } while (isRun) { timer += Time.deltaTime; process = timer / time; if (process >= 1) { process = 1; isRun = false; //EazySoundManager.PlaySound(MoveClip); } Vector2 pos = Vector2.Lerp(startPos, endPos, process); transform.position = new Vector3(pos.x, pos.y, transform.position.z); if (Vector2.Distance(transform.position, Target.transform.position) < AttackRange) { if (!IsPlayer) { ToAttack(); yield return(new WaitForSeconds(0.4f)); RoleCtrl ctrl = Target.GetComponent <RoleCtrl>(); ctrl.ToDie(); yield return(new WaitForSeconds(0.25f)); ToStand(); yield return(new WaitForSeconds(1f)); } else { ToWin(); transform.position = new Vector3(endPos.x, endPos.y, transform.position.z); yield return(new WaitForSeconds(0.5f)); } if (OnWin != null) { OnWin(IsPlayer); } yield break; } yield return(null); } } if (endCallBack != null) { endCallBack(); } IsRigibody = false; ToStand(); }