/// <summary> /// Performs the patrol action. /// </summary> public override void PerformAction() { if (!m_IsWalking) { m_BasicEnemy.SetWalking(true); m_IsWalking = true; m_Animator.SetBool("IsWalking", true); if (m_WalkingDirection == 1 && !m_BasicEnemy.FacingRight) { m_BasicEnemy.Flip(); } else if (m_WalkingDirection == -1 && m_BasicEnemy.FacingRight) { m_BasicEnemy.Flip(); } } m_WalkAmount.x = m_WalkingDirection * m_WalkSpeed * Time.deltaTime; if (m_WallCheckCollider.IsTouchingLayers(m_WhatIsGround)) { m_WalkingDirection = -m_WalkingDirection; m_BasicEnemy.Flip(); } else if (!m_FloorCheckCollider.IsTouchingLayers(m_WhatIsGround)) { m_WalkingDirection = -m_WalkingDirection; m_BasicEnemy.Flip(); } m_EnemyAudio.PlayWalkAudioClip(); m_BasicEnemy.transform.Translate(m_WalkAmount); if (m_EnemyPlayerDetection.CanPlayerBeSeen() && !m_PatrolCooldown) { m_PlayerDetected.Invoke(); m_IsWalking = false; } }
/// <summary> /// Sets up the move action. /// </summary> public override void PerformAction() { if (!m_IsWalking) { m_BasicEnemy.SetWalking(true); m_IsWalking = true; } m_WalkAmount.x = m_WalkingDirection * m_WalkSpeed * Time.deltaTime; if (m_BasicEnemy.transform.position.x > m_WaypointB.x) { m_WalkingDirection = -1.0f; m_BasicEnemy.Flip(); } else if (m_BasicEnemy.transform.position.x < m_WaypointA.x) { m_WalkingDirection = 1.0f; m_BasicEnemy.Flip(); } m_EnemyAudio.PlayWalkAudioClip(); m_BasicEnemy.transform.Translate(m_WalkAmount); }