finished fixing events control
This commit is contained in:
@@ -7,6 +7,8 @@ public class BugMovement : MonoBehaviour
|
||||
[SerializeField] private float secondsGoingLeft = 1;
|
||||
[SerializeField] private float secondsGoingRight = 1;
|
||||
[SerializeField] private float movementSpeed = 10;
|
||||
[SerializeField] public int eventTriggerCount = 3;
|
||||
[SerializeField] public int controlTriggerCounterEvent = 3;
|
||||
[SerializeField] Collider2D playerCollider;
|
||||
[SerializeField] EventControls eventControls;
|
||||
[SerializeField] Player player;
|
||||
@@ -14,6 +16,7 @@ public class BugMovement : MonoBehaviour
|
||||
private int leftAccumalator = 0;
|
||||
private int rightAccumalator = 0;
|
||||
private Rigidbody2D rigidBody;
|
||||
private bool isMovementDisabled = false;
|
||||
|
||||
private int framesPerSecond => 60;
|
||||
|
||||
@@ -27,6 +30,8 @@ public class BugMovement : MonoBehaviour
|
||||
{
|
||||
if (HasEncounteredPlayer())
|
||||
eventControls.TriggerEvent(playerCollider, GetComponent<Collider2D>(), player);
|
||||
if (isMovementDisabled)
|
||||
return;
|
||||
|
||||
var totalFramesGoingLeft = framesPerSecond * secondsGoingLeft;
|
||||
var totalFramesGoingRight = framesPerSecond * secondsGoingRight;
|
||||
@@ -65,4 +70,14 @@ public class BugMovement : MonoBehaviour
|
||||
{
|
||||
return rigidBody.IsTouchingLayers(LayerMask.GetMask(LayerNames.Player));
|
||||
}
|
||||
|
||||
public void DisableMovement()
|
||||
{
|
||||
isMovementDisabled = true;
|
||||
}
|
||||
|
||||
public void EnableMovement()
|
||||
{
|
||||
isMovementDisabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user