Ejemplo n.º 1
0
    //Check if pin is ready to be unlocked
    private IEnumerator CheckPin()
    {
        checkingPin = true;
        yield return(new WaitForSecondsRealtime(0.1f));

        float currentState = SelectedAnim.GetCurrentAnimatorStateInfo(0).normalizedTime;
        float sweetSpot    = SelectedPin.GetComponent <Behaviour_LockPin>().Fraction;

        if (Mathf.Abs(sweetSpot - currentState) < 0.01f)
        {
            sweetSpotReached = true;
        }
        else
        {
            sweetSpotReached = false;
        }
        checkingPin = false;
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     lockAxis = CrossPlatformInputManager.GetAxis("GunVertical") % 1;
     if (CrossPlatformInputManager.GetButtonDown("Horizontal") && SelectedAnim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1)
     {
         ChangeSelectedPin(CrossPlatformInputManager.GetAxis("Horizontal"));
     }
     if (CrossPlatformInputManager.GetButton("Fire2") && lockAxis >= 0 && SelectedAnim.GetCurrentAnimatorStateInfo(0).normalizedTime > 0)
     {
         SelectedAnim.SetFloat("Speed", -lockAxis);
         foreach (var anim in PrecedingAnims)
         {
             if ((anim.GetCurrentAnimatorStateInfo(0).normalizedTime - SelectedAnim.GetCurrentAnimatorStateInfo(0).normalizedTime) > 0.42f)
             {
                 anim.SetFloat("Speed", -lockAxis);
             }
             else if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime <= 1)
             {
                 anim.SetFloat("Speed", 1);
             }
             else
             {
                 anim.SetFloat("Speed", 0);
             }
         }
     }
     else if (SelectedAnim.GetCurrentAnimatorStateInfo(0).normalizedTime <= 1)
     {
         SelectedAnim.SetFloat("Speed", 1);
         foreach (var anim in PrecedingAnims)
         {
             if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime <= 1)
             {
                 anim.SetFloat("Speed", 1);
             }
             else
             {
                 anim.SetFloat("Speed", 0);
             }
         }
     }
     else
     {
         SelectedAnim.SetFloat("Speed", 0);
         PrecedingAnims.ForEach(x => x.SetFloat("Speed", 0));
     }
     if (!checkingPin && SelectedPin == UI_Lock.PinOrder[currentPosition])
     {
         StartCoroutine(CheckPin());
     }
     if (SelectedAnim.GetCurrentAnimatorStateInfo(0).normalizedTime < 0.56f) //Change dropped lower pin position if pick has reached them
     {
         HoldPinResidue.ForEach(x => x.droppedPosition = new Vector3(x.droppedPosition.x, pick.GetChild(0).position.y));
     }
     if (sweetSpotReached)
     {
         UI_Lever.SetLeverStatus(true);
         if (CrossPlatformInputManager.GetButtonDown("Fire1"))
         {
             HoldPin();
         }
     }
     else
     {
         UI_Lever.SetLeverStatus(false);
     }
     if (CrossPlatformInputManager.GetButton("Cancel")) // If Cancel Pressed disable lock UI
     {
         gameObject.SetActive(false);
     }
 }