protected override void Attack() { m_AttackTimer -= Time.deltaTime; if (m_AttackTimer < 0) { for (int i = 0; i < m_PhyCtroller.ForwardHitsStorage.Length; i++) { if (m_PhyCtroller.ForwardHitsStorage[i].distance > 0) { RoleCtrl ctrl = m_PhyCtroller.ForwardHitsStorage[i].collider.GetComponent <RoleCtrl>(); if (ctrl != null) { ctrl.ToHurt(m_AttackImpuse, true); m_AttackTimer = m_AttackInterval; return; } } } for (int i = 0; i < m_PhyCtroller.BackwardHitsStorage.Length; i++) { if (m_PhyCtroller.BackwardHitsStorage[i].distance > 0) { RoleCtrl ctrl = m_PhyCtroller.BackwardHitsStorage[i].collider.GetComponent <RoleCtrl>(); if (ctrl != null) { ctrl.ToHurt(m_AttackImpuse, true); m_AttackTimer = m_AttackInterval; return; } } } } }
protected override void Attack() { m_AttackTimer -= Time.deltaTime; for (int i = 0; i < m_PhyCtroller.AboveHitsStorge.Length; i++) { if (m_PhyCtroller.AboveHitsStorge[i].distance > 0) { if (m_AttackTimer < 0) { RoleCtrl player = m_PhyCtroller.AboveHitsStorge[i].collider.GetComponent <RoleCtrl>(); if (player != null) { player.ToHurt(m_AttackImpuse); m_AttackTimer = m_AttackInterval; return; } } } } if (!IsAboveAttack) { for (int i = 0; i < m_PhyCtroller.ForwardHitsStorage.Length; i++) { if (m_PhyCtroller.ForwardHitsStorage[i].distance > 0) { if (m_AttackTimer < 0) { RoleCtrl player = m_PhyCtroller.ForwardHitsStorage[i].collider.GetComponent <RoleCtrl>(); if (player != null) { player.ToHurt(m_AttackImpuse); m_AttackTimer = m_AttackInterval; return; } } } } for (int i = 0; i < m_PhyCtroller.BackwardHitsStorage.Length; i++) { if (m_PhyCtroller.BackwardHitsStorage[i].distance > 0) { if (m_AttackTimer < 0) { RoleCtrl player = m_PhyCtroller.BackwardHitsStorage[i].collider.GetComponent <RoleCtrl>(); if (player != null) { player.ToHurt(m_AttackImpuse); m_AttackTimer = m_AttackInterval; return; } } } } } }
private void OnTriggerStay2D(Collider2D collision) { m_AttackTimer -= Time.deltaTime; if (m_AttackTimer < 0) { m_IsAttack = true; } if (m_IsAttack) { RoleCtrl ctrl = collision.GetComponent <RoleCtrl>(); if (ctrl != null) { ctrl.ToHurt(m_AttackImpuse); m_IsAttack = false; m_AttackTimer = m_AttackInterval; } } }
private void RayCastFloor() { if (!m_Attack) { m_LineRender.SetPosition(1, m_LineStartPos.position); return; } m_LineRenderMaterial.SetTextureOffset("_MainTex", new Vector2(m_Angle * 10, 0)); Vector3 dir = Vector3.one; if (m_Dir == 1) { m_Angle = m_Angle + m_AngleSpeed * Time.deltaTime; Quaternion rot = Quaternion.AngleAxis(m_Angle, Vector3.forward); dir = rot * Vector3.down; } else { m_Angle = m_Angle - m_AngleSpeed * Time.deltaTime; Quaternion rot = Quaternion.AngleAxis(m_Angle, Vector3.forward); dir = rot * Vector3.down; } RaycastHit2D hit = PhyDebug.Raycast(m_LineStartPos.position, dir, 10, m_LineMask, Color.red); if (hit.distance > 0) { m_LineRender.SetPosition(1, hit.point); m_HitPoint = hit.point; if (m_AttackRole) { RoleCtrl ctrl = hit.collider.GetComponent <RoleCtrl>(); if (ctrl != null) { if (Vector2.Dot(transform.position - ctrl.transform.position, ctrl.transform.right) > 0) { ctrl.ToHurt(5, chandDir: true); } else { ctrl.ToHurt(5); } m_AttackRole = false; } } } if (m_Dir == 1) { if (m_Angle >= 90) { m_Attack = false; //StartCoroutine("EndAttack"); } } else { if (m_Angle <= -90) { m_Attack = false; //StartCoroutine("EndAttack"); } } }