Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        //checks if currently paused
        if (isPaused)
        {
            //old

            ////takes all the pressed buttons
            //List<ButtonPress> presses = buttonListen.getPressed ();

            ////verifies that there is something
            //if (presses == null)
            //	return;

            ////takes all of the types
            //List<ButtonType> buttons = new List<ButtonType> ();

            //foreach (ButtonPress press in presses)
            //	buttons.Add (press.type);

            //checks if resume is pressed
            if (buttonListen.isPressed(ButtonType.PAUSE_RESUME))
            {
                resume();
            }

            //check if quit was pressed
            if (buttonListen.isPressed(ButtonType.PAUSE_QUIT))
            {
                quit();
            }
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (isShowing)
        {
            //old code

            ////gets pressed
            //List<ButtonPress> buttons = buttonListen.getPressed();

            //if (buttons == null)
            //	return;

            ////converts to types
            //List<ButtonType> types = new List<ButtonType>();
            //foreach (ButtonPress button in buttons)
            //	types.Add(button.type);

            ////checks if retry pressed
            //if (types.Contains(ButtonType.PAUSE_RESUME))
            //{
            //	SceneManager.LoadScene(SceneManager.GetActiveScene().name, LoadSceneMode.Single);
            //}

            ////checks if menu pressed
            //if (types.Contains(ButtonType.PAUSE_QUIT))
            //{
            //	SceneManager.LoadScene("MainMenu", LoadSceneMode.Single);
            //}

            if (buttonListen.isPressed(ButtonType.PAUSE_RESUME))
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().name, LoadSceneMode.Single);
            }

            if (buttonListen.isPressed(ButtonType.PAUSE_QUIT))
            {
                SceneManager.LoadScene("MainMenu", LoadSceneMode.Single);
            }
        }
    }
    //updates before physics updates
    void FixedUpdate()
    {
        //tests of time to next attack is being used
        if (!(timeToNextAttack <= 0))
        {
            timeToNextAttack -= Time.deltaTime;
            //tests if enough time went by
            if (timeToNextAttack <= 0)
            {
                canMove = true;
            }
        }

        //defualt slow is off
        isSlowed = false;

        //tests if should be slowed
        if (timeSlowedLeft > 0)
        {
            timeSlowedLeft -= Time.deltaTime;
            if (timeSlowedLeft <= 0)
            {
                isSlowed = false;
            }
            else
            {
                isSlowed = true;
            }
        }

        //variables for speed in each direction
        float vertical   = 0.0f;
        float horizontal = 0.0f;

        //tests if player is allowed to move
        if (canMove)
        {
            //checks if paused pressed
            if (buttonListen.isPressed(ButtonType.PAUSE))
            {
                //pauses game and stops player
                PauseMenuControl.pause();
                return;
            }

            //gets the angle of how the stick was moved
            horizontal = Stick.Horizontal();
            vertical   = Stick.Vertical();

            //checks attack buttons
            if (buttonListen.isPressed(ButtonType.ATTACK_LIGHT) && timeToNextAttack <= 0)
            {
                attack(lightAttack, lightAttackDamage, false);
                animator.SetTrigger("lightattack");
                timeToNextAttack = 1;
                ASound.playAttackSound();
            }

            if (buttonListen.isPressed(ButtonType.ATTACK_HEAVY) && timeToNextAttack <= 0)
            {
                attack(heavyAttack, heavyAttackDamage, true);
                animator.SetTrigger("heavyattack");
                timeToNextAttack = 2;
                canMove          = false;
                ASound.playAttackSound();
            }

            //Ammo selector checks
            if (buttonListen.isPressed(ButtonType.AMMO_PRIMARY))
            {
                setActiveAmmoPrimary(true);
            }

            if (buttonListen.isPressed(ButtonType.AMMO_SECONDARY))
            {
                setActiveAmmoPrimary(false);
            }
        }


        //checks ranged stick
        //if player is aiming
        if (isAiming())
        {
            //slows player movement
            isSlowed = true;

            //calculates trajectory
            calculateTrajectoryStart(out powerPrev, out isLeftPrev, out slopePrev);

            //draws trajectory line
            lineRender.gameObject.SetActive(true);
            shootCon.drawTrajectory(transform.position, powerPrev, slopePrev, isLeftPrev, lineRender);
        }
        //if player has attempted to shoot
        if (shouldShoot())
        {
            //shoots in trajectory using previous settings
            lineRender.gameObject.SetActive(false);

            //checks if ammo is left
            if (getActiveSelect().canConsume(1))
            {
                //shoots
                shootCon.shoot(transform.position, powerPrev, slopePrev, isLeftPrev, gameObject);
                //updates counter
                getActiveSelect().consume(1);
            }
        }

        //set variable for speed(in each direction) needed to move
        moveDirection = new Vector2(horizontal, vertical);

        //if slowed reduces the speed
        if (isSlowed)
        {
            moveDirection -= (moveDirection * slowPerCent);
        }

        //sets the animation speed variable
        moveDirection *= speed;

        //gets total speed in float
        float speedmove = horizontal + vertical;

        //changes direction sprite is facing

        //checks for facing right and changes to move left (negative value(speed) is facing left)
        if (transform.localScale.x > 0)
        {
            if (speedmove < 0)
            {
                //sets facing direction to the left
                Vector3 scale = gameObject.transform.localScale;
                scale.Set(gameObject.transform.localScale.x * -1, gameObject.transform.localScale.y, gameObject.transform.localScale.z);
                gameObject.transform.localScale = scale;
            }
            //checks for facing left and changes to move right
        }
        else if (transform.localScale.x < 0)
        {
            if (speedmove > 0)
            {
                //sets facing direction to the right
                Vector3 scale = gameObject.transform.localScale;
                scale.Set(gameObject.transform.localScale.x * -1, gameObject.transform.localScale.y, gameObject.transform.localScale.z);
                gameObject.transform.localScale = scale;
            }
        }

        //gets absolute value of speedmove
        speedmove = Mathf.Abs(speedmove);

        //sets animator speed parameter
        animator.SetFloat("speed", speedmove);

        //sets velocity for movement
        controller.velocity = moveDirection;
    }
    // Update is called once per frame
    void Update()
    {
        //old stuff
        //List<ButtonPress> rawButtonObjects = buttonListen.getPressed ();

        //if (rawButtonObjects == null)
        //	return;

        //List<ButtonType> buttonObjects = new List<ButtonType> ();

        //foreach (ButtonPress press in rawButtonObjects)
        //	buttonObjects.Add (press.type);


        //ButtonType button = buttonObjects[0].GetComponent<ButtonPress> ().type;

        //tests if the mainMenu is active
        if (mainMenuActive)
        {
            //menu Menu

            //tests if the startbutton is pressed
            if (/*button == ButtonType.ARROW_UP*/ buttonListen.isPressed(ButtonType.ARROW_UP))
            {
                //sets the bool for the levels
                mainMenuActive    = false;
                levelSelectActive = true;

                //sets the gameobject
                mainMenu.SetActive(false);
                levelSelect.SetActive(true);

                //disables own buttons
                buttonListen.UserUiObjects[0].GetComponent <ButtonPress> ().isActive = false;
                buttonListen.UserUiObjects[5].GetComponent <ButtonPress> ().isActive = false;

                //enables next buttons
                buttonListen.UserUiObjects[1].GetComponent <ButtonPress> ().isActive = true;
                buttonListen.UserUiObjects[2].GetComponent <ButtonPress> ().isActive = true;
                buttonListen.UserUiObjects[3].GetComponent <ButtonPress> ().isActive = true;
                buttonListen.UserUiObjects[4].GetComponent <ButtonPress> ().isActive = true;

                ////temp////
                buttonListen.UserUiObjects[7].GetComponent <ButtonPress> ().isActive = true;
                buttonListen.UserUiObjects[8].GetComponent <ButtonPress>().isActive  = true;
                ////////////

                return;
            }

            //tests if the credits button is pressed
            if (buttonListen.isPressed(ButtonType.ATTACK_LIGHT))
            {
                //sets the bool for the levels
                mainMenuActive   = false;
                CreditMenuActive = true;

                //sets the gameobject
                mainMenu.SetActive(false);
                CreditMenu.SetActive(true);

                //disables own buttons
                buttonListen.UserUiObjects[0].GetComponent <ButtonPress> ().isActive = false;
                buttonListen.UserUiObjects[5].GetComponent <ButtonPress> ().isActive = false;

                //enables next buttons
                buttonListen.UserUiObjects[6].GetComponent <ButtonPress> ().isActive = true;

                return;
            }
        }
        else if (levelSelectActive)
        {
            //levelSelect

            //tests if the Level1 is pressed
            if (buttonListen.isPressed(ButtonType.ARROW_DOWN))
            {
                //Advertisement.Show("video");
                //loads scene
                //SceneManager.LoadScene ("INSERT SCENE HERE", LoadSceneMode.Single);
                return;
            }

            //tests if the Level2 is pressed
            if (buttonListen.isPressed(ButtonType.ARROW_LEFT))
            {
                //Advertisement.Show("video");
                //loads scene
                //SceneManager.LoadScene ("INSERT SCENE HERE", LoadSceneMode.Single);
                return;
            }

            //tests if the Level3 is pressed
            if (buttonListen.isPressed(ButtonType.ARROW_RIGHT))
            {
                //Advertisement.Show("video");
                //loads scene
                //SceneManager.LoadScene ("INSERT SCENE HERE", LoadSceneMode.Single);
                return;
            }

            //tests if the tutorial is pressed
            if (buttonListen.isPressed(ButtonType.ARROW_UP))
            {
                Advertisement.Show("video");
                //loads scene
                SceneManager.LoadScene("Tutorial", LoadSceneMode.Single);
                return;
            }

            //////////////temp//////////////////
            /// //tests if the beta is pressed
            if (buttonListen.isPressed(ButtonType.DEATH))
            {
                Advertisement.Show("video");
                //loads scene
                SceneManager.LoadScene("BetaLevel", LoadSceneMode.Single);
                return;
            }
            ////////////////////////////////////
        }
        else if (CreditMenuActive)
        {
            //credits
            //tests if the back button is pressed
            if (buttonListen.isPressed(ButtonType.PAUSE_RESUME))
            {
                //sets the bool for the levels
                CreditMenuActive = false;
                mainMenuActive   = true;

                //sets the gameobject
                CreditMenu.SetActive(false);
                mainMenu.SetActive(true);

                //disables own buttons
                buttonListen.UserUiObjects[6].GetComponent <ButtonPress> ().isActive = false;

                //enables next buttons
                buttonListen.UserUiObjects[0].GetComponent <ButtonPress> ().isActive = true;
                buttonListen.UserUiObjects[5].GetComponent <ButtonPress> ().isActive = true;

                return;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (isDead)
        {
            //old code

            ////gets pressed
            //List<ButtonPress> buttons = buttonListen.getPressed();

            //if (buttons == null)
            //    return;

            ////converts to types
            //List<ButtonType> types = new List<ButtonType>();
            //foreach (ButtonPress button in buttons)
            //    types.Add(button.type);

            ////checks fail menu
            //if (types.Contains(ButtonType.ATTACK_LIGHT)) {
            //    closeFailMenu();
            //    return;
            //}

            ////checks restart
            //if (types.Contains(ButtonType.PAUSE_RESUME)) {
            //    restart();
            //    return;
            //}

            ////checks quit
            //if (types.Contains(ButtonType.PAUSE_QUIT)) {
            //    quitToMain();
            //    return;
            //}

            ////checks revive
            //if (types.Contains(ButtonType.DEATH)) {
            //    reviveAd();
            //    return;
            //}



            //checks fail menu
            if (buttonListen.isPressed(ButtonType.ATTACK_LIGHT))
            {
                closeFailMenu();
                return;
            }

            //checks restart
            if (buttonListen.isPressed(ButtonType.PAUSE_RESUME))
            {
                restart();
                return;
            }

            //checks quit
            if (buttonListen.isPressed(ButtonType.PAUSE_QUIT))
            {
                quitToMain();
                return;
            }

            //checks revive
            if (buttonListen.isPressed(ButtonType.DEATH))
            {
                reviveAd();
                return;
            }
        }
    }