Exemplo n.º 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;
 }
Exemplo n.º 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;
                }
            }
        }
    }
Exemplo n.º 3
0
 private void PrepareYarnBallToRoll()
 {
     if (yarnBallState == YarnBallState.FlyingToPlayer)
     {
         myCollider.enabled = true;
         yarnBallState      = YarnBallState.GroundedAtPlayerArea;
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 6
0
 public void LiftYarnBall()
 {
     yarnBallState = YarnBallState.Lifted;
 }