Пример #1
0
 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;
 }
Пример #2
0
    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;
                }
            }
        }
    }
Пример #3
0
 private void PrepareYarnBallToRoll()
 {
     if (yarnBallState == YarnBallState.FlyingToPlayer)
     {
         myCollider.enabled = true;
         yarnBallState      = YarnBallState.GroundedAtPlayerArea;
     }
 }
Пример #4
0
 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;
 }
Пример #5
0
 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;
 }
Пример #6
0
 public void LiftYarnBall()
 {
     yarnBallState = YarnBallState.Lifted;
 }