Exemplo n.º 1
0
 public virtual void OnPointerUp(PointerEventData ped)
 {
     this.inputVector = Vector3.zero;
     this.joystickKnobImage.get_rectTransform().anchoredPosition = Vector3.zero;
     CrossPlatformInputManager.SetAxisZero("Horizontal");
     CrossPlatformInputManager.SetAxisZero("Vertical");
 }
Exemplo n.º 2
0
 private void OnEnable()
 {
     this.bgImage.gameObject.SetActive(false);
     this.inputVector = (Vector3)Vector2.zero;
     this.joystickKnobImage.get_rectTransform().anchoredPosition = Vector2.zero;
     CrossPlatformInputManager.SetAxisZero("Horizontal");
     CrossPlatformInputManager.SetAxisZero("Vertical");
     this.touchCounter = 0;
 }
Exemplo n.º 3
0
 public virtual void OnPointerUp(PointerEventData ped)
 {
     this.touchCounter--;
     if (this.touchCounter == 0)
     {
         this.bgImage.gameObject.SetActive(false);
         this.inputVector = (Vector3)Vector2.zero;
         this.joystickKnobImage.get_rectTransform().anchoredPosition = Vector2.zero;
         CrossPlatformInputManager.SetAxisZero("Horizontal");
         CrossPlatformInputManager.SetAxisZero("Vertical");
     }
 }
 void Start()
 {
     if (PlayerPrefs.GetInt(TOUCH_ENABLED) == DISABLED)
     {
         useTouchUI            = false;
         touchUICanvas.enabled = false;
     }
     else
     {
         CrossPlatformInputManager.SetAxisZero("Fire1");
         CrossPlatformInputManager.SetAxisZero("Horizontal");
         CrossPlatformInputManager.SetButtonUp("Jump");
     }
 }
Exemplo n.º 5
0
    void Move(float delta)
    {
        float horazital = CrossPlatformInputManager.GetAxis("JoyStickX");
        float vertical  = CrossPlatformInputManager.GetAxis("JoyStickY");

        CrossPlatformInputManager.SetAxisZero("JoyStickX");
        CrossPlatformInputManager.SetAxisZero("JoyStickY");
        // Debug.Log(Mathf.Sqrt(horazital*horazital + vertical * vertical));
        float smooth = Mathf.Clamp(Mathf.Sqrt(Mathf.Sqrt(horazital * horazital + vertical * vertical)), 0, 3);

        if (checkNearTarget && signTran != null)
        {
            //Transform signTran = GameObject.Find("Sign").transform;
            bool hasTarget = false;
            // Gizmos.DrawCube(tr)
            if (signTran != null)
            {
                RaycastHit2D[] raycasts = Physics2D.BoxCastAll(signTran.position, new Vector2(0.1f, 0.1f), 0f, Vector2.zero);
                if (raycasts != null && raycasts.Length > 0)
                {
                    for (int i = 0; i < raycasts.Length; i++)
                    {
                        if (raycasts[i].collider.gameObject.GetComponent <GameItem>() != null || raycasts[i].collider.gameObject.GetComponent <GAFEnemy>() != null || raycasts[i].collider.GetComponentInParent <GAFEnemy>() != null)
                        {
                            hasTarget = true;
                            break;
                        }
                    }
                }
            }
            if (hasTarget)
            {
                smooth = nearSmoothRatio;
                //Debug.Log("near target");
            }
        }
        Vector3 newPos = transform.position + new Vector3(horazital, vertical, 0);

        //transform.rotation = new Quaternion(transform.rotation.x+ horazital * Mathf.Deg2Rad * smoothRatio, transform.rotation.y + vertical * Mathf.Deg2Rad * smoothRatio, transform.rotation.z,transform.rotation.w);
        if (restrictionMoveZone)
        {
            newPos = new Vector3(Mathf.Clamp(newPos.x, minWidth, MaxWidth), Mathf.Clamp(newPos.y, minHight, maxHight), newPos.z);
        }

        transform.position = Vector3.Lerp(transform.position, newPos, delta * smooth);
    }
Exemplo n.º 6
0
 private void Start()
 {
     CrossPlatformInputManager.SetAxisZero("Horizontal");
     CrossPlatformInputManager.SetAxisZero("Vertical");
     if (base.GetComponent <Image>() == null)
     {
         Debug.LogError("There is no joystick image attached to this script.");
     }
     if (base.transform.GetChild(0).GetComponent <Image>() == null)
     {
         Debug.LogError("There is no joystick handle image attached to this script.");
     }
     if ((base.GetComponent <Image>() != null) && (base.transform.GetChild(0).GetComponent <Image>() != null))
     {
         this.bgImage.get_rectTransform().SetAsLastSibling();
     }
 }
Exemplo n.º 7
0
    private void StopMove()
    {
        switch (direction)
        {
        case Direction.Up:
        case Direction.Down:
            CrossPlatformInputManager.SetAxisZero("Vertical");
            break;

        case Direction.Right:
        case Direction.Left:
            CrossPlatformInputManager.SetAxisZero("Horizontal");
            break;

        default:

            break;
        }
    }
Exemplo n.º 8
0
 private void Start()
 {
     CrossPlatformInputManager.SetAxisZero("Horizontal");
     CrossPlatformInputManager.SetAxisZero("Vertical");
     if (base.GetComponent <Image>() == null)
     {
         Debug.LogError("There is no joystick image attached to this script.");
     }
     if (base.transform.GetChild(0).GetComponent <Image>() == null)
     {
         Debug.LogError("There is no joystick handle image attached to this script.");
     }
     if ((base.GetComponent <Image>() != null) && (base.transform.GetChild(0).GetComponent <Image>() != null))
     {
         this.bgImage           = base.GetComponent <Image>();
         this.joystickKnobImage = base.transform.GetChild(0).GetComponent <Image>();
         this.bgImage.get_rectTransform().SetAsLastSibling();
         this.bgImage.get_rectTransform().GetWorldCorners(this.fourCornersArray);
         this.bgImageStartPosition = this.fourCornersArray[3];
         this.bgImage.get_rectTransform().pivot    = new Vector2(1f, 0f);
         this.bgImage.get_rectTransform().position = (Vector3)this.bgImageStartPosition;
     }
 }
Exemplo n.º 9
0
 public void SetAxisNeutralState()
 {
     CrossPlatformInputManager.SetAxisZero(Name);
 }
Exemplo n.º 10
0
 public void NeutralizeInput()
 {
     CrossPlatformInputManager.SetAxisZero(horizontalAxisName);
     CrossPlatformInputManager.SetAxisZero(verticalAxisName);
 }
Exemplo n.º 11
0
    void Update()
    {
        ProgressBar();
        UpdateDifficulty();

        // Impede que o jogo prossiga enquanto ainda estiver na introdução
        if (intro == true && introAnim != null && introAnim.GetCurrentAnimatorStateInfo(0).IsTag("1"))
        {
            paused = true;
        }
        // Ao final da intro, permite que o jogo prossiga
        else if (intro == true)
        {
            paused = false;
            intro  = false;
            player.GetComponent <SpriteRenderer>().enabled = true;
        }

        // Desativa a barra de progresso e controle de poweUPs quando o jogo é pausado
        if (paused)
        {
            PainelPowerUp.gameObject.SetActive(false);
            progressBarFrame.gameObject.SetActive(false);
            Background.gameObject.SetActive(false);

#if UNITY_ANDROID
            pauseButton.gameObject.SetActive(false);

            if (PlayerPrefs.GetInt("INPUTCONFIG") == JOYSTICK && freeJoystick.gameObject.activeSelf)
            {
                freeJoystick.GetComponent <AnalógicoLivre>().NeutralizeInput();
                freeJoystick.gameObject.SetActive(false);
            }

            else if (PlayerPrefs.GetInt("INPUTCONFIG") == VIRTUAL && mobileVirtualButtonsController.gameObject.activeSelf)
            {
                CrossPlatformInputManager.SetAxisZero("Horizontal");
                CrossPlatformInputManager.SetAxisZero("Vertical");
                mobileVirtualButtonsController.gameObject.SetActive(false);
            }
#endif
        }
        else
        {
            PainelPowerUp.gameObject.SetActive(true);
            progressBarFrame.gameObject.SetActive(true);
            Background.gameObject.SetActive(true);

#if UNITY_ANDROID
            pauseButton.gameObject.SetActive(true);

            if (PlayerPrefs.GetInt("INPUTCONFIG") == JOYSTICK && !freeJoystick.gameObject.activeSelf)
            {
                freeJoystick.gameObject.SetActive(true);
            }

            else if (PlayerPrefs.GetInt("INPUTCONFIG") == VIRTUAL && !mobileVirtualButtonsController.gameObject.activeSelf)
            {
                mobileVirtualButtonsController.gameObject.SetActive(true);
            }
#endif
        }

        // Verifica se o jogador ganhou
        if (winAnimation)
        {
            // Executa a animação de vitória
            PlayWinAnimation();
        }

        // Verifica se deve avisar o jogador
    }
Exemplo n.º 12
0
    protected virtual void Movement()
    {
        if (keyboardMode)
        {
            dirx        = Input.GetAxisRaw("Horizontal");
            diry        = Input.GetAxisRaw("Vertical");
            feverButton = Input.GetAxisRaw("Jump");
        }
        else
        {
            dirx        = CrossPlatformInputManager.GetAxisRaw("Horizontal");
            diry        = CrossPlatformInputManager.GetAxisRaw("Vertical");
            feverButton = CrossPlatformInputManager.GetAxisRaw("Fire1");
        }

        mDir = new Vector2(dirx, diry);
        if (canMove)
        {
            if (beatManager.movable && mDir != Vector2.zero && mDir.magnitude == 1 && !beatManager.isMovingCurrentBeat)
            {
                hit = Physics2D.Raycast(transform.position, mDir, 1f, mask);
                if (hit && hit.transform.tag == "Interactable")
                {
                    print(hit.transform.tag);
                    var interactable = hit.transform.GetComponent <Interactable>();
                    interactable.Interact();
                    anim.SetTrigger("Fail");
                    beatManager.isMovingCurrentBeat = true;
                    CrossPlatformInputManager.SetAxisZero("Horizontal");
                    CrossPlatformInputManager.SetAxisZero("Vertical");
                    moveSign++;
                    return;
                }
                else if (hit)
                {
                    anim.SetTrigger("Fail");
                    fm.ResetCombo();
                    if (!judgeFX[1].isPlaying)
                    {
                        judgeFX[1].Play();
                    }

                    beatManager.isMovingCurrentBeat = true;
                    CrossPlatformInputManager.SetAxisZero("Horizontal");
                    CrossPlatformInputManager.SetAxisZero("Vertical");
                    moveSign++;
                    return;
                }

                if (fm.comboCount >= 10)
                {
                    foreach (var fx in stompFX)
                    {
                        fx.Play();
                    }
                }

                fm.IncreseCombo();
                clapSFX.Play();
                judgeFX[0].Play();
                previousPos = transform.position;
                transform.Translate(mDir);
                beatManager.isMovingCurrentBeat = true;
                CrossPlatformInputManager.SetAxisZero("Horizontal");
                CrossPlatformInputManager.SetAxisZero("Vertical");
                moveSign++;
                return;
            }
            else if (!beatManager.movable && mDir != Vector2.zero && mDir.magnitude == 1)
            {
                anim.SetTrigger("Fail");
                fm.ResetCombo();
                judgeFX[1].Play();
                if (beatManager.judge2 > 10)
                {
                    beatManager.preMiss = true;
                }
                beatManager.isMovingCurrentBeat = true;
                CrossPlatformInputManager.SetAxisZero("Horizontal");
                CrossPlatformInputManager.SetAxisZero("Vertical");
            }

            if (beatManager.movable && feverButton == 1 && fm.isAvailable && !beatManager.isMovingCurrentBeat)
            {
                clapSFX.Play();
                judgeFX[0].Play();
                fm.ResetFeverGauge();
                fm.isAvailable = false;
                fm.feverButton.OnFever(false);
                beatManager.isMovingCurrentBeat = true;
                CrossPlatformInputManager.SetAxisZero("Fire1");
                moveSign++;
                print("Fire");
                ActiveSkill();
            }
        }
        else
        {
            if (mDir != Vector2.zero && mDir.magnitude == 1)
            {
                anim.SetTrigger("Fail");
                CrossPlatformInputManager.SetAxisZero("Horizontal");
                CrossPlatformInputManager.SetAxisZero("Vertical");
            }
        }
    }
Exemplo n.º 13
0
 void GetPlayer(Transform obj)
 {
     CrossPlatformInputManager.SetAxisZero("Horizontal");//если игрок умер нужно освободить кнопки от нажатия
     CrossPlatformInputManager.SetAxisZero("Vertical");
     player = obj.GetComponent <Player>();
 }