private void SetUpDefaultVariables() { // Prevent Yarn Ball from colliding with Enemy before it is thrown myCollider.enabled = false; // Set the Bomb initial state yarnBallState = YarnBallState.PickUp; }
private void ControllYarnBallDisplacementProgress() { if (yarnBallState == YarnBallState.FlyingToPlayer || yarnBallState == YarnBallState.FlyingToEnemy) { distanceTraveled = yarnBallThrowingSpeed * (Time.time - timeWhenWasThrown); distanceToBeTraveled = (positionWhenThrownByEnemy - positionWhenLanded).magnitude; percentualDistanceTravaled = distanceTraveled / distanceToBeTraveled; // 1.75f PlayArcAnimation(); if (percentualDistanceTravaled >= 1f) { SetMovementRestrictions(); PrepareYarnBallToRoll(); ResetArcProgress(); if (yarnBallState == YarnBallState.FlyingToPlayer) { yarnBallState = YarnBallState.GroundedAtPlayerArea; } else if (yarnBallState == YarnBallState.FlyingToEnemy) { yarnBallState = YarnBallState.PickUp; } } } }
private void PrepareYarnBallToRoll() { if (yarnBallState == YarnBallState.FlyingToPlayer) { myCollider.enabled = true; yarnBallState = YarnBallState.GroundedAtPlayerArea; } }
private void SetUpTravelBackToCaster() { RemoveMovementRestrictions(); // positionWhenLanded = transform.position; myCollider.isTrigger = true; // Get a Time reference for the moment the action begun timeWhenWasThrown = Time.time; yarnBallState = YarnBallState.FlyingToEnemy; }
public void SetpUpThrowAgainstPlayer() { positionWhenThrownByEnemy = transform.position; if (isFacingRight) { positionWhenLanded = new Vector2(transform.position.x + 1.8f, transform.position.y - 0.4f); } else { positionWhenLanded = new Vector2(transform.position.x - 1.8f, transform.position.y - 0.4f); } DefineYarnBallOriginalDirection(isFacingRight); // Get a Time reference for the moment the action begun timeWhenWasThrown = Time.time; yarnBallState = YarnBallState.FlyingToPlayer; }
public void LiftYarnBall() { yarnBallState = YarnBallState.Lifted; }