Esempio n. 1
0
    void Update()
    {
        //Debug.Log(gamepad.GetStick_L().Y);
        if (((gamepad.GetStick_L().X) > 0.2f || (gamepad.GetStick_L().X) < -0.2f))
        {
            //&& rb.velocity.x<maxSpeed
            Move();
        }


        if (gamepad.GetButtonDown("A") && !dashOn)
        {
            dashOn = true;
            StartCoroutine(DashTimer());
        }
        if (gamepad.GetStick_L().Y != 0 && onTheWall)
        {
            moveDown();
        }
        if (gamepad.GetButton("X"))
        {
            Stop();
        }
        if (gamepad.GetButton("Start"))
        {
            Scene scene = SceneManager.GetActiveScene();
            SceneManager.LoadScene(scene.name);
        }
        if (gamepad.GetButtonDown("Y"))
        {
            colorChanger.GetComponent <Renderer>().material.SetColor("_Color", Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f));
        }
    }
Esempio n. 2
0
    void SelectCard()
    {
        if (gamepad.GetButtonDown(attack))
        {
            if (selectedCard != null)
            {
                selectedCard.Deselect();
            }

            if (selectedCard != null && selectedCard.cardNature == Cards.Attack)
            {
                selectedCard = null;
            }

            else
            {
                selectedCard = cardDico[Cards.Attack];
                selectedCard.Select();
            }
        }

        if (gamepad.GetButtonDown(shield))
        {
            if (selectedCard != null)
            {
                selectedCard.Deselect();
            }

            if (selectedCard != null && selectedCard.cardNature == Cards.Shield)
            {
                selectedCard = null;
            }

            else
            {
                selectedCard = cardDico[Cards.Shield];
                selectedCard.Select();
            }
        }

        if (gamepad.GetButtonDown(backstep))
        {
            if (selectedCard != null)
            {
                selectedCard.Deselect();
            }

            if (selectedCard != null && selectedCard.cardNature == Cards.Backstep)
            {
                selectedCard = null;
            }

            else
            {
                selectedCard = cardDico[Cards.Backstep];
                selectedCard.Select();
            }
        }
    }
Esempio n. 3
0
    private void Update()
    {
        if (!m_Gamepad.IsConnected || characterState == CharacterState.Death || m_ControllerLock)
        {
            return;
        }

        m_TargetDirection = transform.forward * m_Gamepad.GetStick_L().X *lookAtDirection + transform.up * m_Gamepad.GetStick_L().Y;

        if (m_Gamepad.GetButtonDown("A") && (m_Controller.isGrounded || m_JumpAirDelayed))
        {
            AkSoundEngine.PostEvent("P" + m_PlayerIndex + "_Jump", gameObject);
            m_YVelocity        = m_JumpInitialVelocity;
            m_HavePressA       = true;
            m_HaveBeenGrounded = false;
        }

        if (m_Gamepad.GetButtonDown("X"))
        {
            if (characterState == CharacterState.withEgg)
            {
                AkSoundEngine.PostEvent("P" + m_PlayerIndex + "_Throw", gameObject);
                m_Animator.SetTrigger("Toss");
                m_EggController.LaunchEgg((m_TargetDirection) * m_BaseThrowEgg);
                characterState = CharacterState.withoutEgg;
            }
        }

        if (m_Controller.isGrounded && m_YVelocity < 0)
        {
            m_YVelocity        = 0;
            m_HaveBeenGrounded = true;
        }

        if (!m_Controller.isGrounded && m_HaveBeenGrounded)
        {
            m_JumpAirDelayed   = true;
            m_HaveBeenGrounded = false;
        }

        //quick fix to resolve the first frame where the camera dont render the players
        if (m_Renderer.isVisible)
        {
            m_HaveBeenVisible = true;
        }
        Debug.Log(m_Renderer.isVisible);
        if (!m_Renderer.isVisible && m_HaveBeenVisible && !m_invulnaribility)
        {
            characterState = CharacterState.Death;
        }
    }
Esempio n. 4
0
    void Update()
    {
        if (gamepad.GetButtonDown("B"))
        {
            Debug.Log("oui");
        }

        if (gamepad.GetButtonDown("A"))
        {
            print("A");
        }

        //print (gamepad.GetStick_L ().X);
    }
Esempio n. 5
0
    void Update()
    {
        if (Input.GetKeyDown("escape"))
        {
            TogglePauseMenu();
            controlls.GetComponent <RectTransform>().anchoredPosition = offScreen;
        }

        if (gamepad1.IsConnected)
        {
            if (gamepad1.GetButtonDown("Start"))
            {
                TogglePauseMenu();
                controlls.GetComponent <RectTransform>().anchoredPosition = offScreen;
            }
        }

        if (gamepad2.IsConnected)
        {
            if (gamepad2.GetButtonDown("Start"))
            {
                TogglePauseMenu();
                controlls.GetComponent <RectTransform>().anchoredPosition = offScreen;
            }
        }
    }
Esempio n. 6
0
    void Update()
    {
        if (round == Rounds.Startup)
        {
            if (gamepad1.GetButtonDown("Start") || gamepad2.GetButtonDown("Start"))
            {
                round        = Rounds.Wait;
                roundCorWait = StartCoroutine(WaitCor());
            }
        }

        if (round == Rounds.Fight)
        {
            if (health1 == 0)
            {
                round = Rounds.End;
                StartCoroutine(EndGame(player2));
            }

            if (health2 == 0)
            {
                round = Rounds.End;
                StartCoroutine(EndGame(player1));
            }
        }

        ElevatorFeedback();
    }
Esempio n. 7
0
 // Update is called once per frame
 void Update()
 {
     if (gamepad.GetButtonDown("A"))
     {
         Debug.Log("oui");
     }
 }
Esempio n. 8
0
 // Update is called once per frame
 void Update()
 {
     if (gamepad.GetButtonDown("A"))
     {
         StopAllCoroutines();
         Debug.Log("oui" + papa);
         //Debug.Log(papa);
         StartCoroutine(inactif());
     }
 }
Esempio n. 9
0
 // Update is called once per frame
 void Update()
 {
     if (gamepad.GetButtonDown("DPad_Right"))
     {
         NextSlide();
     }
     if (gamepad.GetButtonDown("DPad_Left"))
     {
         PreviousSlide();
     }
     if (gamepad.GetButtonDown("DPad_Up"))
     {
         ShowSlide();
     }
     if (gamepad.GetButtonDown("DPad_Down"))
     {
         HideSlide();
     }
 }
Esempio n. 10
0
    // Update is called once per frame
    void Update()
    {
        // Obtain the desired gamepad from GamepadManager
        gamepad = GamepadManager.Instance.GetGamepad(1);

        // Sample code to test button input and rumble
        if (gamepad.GetButtonDown("A"))
        {
            TestRumble();
            Debug.Log("A down");
        }
    }
Esempio n. 11
0
    // Update is called once per frame
    void Update()
    {
        if (gamepad.GetButtonDown("A"))
        {
            StopAllCoroutines();
            Debug.Log("oui" + papa);
            //Debug.Log(papa);
        }

        if (gamepad.GetStick_L().X > .9f)
        {
            print("owi le stick!");
        }
    }
Esempio n. 12
0
    void Update()
    {
        if (gamepad.IsConnected)
        {
            // Moving in straight lines
            if (gamepad.GetButton("DPad_Up"))
            {
                Vector3 movement = new Vector3(0.0f, 0.0f, -1.0f);
                gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed;
                lastMove = movement;
            }
            else if (gamepad.GetButton("DPad_Down"))
            {
                Vector3 movement = new Vector3(0.0f, 0.0f, 1.0f);
                gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed;
                lastMove = movement;
            }
            else if (gamepad.GetButton("DPad_Left"))
            {
                Vector3 movement = new Vector3(1.0f, 0.0f, 0.0f);
                gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed;
                lastMove = movement;
            }
            else if (gamepad.GetButton("DPad_Right"))
            {
                Vector3 movement = new Vector3(-1.0f, 0.0f, 0.0f);
                gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed;
                lastMove = movement;
            }

            // Moving Diagonally
            if (gamepad.GetButton("DPad_Up") && gamepad.GetButton("DPad_Left"))
            {
                Vector3 movement = new Vector3(0.75f, 0.0f, -0.75f);
                gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed;
                lastMove = movement;
            }
            else if (gamepad.GetButton("DPad_Up") && gamepad.GetButton("DPad_Right"))
            {
                Vector3 movement = new Vector3(-0.75f, 0.0f, -0.75f);
                gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed;
                lastMove = movement;
            }
            else if (gamepad.GetButton("DPad_Down") && gamepad.GetButton("DPad_Left"))
            {
                Vector3 movement = new Vector3(0.75f, 0.0f, 0.75f);
                gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed;
                lastMove = movement;
            }
            else if (gamepad.GetButton("DPad_Down") && gamepad.GetButton("DPad_Right"))
            {
                Vector3 movement = new Vector3(-0.75f, 0.0f, 0.75f);
                gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed;
                lastMove = movement;
            }

            // Dodge Roll
            if (gamepad.GetButtonDown("A"))
            {
                if (dodgeTimer >= dodgeCool)
                {
                    dodgeTimer = 0;
                    //                timer            power         fade
                    gamepad.AddRumble(0.1f, new Vector2(0.1f, 0.1f), 0.1f);
                    gameObject.GetComponent <Rigidbody>().velocity = lastMove * moveSpeed * 3;
                }
            }

            // Player Attacks
            if (gamepad.GetButtonDown("X"))
            {
                if (attackTimer >= attackSpeed)
                {
                    Instantiate(attackGhost, (gameObject.GetComponent <Transform>().position + (lastMove * attackRange)), Quaternion.identity);
                    attackTimer = 0;
                }
            }

            /*************Cheats*************/
            /********************************/

            /*if (Input.GetKeyDown("8"))
             * {
             *  next Round
             * }*/
            if (Input.GetKeyDown("9"))
            {
                health = 9999;
            }
            if (Input.GetKeyDown("0"))
            {
                health = 0;
            }
            /*********************************/
            /*********************************/

            if (health >= 4)
            {
                h1.GetComponent <SpriteRenderer>().enabled = true;
                h2.GetComponent <SpriteRenderer>().enabled = true;
                h3.GetComponent <SpriteRenderer>().enabled = true;
                h4.GetComponent <SpriteRenderer>().enabled = true;
            }
            else if (health == 3)
            {
                h1.GetComponent <SpriteRenderer>().enabled = false;
                h2.GetComponent <SpriteRenderer>().enabled = true;
                h3.GetComponent <SpriteRenderer>().enabled = true;
                h4.GetComponent <SpriteRenderer>().enabled = true;
            }
            else if (health == 2)
            {
                h1.GetComponent <SpriteRenderer>().enabled = false;
                h2.GetComponent <SpriteRenderer>().enabled = false;
                h3.GetComponent <SpriteRenderer>().enabled = true;
                h4.GetComponent <SpriteRenderer>().enabled = true;
            }
            else if (health == 1)
            {
                h1.GetComponent <SpriteRenderer>().enabled = false;
                h2.GetComponent <SpriteRenderer>().enabled = false;
                h3.GetComponent <SpriteRenderer>().enabled = false;
                h4.GetComponent <SpriteRenderer>().enabled = true;
            }
            // Needs to be replaced by a downed mechanic
            else
            {
                // Destroys the player character if they lose all health
                Destroy(gameObject);
                h1.GetComponent <SpriteRenderer>().enabled   = false;
                h2.GetComponent <SpriteRenderer>().enabled   = false;
                h3.GetComponent <SpriteRenderer>().enabled   = false;
                h4.GetComponent <SpriteRenderer>().enabled   = false;
                loseText.GetComponent <Transform>().position = new Vector3(0f, -2.45983f, 12.14942f);
            }

            // Update Timers
            dodgeTimer++;
            attackTimer++;
        }
    }
Esempio n. 13
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(numberOfPlayer);
        nombreDeGamepad = manager.ConnectedTotal();


        if (nombreDeGamepad >= 1)
        {
            if (gamepad1.GetButtonDown("A") && player1
                == false)
            {
                player1         = true;
                numberOfPlayer += 1;
                CreatePlayer(numberOfPlayer, playerObject);
                //numberOfPlayer = 1;
            }
            if (nombreDeGamepad >= 2)
            {
                if (gamepad2.GetButtonDown("A") && player2 == false)
                {
                    player2         = true;
                    numberOfPlayer += 1;
                    CreatePlayer(numberOfPlayer, playerObject);
                }
            }
            if (nombreDeGamepad >= 3)
            {
                if (gamepad3.GetButtonDown("A") && player3 == false)
                {
                    player3         = true;
                    numberOfPlayer += 1;
                    CreatePlayer(numberOfPlayer, playerObject);
                }
            }
            if (nombreDeGamepad >= 4)
            {
                if (gamepad4.GetButtonDown("A") && player4 == false)
                {
                    player4         = true;
                    numberOfPlayer += 1;
                    CreatePlayer(numberOfPlayer, playerObject);
                }
            }
        }

        /*
         *      if(gamepad1.GetButtonDown("A")&& !player1)
         * {
         *  //Debug.Log("1");
         *  player1 = true;
         *  CreatePlayer(1,playerObject);
         * }
         *
         * if (gamepad2.GetButtonDown("A") && !player2)
         * {
         *  //Debug.Log("2");
         *  player2 = true;
         *  CreatePlayer(2,playerObject);
         * }
         */
    }
Esempio n. 14
0
    void CheckInputs()
    {
        x = gamepad.GetStick_L().X;
        y = gamepad.GetStick_L().Y;

        movement = new Vector3(x, 0, y);



        if (gamepad.GetButtonDown("A"))
        {
            Hide();

            rb.velocity = Vector3.zero;
        }



        if (hiding)
        {
            return;
        }

        if (x != 0 || y != 0)
        {
            if (anim.GetBool("Walk") == false)
            {
                anim.SetBool("Walk", true);
            }

            if (dust.isStopped)
            {
                dust.Play();
            }

            Rotate();
        }
        else
        {
            if (anim.GetBool("Walk"))
            {
                anim.SetBool("Walk", false);
            }
            if (dust.isPlaying)
            {
                dust.Stop();
            }

            /*
             * if(rb.velocity.magnitude>.5f)
             * {
             *  rb.velocity /= 2;
             * }
             */
        }

        Move();

        if (gamepad.GetButtonDown("X") && !attacking)
        {
            Attack();
        }
    }
Esempio n. 15
0
    void Update()
    {
        // For the start: enabling day light and disabling night light for the crane bird
        if (lightManager.startingInDayLight == true)
        {
            lightManager.EnableNightLights();
            lightManager.startingInDayLight = false;
        }

        // Pressing LB or RB switches the lens on the list and triggers the LensSwitcher function
        if (gamepad.GetButtonDown("LB"))
        {
            if (lensCounter <= 0)
            {
                lensCounter = lensesList.Count - 1;
            }
            else
            {
                lensCounter = lensCounter - 1;
            }

            currentLens = lensesList[lensCounter];

            LensSwitcher(currentLens);
        }

        else if (gamepad.GetButtonDown("RB"))
        {
            if (lensCounter >= lensesList.Count - 1)
            {
                lensCounter = 0;
            }
            else
            {
                lensCounter = lensCounter + 1;
            }

            currentLens = lensesList[lensCounter];

            LensSwitcher(currentLens);
        }

        // Special transition made when coming back to normal
        if (noLensTransition == true)
        {
            noLensTransitionTimer += Time.deltaTime;
            if (noLensTransitionTimer >= 0.2)
            {
                bawShader.enabled   = false;
                postProcess.profile = noLenseProfile;

                cineCamera.m_Lens.FarClipPlane = noLenseDepthOfView;
                Camera.main.GetComponent <Skybox>().material   = daySkybox;
                Camera.main.GetComponent <Camera>().clearFlags = CameraClearFlags.Skybox;

                noLensTransition      = false;
                noLensTransitionTimer = 0;

                // Enables Day Light and disables Night Light in case the player is a crane and comes back from the night lense
                if (isCrane == true)
                {
                    lightManager.DisableNightLights();
                }
            }
        }

        // White transition for the night, maybe I can find a better idea...
        if (nightTransition == true)
        {
            nightTransitionTimer += Time.deltaTime;
            if (nightTransitionTimer >= 0.2)
            {
                bawShader.enabled              = false;
                postProcess.profile            = nightProfile;
                cineCamera.m_Lens.FarClipPlane = noLenseDepthOfView;

                Camera.main.GetComponent <Skybox>().material   = nightSkybox;
                Camera.main.GetComponent <Camera>().clearFlags = CameraClearFlags.Skybox;

                lightManager.EnableNightLights();

                nightTransition      = false;
                nightTransitionTimer = 0;

                lightManager.EnableNightLights();
            }
        }
    }