public void Update()
 {
     if (!eventSystem.enabled)
     {
         if (UNInput.GetButtonDown(ButtonCode.B))
         {
             CreditsToMenu();
             eventSystem.enabled = true;
         }
     }
 }
Exemplo n.º 2
0
        protected override void Update()
        {
            base.Update();

            m_MovementInputValue = (m_MovementInputValue == 0) ? UNInput.GetAxis(m_PlayerNumber, _networkVerticalAxis) : m_MovementInputValue;
            m_TurnInputValue     = (m_TurnInputValue == 0) ? UNInput.GetAxis(m_PlayerNumber, _networkHorizontalAxis) : m_TurnInputValue;

            if (Input.GetButtonDown(_placeAmpButton) || UNInput.GetButtonDown(m_PlayerNumber, "Action"))
            {
                Debug.LogFormat("Player {0} placed an Amp!", m_PlayerNumber);
                PlaceAmp();
            }

            if (Input.GetKeyDown(KeyCode.Backspace) || UNInput.GetButtonDown(m_PlayerNumber, "Start"))
            {
                for (int i = _amps.Count - 1; i >= 0; i--)
                {
                    var a = _amps[i];
                    DestroyAmp(a);
                }

                _amps.Clear();
            }

            var enemyAmps = GameController.Instance.EnemyAmps(_player);

            AmpController target  = null;
            var           minDist = float.MaxValue;

            foreach (var a in enemyAmps)
            {
                Vector3 point;
                var     dist = a.PowLine.SqrDistanceFromPoint(_transform.position, out point);

                if (dist < MaxCutSqrDistance && dist < minDist)
                {
                    minDist = dist;
                    Debug.DrawLine(point, point + Vector3.up * 100f, Color.yellow);
                    target = a;
                }
            }

            if (target != null && Input.GetButton(_cutButton) || UNInput.GetButton(m_PlayerNumber, "Back"))
            {
                target.Owner.DestroyAmp(target);
            }
        }
Exemplo n.º 3
0
    void Update()
    {
        if (useKeyboard)
        {
            tempH = Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow) ? 1 :
                    Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow) ? -1 : 0;
            tempV = Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow) ? 1 :
                    Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow) ? -1 : 0;
            action = Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.X);
        }
        else
        {
            tempH  = UNInput.GetAxis(joystickId, AxisCode.LSH);
            tempV  = UNInput.GetAxis(joystickId, AxisCode.LSV);
            action = UNInput.GetButtonDown(joystickId, ButtonCode.A) || UNInput.GetButtonDown(joystickId, ButtonCode.RightBumper);
        }

        if (Mathf.Abs(tempH) > controlRate)
        {
            if (tempH > 0)
            {
                movement.ChangeDirection(Direction.Right);
            }
            else
            {
                movement.ChangeDirection(Direction.Left);
            }
        }
        else if (Mathf.Abs(tempV) > controlRate)
        {
            if (tempV > 0)
            {
                movement.ChangeDirection(Direction.Top);
            }
            else
            {
                movement.ChangeDirection(Direction.Bottom);
            }
        }

        if (action)
        {
            elementBending.Action();
        }
    }
Exemplo n.º 4
0
 private void DropBlock()
 {
     if (catchBlock && guide)
     {
         guide.Throw();
     }
     if (!catchBlock && guide)
     {
         guide.Clear();
     }
     if (UNInput.GetButtonDown(playerData.ID, ButtonCode.B))
     {
         if (catchBlock)
         {
             StartCoroutine(ThrowRoutine(0.75f));
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < players.Length; i++)
        {
            players[i].Update();
        }

        for (int i = 0; i < remainingInputs.Count; i++)
        {
            if (UNInput.GetButtonDown(remainingInputs[i], "Action"))
            {
                ClickedJoined(remainingInputs[i]);
                remainingInputs.Remove(remainingInputs[i]);
            }
        }
        if (keyboardAvailable && Input.GetKeyDown(KeyCode.Space))
        {
            ClickedJoined(-1);
            keyboardAvailable = false;
        }
    }
Exemplo n.º 6
0
 private void CatchBlock()
 {
     if (catchBlock)
     {
         return;
     }
     if (interactBlock && guide)
     {
         guide.Grab();
     }
     if (!interactBlock && guide)
     {
         guide.Clear();
     }
     if (UNInput.GetButtonDown(playerData.ID, ButtonCode.A))
     {
         if (interactBlock)
         {
             StartCoroutine(GrabRoutine(0.1f));
         }
     }
 }
    public void Update()
    {
        if (!hasClicked)
        {
            return;
        }

        if (joystickID == -1)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Back();
            }
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Ready();
            }
        }
        else
        {
            UNInput.GetInputReference(joystickID, out vi);
            if (!vi.connected)
            {
                Unready();
                Unjoin();
                return;
            }

            if (UNInput.GetButtonDown(joystickID, "Back"))
            {
                Back();
            }

            if (UNInput.GetButtonDown(joystickID, "Action"))
            {
                Ready();
            }
        }
    }
Exemplo n.º 8
0
    private void Update()
    {
        if (UNInput.GetButtonDown(ButtonCode.Start))
        {
            if (playersActivated.Count > 0)
            {
                SceneManager.LoadScene(1);
            }
        }

        for (int id = 0; id < 4; id++)
        {
            if (playersActivated.Contains(id))
            {
                horizontal = UNInput.GetAxis(players[id].playerData.ID, AxisCode.LeftStickHorizontal);
                vertical   = UNInput.GetAxis(players[id].playerData.ID, AxisCode.LeftStickVertical);
                if (Mathf.Abs(horizontal) > .55f)
                {
                    if (horizontal > 0f)
                    {
                        players[id].IncrementModel();
                    }
                    else
                    {
                        players[id].DecrementModel();
                    }
                }
                if (Mathf.Abs(vertical) > .55f)
                {
                    if (vertical > 0f)
                    {
                        players[id].IncrementSkin();
                    }
                    else
                    {
                        players[id].DecrementSkin();
                    }
                }
                continue;
            }

            blockCheck = false;
            if (UNInput.GetButtonDown(id, ButtonCode.B))
            {
                for (int i = 0; i < 4; i++)
                {
                    if (players[i].IsActive())
                    {
                        continue;
                    }
                    menuController.ChooseToMenu();
                    Invoke("Start", 1f);
                    blockCheck = true;
                    break;
                }
            }
            if (UNInput.GetButtonDown(id, ButtonCode.A))
            {
                for (int i = 0; i < 4; i++)
                {
                    if (players[i].IsActive())
                    {
                        continue;
                    }
                    players[i].ActivePlayer(id, false);
                    playersActivated.Add(id);
                    blockCheck = true;
                    break;
                }
            }
            if (blockCheck)
            {
                break;
            }
        }
    }
    /// <summary>
    /// Move the player.
    /// </summary>
    /// <param name="i"> id of the joystic that is going to move this player. </param>
    public void Move(int i)
    {
        if (canMove)//Se o jogador pode se movimentar
        {
            if (usingKeyboard)
            {
                movement = Vector3.zero;
                if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W))
                {
                    movement += Vector3.forward;
                }
                if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S))
                {
                    movement += Vector3.back;
                }
                if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
                {
                    movement += Vector3.left;
                }
                if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
                {
                    movement += Vector3.right;
                }
                //Setando movimentação
            }
            else
            {
                movement = new Vector3(UNInput.GetAxis(i, AxisCode.LSH), 0f, UNInput.GetAxis(i, AxisCode.LSV)); //Setando movimentação
            }
            if (movement.magnitude < 0.2f)                                                                      //Se a movementação for pequena(correção do analógico)
            {
                movement = Vector3.zero;                                                                        //Zerando movimentação
            }
            else
            {
                transform.rotation = Quaternion.identity * Quaternion.LookRotation(movement, Vector3.up);                   //Atualizando a rotação
            }
            if (controller.isGrounded)                                                                                      //Se estiver colidindo com o chão
            {
                doubleJumping = false;                                                                                      //Pode pular a segunda vez
                if (canJump)                                                                                                //Se pode pular
                {
                    if (UNInput.GetButtonDown(i, ButtonCode.A) || (Input.GetKeyDown(KeyCode.KeypadEnter) && usingKeyboard)) //Se o jogador apertar o botão de pulo
                    {
                        Jump();                                                                                             //Função de pulo
                    }
                }
            }
            else //Se não estiver no chão
            {
                if (canDoubleJump)//Se puder pular uma segunda vez
                {
                    if (!doubleJumping)                                                                                         //Se ainda não pulou o segundo pulo
                    {
                        if (UNInput.GetButtonDown(i, ButtonCode.A) || (Input.GetKeyDown(KeyCode.KeypadEnter) && usingKeyboard)) //Se o jogador apertar o botão de pulo
                        {
                            Jump();                                                                                             //Função de pulo
                            doubleJumping = true;                                                                               //pulou segundo pulo
                        }
                    }
                }
            }

            gravity += Vector3.down * forceGravity * Time.deltaTime;                                                                                     //Adicionando a gravidade

            controller.Move(((transform.rotation * Vector3.forward * currentSpeed) * movement.magnitude * Time.deltaTime) + (gravity * Time.deltaTime)); //Movimentando
        }
        else
        {
            controller.Move(gravity * Time.deltaTime); //Somente Adicionar a gravidade
        }
        if (gravity.y < -forceGravity)                 //Se a gravidade for maior que a força gravitacional
        {
            gravity = Vector3.down * forceGravity;     //Setando o valor máximo da gravidade
        }
    }
Exemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        if (!isComplete)
        {
            switch (puzzleType)
            {
            case PuzzleType.Press:
                if (UNInput.GetButtonDown(controllerID, randButton[buttonSelected]))
                {
                    percentage += percentageIncrease;
                    if (percentage >= 100.0f)
                    {
                        Debug.Log("Completed");
                        isComplete = true;
                    }
                }

                percentage         -= percentageDecrease * Time.deltaTime;
                percentage          = Mathf.Abs(percentage);
                progressValue.value = percentage / 100f;
                break;

            case PuzzleType.Alternate:
                if (UNInput.GetButtonDown(controllerID, nextPress))
                {
                    nextPress   = nextPress != altButton[0] ? altButton[0] : altButton[1];
                    percentage += percentageIncrease;
                    if (percentage >= 100.0f)
                    {
                        Debug.Log("Completed");
                        isComplete = true;
                    }
                }
                percentage         -= percentageDecrease * Time.deltaTime;
                percentage          = Mathf.Abs(percentage);
                progressValue.value = percentage / 100f;
                break;

            case PuzzleType.Combination:
                if (resetTimer >= resetTime)
                {
                    ResetCombination();
                }
                foreach (ButtonCode button in allButtons)
                {
                    if (!UNInput.GetButtonDown(controllerID, button))
                    {
                        continue;
                    }

                    Debug.Log(button);
                    if (button != combButtons[combCount])
                    {
                        ResetCombination();
                        resetTimer = 0.0f;
                    }
                    else
                    {
                        combCount++;
                    }
                    transform.GetChild(2).GetChild(1).GetComponentInChildren <ButtonCodeWriter>().SetText(combCount);
                    if (combCount >= combButtons.Length)
                    {
                        Debug.Log("Completed");
                        isComplete = true;
                        break;
                    }
                }

                resetTimer += Time.deltaTime;
                break;
            }
        }
    }