Example #1
0
 // Update is called once per frame
 void Update()
 {
     //El jugador esta colisionando con algo
     if (collisionStay)
     {
         //Es una zanahoria
         if (collisionName.StartsWith("Carrot") || collisionName.StartsWith("Golden"))
         {
             //El input es el correcto
             if (Input.GetButtonUp(currentInputString))
             {
                 //Empezar a sacar la zanahoria
                 playerAnimator.SetTrigger("StartPull");
                 carrotGrid.PullCarrot(playerPosX, playerPosY, currentInputPulls++);
                 //Termino de sacarla
                 if (currentInputPulls == 5)
                 {
                     //Es normal
                     if (collisionName.StartsWith("Carrot"))
                     {
                         carrotGrid.DestroyCarrot(playerPosX, playerPosY, false);
                         MoneyManager.AddActivityMoney(10f);
                     }
                     //Es de oro
                     else
                     {
                         carrotGrid.DestroyCarrot(playerPosX, playerPosY, true);
                         MoneyManager.AddActivityMoney(30f);
                     }
                 }
             }
             //Verificar que no se haya equivocado de input
             if (checkIncorrectInput())
             {
                 //Se equivoco, regresar la zanahoria a su estado inicial
                 carrotGrid.ReturnCarrotToOriginalPosition(playerPosX, playerPosY);
             }
         }
         else
         {
             //Es una ardilla
             if (collisionName.StartsWith("S"))
             {
                 //Ahuyentarla
                 if (Input.GetButtonUp(currentInputString))
                 {
                     playerAnimator.SetTrigger("Boo");
                     carrotGrid.SquirrelScared();
                 }
             }
         }
     }
 }
Example #2
0
 // Update is called once per frame
 void Update()
 {
     //El jugador esta colisionando con algo
     if (collisionStay)
     {
         //Es una zanahoria
         if (collisionName.StartsWith("Carrot") || collisionName.StartsWith("Golden"))
         {
             //El input es el correcto
             if (Input.GetButtonUp(currentInputString) ||
                 (currentInputString == "A_Button" && mobileInputs.AButton) ||
                 (currentInputString == "B_Button" && mobileInputs.BButton) ||
                 (currentInputString == "X_Button" && mobileInputs.XButton) ||
                 (currentInputString == "Y_Button" && mobileInputs.YButton))
             {
                 Debug.Log("Input correcto!");
                 //Empezar a sacar la zanahoria
                 if (currentInputPulls == 0)
                 {
                     audioSource.PlayOneShot(audioPull);
                 }
                 playerAnimator.SetTrigger("StartPull");
                 carrotGrid.PullCarrot(playerPosX, playerPosY, currentInputPulls++);
                 carrotGrid.PlayerIsPullingGoldenCarrot(collisionName.StartsWith("Golden") ? true : false);
                 //Termino de sacarla
                 if (currentInputPulls == 5)
                 {
                     audioSource.PlayOneShot(audioCoin);
                     //Es normal
                     if (collisionName.StartsWith("Carrot"))
                     {
                         carrotGrid.DestroyCarrot(playerPosX, playerPosY, false);
                         MoneyManager.AddActivityMoney(20f);
                     }
                     //Es de oro
                     else
                     {
                         carrotGrid.DestroyCarrot(playerPosX, playerPosY, true);
                         MoneyManager.AddActivityMoney(50f);
                     }
                 }
             }
             //Verificar que no se haya equivocado de input
             if (checkIncorrectInput())
             {
                 //Se equivoco, regresar la zanahoria a su estado inicial
                 carrotGrid.ReturnCarrotToOriginalPosition(playerPosX, playerPosY);
             }
         }
         else
         {
             //Es una ardilla
             if (collisionName.StartsWith("S"))
             {
                 //Ahuyentarla
                 if (Input.GetButtonUp(currentInputString) ||
                     (currentInputString == "A_Button" && mobileInputs.AButton) ||
                     (currentInputString == "B_Button" && mobileInputs.BButton) ||
                     (currentInputString == "X_Button" && mobileInputs.XButton) ||
                     (currentInputString == "Y_Button" && mobileInputs.YButton))
                 {
                     playerAnimator.SetTrigger("Boo");
                     carrotGrid.SquirrelScared();
                     audioSource.PlayOneShot(audioBoo);
                 }
             }
         }
     }
 }