void Update()
    {
        if (XCI.GetButtonDown(XboxButton.DPadUp, XboxController.First) ||
            XCI.GetButtonDown(XboxButton.DPadUp, XboxController.Second) ||
            XCI.GetButtonDown(XboxButton.DPadUp, XboxController.Fourth) ||
            XCI.GetButtonDown(XboxButton.DPadUp, XboxController.Third))
        {
            selectID--;
        }

        if (XCI.GetButtonDown(XboxButton.DPadDown, XboxController.First) ||
            XCI.GetButtonDown(XboxButton.DPadDown, XboxController.Second) ||
            XCI.GetButtonDown(XboxButton.DPadDown, XboxController.Fourth) ||
            XCI.GetButtonDown(XboxButton.DPadDown, XboxController.Third))
        {
            selectID++;
        }

        if (selectID < 0)
        {
            selectID = 2;
        }

        if (selectID > 2)
        {
            selectID = 0;
        }

        switch (selectID)
        {
        case 0:
            ContinueImage.sprite = ContinueSprite_Gray;
            RestartImage.sprite  = RestartSprite;
            ExitImage.sprite     = ExitSprite;

            if (XCI.GetButtonDown(XboxButton.A, XboxController.All))
            {
                Continue();
            }

            break;

        case 1:
            ContinueImage.sprite = ContinueSprite;
            RestartImage.sprite  = RestartSprite_Gray;
            ExitImage.sprite     = ExitSprite;

            if (XCI.GetButtonDown(XboxButton.A, XboxController.All))
            {
                Restart();
            }

            break;

        case 2:
            ContinueImage.sprite = ContinueSprite;
            RestartImage.sprite  = RestartSprite;
            ExitImage.sprite     = ExitSprite_Gray;

            if (XCI.GetButtonDown(XboxButton.A, XboxController.All))
            {
                Exit();
            }

            break;
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        MoneyText.text = "$" + Mathf.RoundToInt(PlayerBank.instance.TeamMoney);
        //deal with prices
        bool fuelUpsAvailable = true;

        if (FollowScript.playersUpgrades.CurrentFuel == UpgradesData.instance.FuelUpgrades.Count - 1)
        {
            Fuel.text        = "No more upgrades";
            fuelUpsAvailable = false;
        }
        else
        {
            Fuel.text = "$" + UpgradesData.instance.PriceTable[FollowScript.playersUpgrades.CurrentFuel + 1];
        }

        bool healthUpsAvailable = true;

        if (FollowScript.playersUpgrades.CurrentHealth == UpgradesData.instance.HealthUpgrades.Count - 1)
        {
            Health.text        = "No more upgrades";
            healthUpsAvailable = false;
        }
        else
        {
            Health.text = "$" + UpgradesData.instance.PriceTable[FollowScript.playersUpgrades.CurrentHealth + 1];
        }

        bool cargoUpsAvailable = true;

        if (FollowScript.playersUpgrades.CurrentCargo == UpgradesData.instance.CargoUpgrades.Count - 1)
        {
            Cargo.text        = "No more upgrades";
            cargoUpsAvailable = false;
        }
        else
        {
            Cargo.text = "$" + UpgradesData.instance.PriceTable[FollowScript.playersUpgrades.CurrentCargo + 1];
        }

        bool drillUpsAvailable = true;

        if (FollowScript.playersUpgrades.CurrentDrill == UpgradesData.instance.DrillUpgrades.Count - 1)
        {
            Drill.text        = "No more upgrades";
            drillUpsAvailable = false;
        }
        else
        {
            Drill.text = "$" + UpgradesData.instance.PriceTable[FollowScript.playersUpgrades.CurrentDrill + 1];
        }

        bool jetUpsAvailable = true;

        if (FollowScript.playersUpgrades.CurrentJumpJet == UpgradesData.instance.JumpjetUpgrades.Count - 1)
        {
            Jets.text       = "No more upgrades";
            jetUpsAvailable = false;
        }
        else
        {
            Jets.text = "$" + UpgradesData.instance.PriceTable[FollowScript.playersUpgrades.CurrentJumpJet + 1];
        }

        //handle inputs

        if ((XCI.GetButtonDown(XboxButton.A, FollowScript.playersId.controller) ||
             (FollowScript.playersId.GetControllerInt() == 4) && Input.GetButtonDown("Fire1")) && fuelUpsAvailable)
        {
            float bank = PlayerBank.instance.TeamMoney;
            BoostFuel(bank);
        }
        if ((XCI.GetButtonDown(XboxButton.B, FollowScript.playersId.controller) ||
             (FollowScript.playersId.GetControllerInt() == 4) && Input.GetButtonDown("Fire3")) && healthUpsAvailable)
        {
            float bank = PlayerBank.instance.TeamMoney;
            BoostHealth(bank);
        }
        if ((XCI.GetButtonDown(XboxButton.X, FollowScript.playersId.controller) ||
             (FollowScript.playersId.GetControllerInt() == 4) && Input.GetButtonDown("Fire2")) && cargoUpsAvailable)
        {
            float bank = PlayerBank.instance.TeamMoney;
            BoostCargo(bank);
        }
        if ((XCI.GetButtonDown(XboxButton.Y, FollowScript.playersId.controller) ||
             (FollowScript.playersId.GetControllerInt() == 4) && Input.GetButtonDown("Fire4")) && drillUpsAvailable)
        {
            float bank = PlayerBank.instance.TeamMoney;
            BoostDrill(bank);
        }
        if ((XCI.GetButtonDown(XboxButton.RightBumper, FollowScript.playersId.controller) ||
             (FollowScript.playersId.GetControllerInt() == 4) && Input.GetButtonDown("Fire5")) && jetUpsAvailable)
        {
            float bank = PlayerBank.instance.TeamMoney;
            BoostJet(bank);
        }
    }
    void Update()
    {
        MenuSelector temp;
        int          nextSlot = -1;

        for (int i = 0; i < playerSelections.Length; i++)
        {
            temp = selectors[i].GetComponent("MenuSelector") as MenuSelector;
            if (!selectorCoolDowns[i])
            {
                if (XCI.GetButtonDown(XboxButton.A, i + 1))
                {
                    if (!temp.SelectionConfirmed)
                    {
                        temp.SelectionConfirmed = true;
                    }
                }
                if (XCI.GetButtonDown(XboxButton.B, i + 1))
                {
                    if (temp.SelectionConfirmed)
                    {
                        temp.SelectionConfirmed = false;
                    }
                }

                if (XCI.GetAxis(XboxAxis.LeftStickX, i + 1) > 0.5)
                {
                    nextSlot = playerSelections[i];
                    do
                    {
                        nextSlot++;
                        if (nextSlot >= tankMenuObjects.Count)
                        {
                            nextSlot = 0;
                        }
                        else if (nextSlot < 0)
                        {
                            nextSlot = tankMenuObjects.Count - 1;
                        }
                    } while (isOccupied(nextSlot));

                    if (!temp.SelectionConfirmed)
                    {
                        playerSelections[i] = nextSlot;
                    }

                    selectors[i].transform.position = tankMenuObjects[playerSelections[i]].Position;

                    selectorCoolDowns[i] = true;
                    StartCoroutine(SelectionWait(i));
                }
                else if (XCI.GetAxis(XboxAxis.LeftStickX, i + 1) < -0.5)
                {
                    nextSlot = playerSelections[i];
                    do
                    {
                        nextSlot--;
                        if (nextSlot >= tankMenuObjects.Count)
                        {
                            nextSlot = 0;
                        }
                        else if (nextSlot < 0)
                        {
                            nextSlot = tankMenuObjects.Count - 1;
                        }
                    } while (isOccupied(nextSlot));

                    if (!temp.SelectionConfirmed)
                    {
                        playerSelections[i] = nextSlot;
                    }

                    selectors[i].transform.position = tankMenuObjects[playerSelections[i]].Position;

                    selectorCoolDowns[i] = true;
                    StartCoroutine(SelectionWait(i));
                }
            }
        }

        int confirmedCount = 0;

        for (int i = 0; i < playerSelections.Length; i++)
        {
            temp = selectors[i].GetComponent("MenuSelector") as MenuSelector;
            if (temp.SelectionConfirmed)
            {
                confirmedCount++;
            }
        }

        if (confirmedCount >= XCI.GetNumPluggedCtrlrs())
        {
            Debug.Log("Ready to Play");
        }
    }
    void Update()
    {
        if (bIsOnMenu)
        {
            return;
        }

        if (!finished)
        {
            if ((Input.GetKeyDown(KeyCode.Space) || XCI.GetButtonDown(XboxButton.A)) && allowedToJump)
            {
                hovering      = true;
                isGrounded    = false;
                allowedToJump = false;
            }
            if (magnatise)
            {
                //If both directions are being pressed
                if ((Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) && (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) && XCI.GetAxisRaw(XboxAxis.LeftStickX, controller) == 0.0f)
                {
                    movingLeft  = false;
                    movingRight = false;
                }
                else
                {
                    //Left Movement
                    if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
                    {
                        movingLeft = true;
                    }
                    else
                    {
                        movingLeft = false;
                    }
                    //Right Movement
                    if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
                    {
                        movingRight = true;
                    }
                    else
                    {
                        movingRight = false;
                    }
                }


                if (XCI.GetAxisRaw(XboxAxis.LeftStickX, controller) < 0.0f)
                {
                    movingLeft  = true;
                    movingRight = false;
                }
                if (XCI.GetAxisRaw(XboxAxis.LeftStickX, controller) > 0.0f)
                {
                    movingRight = true;
                    movingLeft  = false;
                }
            }
            else if (!magnatise)
            {
                if (!XCI.IsPluggedIn(1))
                {
                    if (transform.position.x == leftLanePos.x)
                    {
                        if (movingLeft)
                        {
                            movingLeft = false;
                        }
                        inLeftLane  = true;
                        inMidLane   = false;
                        inRightLane = false;
                    }
                    if (transform.position.x == rightLanePos.x)
                    {
                        if (movingRight)
                        {
                            movingRight = false;
                        }
                        inLeftLane  = false;
                        inMidLane   = false;
                        inRightLane = true;
                    }
                    if (transform.position.x == centreLanePos.x)
                    {
                        inLeftLane  = false;
                        inMidLane   = true;
                        inRightLane = false;
                    }
                }
                else
                {
                    if ((Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) && (!inLeftLane || !inMidLane))
                    {
                        movingLeft = true;
                    }
                    if ((Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) && (!inMidLane || !inRightLane))
                    {
                        movingRight = true;
                    }
                    if (XCI.GetAxisRaw(XboxAxis.LeftStickX, controller) < 0.0f)
                    {
                        movingLeft  = true;
                        movingRight = false;
                    }
                    if (XCI.GetAxisRaw(XboxAxis.LeftStickX, controller) > 0.0f)
                    {
                        movingRight = true;
                        movingLeft  = false;
                    }
                    if (XCI.GetAxisRaw(XboxAxis.LeftStickX, controller) == 0.0f)
                    {
                        movingLeft  = false;
                        movingRight = false;
                    }
                }
            }
        }
        else
        {
            movingLeft  = false;
            movingRight = false;
        }
    }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        //if (playerJoined && !Globals.Instance.GameManager.joinedPlayers.Contains(playerNum))
        //{
        //    Leave();
        //}
        if (state == PlayerSelectorState.NameEntry)
        {
            float horizontal = XCI.GetAxisRaw(XboxAxis.LeftStickX, controller);
            float vertical   = XCI.GetAxisRaw(XboxAxis.LeftStickY, controller);

            bool usingStick = false;

            if (Mathf.Abs(horizontal) > 0.8f)
            {
                usingStick = true;
                if (canMoveCursor)
                {
                    nameEntry.MoveCursor(horizontal > 0);
                    canMoveCursor = false;
                    if (moveCursorSound != null)
                    {
                        moveCursorSound.PlayEffect();
                    }
                }
            }
            else
            {
                canMoveCursor = true; //reset moving the cursor each time the user stops pushing a direction
            }

            if (Mathf.Abs(vertical) > 0.3)
            {
                usingStick         = true;
                letterChangeValue += (vertical * Time.deltaTime * nameEntrySensitivity);

                if (vertical > 0 && letterChangeValue > letterChangeThreshold)
                {
                    //move up one letter
                    nameEntry.ChangeLetter(true);
                    letterChangeValue = 0.0f;
                    if (changeLetterNextSound != null)
                    {
                        changeLetterNextSound.PlayEffect();
                    }
                }
                else if (vertical < 0 && letterChangeValue < (letterChangeThreshold * -1))
                {
                    //move down one letter
                    nameEntry.ChangeLetter(false);
                    letterChangeValue = 0.0f;
                    if (changeLetterPrevSound != null)
                    {
                        changeLetterPrevSound.PlayEffect();
                    }
                }
            }
            else
            {
                //letterChangeValue = 0.0f;
            }

            if (!usingStick)
            {
                if (XCI.GetButtonDown(XboxButton.DPadRight, controller))
                {
                    nameEntry.MoveCursor(true);
                    if (moveCursorSound != null)
                    {
                        moveCursorSound.PlayEffect();
                    }
                }
                else if (XCI.GetButtonDown(XboxButton.DPadLeft, controller))
                {
                    nameEntry.MoveCursor(false);
                    if (moveCursorSound != null)
                    {
                        moveCursorSound.PlayEffect();
                    }
                }

                if (XCI.GetButtonDown(XboxButton.DPadUp, controller))
                {
                    nameEntry.ChangeLetter(true);
                    if (changeLetterNextSound != null)
                    {
                        changeLetterNextSound.PlayEffect();
                    }
                }
                else if (XCI.GetButtonDown(XboxButton.DPadDown, controller))
                {
                    nameEntry.ChangeLetter(false);
                    if (changeLetterPrevSound != null)
                    {
                        changeLetterPrevSound.PlayEffect();
                    }
                }
            }

            if (XCI.GetButtonDown(XboxButton.Y, controller))
            {
                nameEntry.SetRandomName();
                if (randomNameSound != null)
                {
                    randomNameSound.PlayEffect();
                }
            }
        }

        if (XCI.GetButtonDown(XboxButton.A, controller))
        {
            Confirm();
        }

        if (XCI.GetButtonDown(XboxButton.B, controller))
        {
            Cancel();
        }

        if (XCI.GetButtonDown(XboxButton.Start, controller))
        {
            if (state == PlayerSelectorState.Joined && Globals.Instance.GameManager.isRoundReady)
            {
                //start game!
                Globals.Instance.GameManager.StartRound();
            }
        }
    }
Example #6
0
    void Reload()
    {
        if (_gunInventory[_currentlySelectedWeapon].gunObject && !_grenadeSelected && _currentlySelectedWeapon != 2)
        {
            if (_currentWeaponInterface.returnCurrentMagazineValue() == 0)
            {
                RemoveCritBoost();
            }


            bool fullMagazine = _currentWeaponInterface.returnCurrentMagazineValue() == _currentWeaponInterface.ReturnClipSize();
            if (XCI.GetButtonDown(XboxButton.X, _inputScript.controller) && !fullMagazine && _gunInventory[_currentlySelectedWeapon].currentAmmo > 0)
            {
                GetComponent <SCR_PlayerWorldSpaceUI>().ShowReloadPrompt(true);
                if (!_isReloading)
                {
                    if (bCritActive)
                    {
                        RemoveCritBoost();
                    }
                    critGauge    = null;
                    _isReloading = true;
                    _currentWeaponInterface.GunReload(true);
                    normalGauge = uiManagerScript.DecreaseSteamGauge(gameObject.tag, this, reloadMultiplier, playerWorldSpaceUIScr);
                    _currentWeaponInterface.PlayReloadSound();
                    StartCoroutine(normalGauge);

                    if (!bHasReloaded && bTutorialCanReload)
                    {
                        GameObject tutorialManager = GameObject.FindGameObjectWithTag("TutorialManager");
                        if (tutorialManager)
                        {
                            SCR_TutorialManager tutorialManagerScr = tutorialManager.GetComponent <SCR_TutorialManager>();
                            tutorialManagerScr.SetHasReloaded();
                        }
                        bHasReloaded = true;
                    }

                    playerWorldSpaceUIScr.HideReloadButtonPrompt();
                }
                else if (_isReloading && !_CritAttempted)
                {
                    if (normalGauge != null)
                    {
                        StopCoroutine(normalGauge);
                        normalGauge = null;
                    }

                    critGauge = uiManagerScript.rotateGaugePinFull(0.0f, this, gameObject.tag, false);
                    StartCoroutine(critGauge);


                    playerWorldSpaceUIScr.ShowReloadPrompt(false);
                    //Original system
                    //float clipPercentage = uiManagerScript.ReturnPercentage(gameObject.tag);
                    //float ammoGaugePercentage = RefillClip(clipPercentage);


                    //EGX SYSTEM
                    float ammoGaugePercentage = RefillClip(100);


                    _CritAttempted = true;
                    uiManagerScript.SetCurrentAmmoText(gameObject.tag, ammoGaugePercentage * _currentWeaponInterface.ReturnClipSize(), _gunInventory[_currentlySelectedWeapon].currentAmmo, _currentWeaponInterface.ReturnClipSize());

                    if (uiManagerScript.WithinCritZone())
                    {
                        CriticalDamageBonus();
                        SCR_AudioManager.instance.Play("DingReload");
                    }
                }
            }
        }
    }
Example #7
0
    /*
     * Brief: manage the jump of the player
     */
    void Update()
    {
        // if the player is alive
        if (m_cameraMovement.m_playerAlive)
        {
            if (m_rb2d.drag > m_groundDrag)
            {
                m_recoveryTimer += Time.deltaTime;
                m_rb2d.drag      = Mathf.Lerp(m_landDrag, m_groundDrag, m_recoveryTimer / m_recoveryTime);
            }

            // If the jump button goes down and the player is not in the air, jump
            if ((Input.GetButtonDown("Jump") || XCI.GetButtonDown(XboxButton.A)) && m_jumpTimer == 0.0f && !m_inAir)
            {
                m_rb2d.AddForce(m_jumpForcev2, ForceMode2D.Impulse);
                m_jumpTimer += Time.deltaTime;
            }
            // If the jump key or button is let go, stop jumping
            else if (Input.GetButtonUp("Jump") || XCI.GetButtonUp(XboxButton.A))
            {
                //Checks if the player is in the air
                if (m_inAir)
                {
                    m_jumpTimer = m_maxJumpTime;
                }
                //Checks if the player is no longer in the air
                else
                {
                    m_jumpTimer = 0.0f;
                }
            }
            //If jump key or button is held maintain velocity and increase timer
            else if ((Input.GetButton("Jump") || XCI.GetButton(XboxButton.A)) && m_jumpTimer < m_maxJumpTime)
            {
                //Checks if player is in the air
                if (m_inAir)
                {
                    m_rb2d.velocity.Set(m_rb2d.velocity.x, m_jumpVelocity);
                }
                m_jumpTimer += Time.deltaTime;
            }

            //Store previous jump velocity
            m_jumpVelocity = m_rb2d.velocity.y;

            if (gameObject.transform.rotation.eulerAngles.y > 90.0f)
            {
                m_rayPosition.x = (m_playerDimensions.x / 2) - m_rayOffset;
            }
            else
            {
                m_rayPosition.x = -(m_playerDimensions.x / 2) + m_rayOffset;
            }

            // draw a raycast below the player
            m_rayH2D = Physics2D.Raycast(gameObject.transform.position + m_rayPosition, gameObject.transform.right, m_playerDimensions.x - m_rayOffset);

            //Debug.DrawRay(gameObject.transform.position + m_rayPosition, gameObject.transform.right);

            // if the raycast collides with a platform, the player is touching the ground
            if (m_rayH2D.collider != null && m_rayH2D.collider.gameObject.tag == "Platform")
            {
                m_inAir     = false;
                m_jumpTimer = 0.0f;

                if (m_rb2d.drag == m_airDrag)
                {
                    m_landDrag      = Mathf.Lerp(m_maxLandDrag, m_groundDrag, (Mathf.Abs(m_rb2d.velocity.x) / m_maxHorizontalSpeed));
                    m_rb2d.drag     = m_landDrag;
                    m_recoveryTimer = 0.0f;
                }
            }
            // if the raycast does not collide with a platform, the player is in the air
            else
            {
                m_inAir     = true;
                m_rb2d.drag = m_airDrag;
            }
        }
        m_animator.SetBool("Jump", m_inAir);
        print(m_rb2d.velocity.x);
    }
    // Update is called once per frame
    void Update()
    {
        if (uiObjects[0].activeInHierarchy) //if currently at MAIN MENU State
        {
            Time.timeScale = 0;

            if (currPointing_MainMenu == currOption_MainMenu.START)
            {
                if (XCI.GetButtonDown(XboxButton.DPadUp, controller) || XCI.GetButtonDown(XboxButton.DPadDown, controller))
                {
                    startSprite_MainMenu.sprite = startSpriteList_MainMenu[0];
                    exitSprite_MainMenu.sprite  = exitSpriteList_MainMenu[1];
                    currPointing_MainMenu       = currOption_MainMenu.EXIT;
                }

                if (XCI.GetButtonDown(XboxButton.B, controller))
                {
                    switchGameState(gameState.INGAME);
                }
            }
            else if (currPointing_MainMenu == currOption_MainMenu.EXIT)
            {
                if (XCI.GetButtonDown(XboxButton.DPadUp, controller) || XCI.GetButtonDown(XboxButton.DPadDown, controller))
                {
                    startSprite_MainMenu.sprite = startSpriteList_MainMenu[1];
                    exitSprite_MainMenu.sprite  = exitSpriteList_MainMenu[0];
                    currPointing_MainMenu       = currOption_MainMenu.START;
                }

                if (XCI.GetButtonDown(XboxButton.B, controller))
                {
                    Application.Quit();
                }
            }
        }

        if (uiObjects[1].activeInHierarchy) //if currently at INGAME State
        {
            Time.timeScale = 1;

            player1ScoreText.text = player1Score.ToString();
            player2ScoreText.text = player2Score.ToString();

            if (XCI.GetButtonDown(XboxButton.Start, controller))
            {
                switchGameState(gameState.PAUSE);
            }
        }

        if (uiObjects[2].activeInHierarchy) //if currently at PAUSE State
        {
            Time.timeScale = 0;

            if (currPointing_Pause == currOption_Pause.RESUME)
            {
                if (XCI.GetButtonDown(XboxButton.B, controller))
                {
                    switchGameState(gameState.INGAME);
                }

                if (XCI.GetButtonDown(XboxButton.DPadUp, controller))
                {
                    currPointing_Pause          = currOption_Pause.EXIT;
                    resumeSprite_Pause.sprite   = resumeSpriteList_Pause[0];
                    mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[0];
                    exitSprite_Pause.sprite     = exitSpriteList_Pause[1];
                }

                if (XCI.GetButtonDown(XboxButton.DPadDown, controller))
                {
                    currPointing_Pause          = currOption_Pause.MAIN;
                    resumeSprite_Pause.sprite   = resumeSpriteList_Pause[0];
                    mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[1];
                    exitSprite_Pause.sprite     = exitSpriteList_Pause[0];
                }
            }
            else if (currPointing_Pause == currOption_Pause.MAIN)
            {
                if (XCI.GetButtonDown(XboxButton.B, controller))
                {
                    switchGameState(gameState.MAIN);
                }

                if (XCI.GetButtonDown(XboxButton.DPadUp, controller))
                {
                    currPointing_Pause          = currOption_Pause.RESUME;
                    resumeSprite_Pause.sprite   = resumeSpriteList_Pause[1];
                    mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[0];
                    exitSprite_Pause.sprite     = exitSpriteList_Pause[0];
                }

                if (XCI.GetButtonDown(XboxButton.DPadDown, controller))
                {
                    currPointing_Pause          = currOption_Pause.EXIT;
                    resumeSprite_Pause.sprite   = resumeSpriteList_Pause[0];
                    mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[0];
                    exitSprite_Pause.sprite     = exitSpriteList_Pause[1];
                }
            }
            else if (currPointing_Pause == currOption_Pause.EXIT)
            {
                if (XCI.GetButtonDown(XboxButton.B, controller))
                {
                    Application.Quit();
                }

                if (XCI.GetButtonDown(XboxButton.DPadUp, controller))
                {
                    currPointing_Pause          = currOption_Pause.MAIN;
                    resumeSprite_Pause.sprite   = resumeSpriteList_Pause[0];
                    mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[1];
                    exitSprite_Pause.sprite     = exitSpriteList_Pause[0];
                }

                if (XCI.GetButtonDown(XboxButton.DPadDown, controller))
                {
                    currPointing_Pause          = currOption_Pause.RESUME;
                    resumeSprite_Pause.sprite   = resumeSpriteList_Pause[1];
                    mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[0];
                    exitSprite_Pause.sprite     = exitSpriteList_Pause[0];
                }
            }
        }

        if (uiObjects[3].activeInHierarchy) //if currently at In NEXT State
        {
            Time.timeScale = 0;

            if (currPointing_Next == currOption_Next.NEXT)
            {
                if (XCI.GetButtonDown(XboxButton.B, controller))
                {
                    switchGameState(gameState.INGAME);
                    GM.refreshStage();
                }

                if (XCI.GetButtonDown(XboxButton.DPadUp, controller))
                {
                    currPointing_Next          = currOption_Next.EXIT;
                    nextSprite_Next.sprite     = nextSpriteList_Next[0];
                    mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[0];
                    exitSprite_Next.sprite     = exitSpriteList_Next[1];
                }

                if (XCI.GetButtonDown(XboxButton.DPadDown, controller))
                {
                    currPointing_Next          = currOption_Next.MAIN;
                    nextSprite_Next.sprite     = nextSpriteList_Next[0];
                    mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[1];
                    exitSprite_Next.sprite     = exitSpriteList_Next[0];
                }
            }
            else if (currPointing_Next == currOption_Next.MAIN)
            {
                if (XCI.GetButtonDown(XboxButton.B, controller))
                {
                    switchGameState(gameState.MAIN);
                }

                if (XCI.GetButtonDown(XboxButton.DPadUp, controller))
                {
                    currPointing_Next          = currOption_Next.NEXT;
                    nextSprite_Next.sprite     = nextSpriteList_Next[1];
                    mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[0];
                    exitSprite_Next.sprite     = exitSpriteList_Next[0];
                }

                if (XCI.GetButtonDown(XboxButton.DPadDown, controller))
                {
                    currPointing_Next          = currOption_Next.EXIT;
                    nextSprite_Next.sprite     = nextSpriteList_Next[0];
                    mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[0];
                    exitSprite_Next.sprite     = exitSpriteList_Next[1];
                }
            }
            else if (currPointing_Next == currOption_Next.EXIT)
            {
                if (XCI.GetButtonDown(XboxButton.B, controller))
                {
                    Application.Quit();
                }

                if (XCI.GetButtonDown(XboxButton.DPadUp, controller))
                {
                    currPointing_Next          = currOption_Next.MAIN;
                    nextSprite_Next.sprite     = nextSpriteList_Next[0];
                    mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[1];
                    exitSprite_Next.sprite     = exitSpriteList_Next[0];
                }

                if (XCI.GetButtonDown(XboxButton.DPadDown, controller))
                {
                    currPointing_Next          = currOption_Next.NEXT;
                    nextSprite_Next.sprite     = nextSpriteList_Next[1];
                    mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[0];
                    exitSprite_Next.sprite     = exitSpriteList_Next[0];
                }
            }
        }
    }
    /*
     * Brief: manage the horizontal movement of the player
     */
    void Update()
    {
        // if the player is alive
        if (m_cameraMovement.m_playerAlive)
        {
            m_direction = 0.0f;
            if (Input.GetAxis("Horizontal") > m_inputThreshold || XCI.GetDPad(XboxDPad.Right))
            {
                m_direction = 1.0f;
            }
            else if (Input.GetAxis("Horizontal") < -m_inputThreshold || XCI.GetDPad(XboxDPad.Left))
            {
                m_direction = -1.0f;
            }

            //Sets moveVelocity's x to - or + move speed
            m_moveVelocity.x = m_direction * m_currentAcceleration;

            //Sets ray position to the left or right side of player
            if (m_moveVelocity.x > 0 && m_rayPosition.x < 0.0f)
            {
                m_rayPosition.x = m_playerDimensions.x + m_minWallDistance;
            }
            else if (m_moveVelocity.x < 0 && m_rayPosition.x > 0.0f)
            {
                m_rayPosition.x = -m_playerDimensions.x - m_minWallDistance;
            }

            //Increases velocity by the move velocity
            m_rb2d.velocity += m_moveVelocity;

            //If jump is pressed set max aerial speed to current x velocity
            if (Input.GetButtonDown("Jump") || XCI.GetButtonDown(XboxButton.A))
            {
                m_aerialMaxSpeed = Mathf.Abs(m_rb2d.velocity.x);
            }

            //Checks if x velocity is greater than max speed in either direction
            if (m_rb2d.velocity.x > m_maxSpeed || m_rb2d.velocity.x < -m_maxSpeed)
            {
                // set the player's speed to the max speed of the direction it is moving
                m_maxVelocity.Set(((m_rb2d.velocity.x >= 0) ? 1 : -1) * m_maxSpeed, m_rb2d.velocity.y);
                m_rb2d.velocity = m_maxVelocity;
            }

            //Checks if the player is in the air
            if (m_playJump.m_inAir)
            {
                m_currentAcceleration = m_airAcceleration;
                //Sets the aerialMaxSpeed to the minimum
                if (m_aerialMaxSpeed < m_minimumMaxAirSpeed)
                {
                    m_aerialMaxSpeed = m_minimumMaxAirSpeed;
                }
                //Checks if x velocity is greater than max speed
                if (Mathf.Abs(m_rb2d.velocity.x) > m_aerialMaxSpeed)
                {
                    // set the player's speed to the max speed of the direction it is moving
                    m_maxVelocity.Set(((m_rb2d.velocity.x >= 0) ? 1 : -1) * m_aerialMaxSpeed, m_rb2d.velocity.y);
                    m_rb2d.velocity = m_maxVelocity;
                }
            }
            //Resets current speed back to ground speed
            else
            {
                m_currentAcceleration = m_groundAcceleration;

                // determine what the max aerial speed would be for if the player were to fall of a platform without jumping
                m_aerialMaxSpeed = Mathf.Abs(m_rb2d.velocity.x);
            }

            if (m_rb2d.velocity.x > 0.0f && gameObject.transform.rotation.eulerAngles.y > 90.0f)
            {
                gameObject.transform.rotation = m_right;
            }
            else if (m_rb2d.velocity.x < 0.0f && gameObject.transform.rotation.eulerAngles.y < 90.0f)
            {
                gameObject.transform.rotation = m_left;
            }

            // draw a raycast adjacent to the player, in the direction they are moving
            m_rayRH2D = Physics2D.Raycast(gameObject.transform.position + m_rayPosition, gameObject.transform.up, m_playerDimensions.y - m_yRayOffset);

            //Debug.DrawRay(gameObject.transform.position + m_rayPosition, gameObject.transform.up, Color.magenta);

            // if the raycast collides with a platform, the player is hitting a wall
            if (m_rayRH2D.collider != null && m_rayRH2D.collider.gameObject.tag == "Platform")
            {
                // set the player's horizontal velocity to 0
                m_wallHit.y     = m_rb2d.velocity.y;
                m_rb2d.velocity = m_wallHit;
            }
        }
        m_animator.SetFloat("X_Velocity", Mathf.Round(m_rb2d.velocity.x * 100f) / 100f);
    }
Example #10
0
 public override bool PressButtonB()
 {
     return(XCI.GetButtonDown(XboxButton.A, controller));
 }
 /// <summary>
 /// uses the keys 1-4 on the top of the keyboard to activate their players
 /// </summary>
 private void SelectPlayers()
 {
     //if controller one's start button is pressed assign controller one to the next avaliable player
     if (XCI.GetButtonDown(XboxButton.A, XboxController.First))
     {
         //checks to see if the controller has already been assigned
         if (!isController1Active)
         {
             //checks the controller count to see what plater needs to be set next
             if (controllerCount == 0)
             {
                 Player1.SetActive(!Player1.activeInHierarchy);
                 controllerCount++;
                 isController1Active = true;
                 Player1.GetComponent <PlayerInput>().SetController(XboxController.First);
                 p1 = 0;
                 return;
             }
             else if (controllerCount == 1)
             {
                 Player2.SetActive(!Player2.activeInHierarchy);
                 controllerCount++;
                 isController1Active = true;
                 Player2.GetComponent <PlayerInput>().SetController(XboxController.First);
                 p2 = 0;
                 return;
             }
             else if (controllerCount == 2)
             {
                 Player3.SetActive(!Player3.activeInHierarchy);
                 controllerCount++;
                 isController1Active = true;
                 Player3.GetComponent <PlayerInput>().SetController(XboxController.First);
                 p3 = 0;
                 return;
             }
             else if (controllerCount == 3)
             {
                 Player4.SetActive(!Player4.activeInHierarchy);
                 controllerCount++;
                 isController1Active = true;
                 Player4.GetComponent <PlayerInput>().SetController(XboxController.First);
                 p4 = 0;
                 return;
             }
         }
     }
     //if controller two's start button is pressed assign controller two to the next avaliable player
     if (XCI.GetButtonDown(XboxButton.A, XboxController.Second))
     {
         //checks to see if the controller has already been assigned
         if (!isController2Active)
         {
             //checks the controller count to see what plater needs to be set next
             if (controllerCount == 0)
             {
                 Player1.SetActive(!Player1.activeInHierarchy);
                 controllerCount++;
                 isController2Active = true;
                 Player1.GetComponent <PlayerInput>().SetController(XboxController.Second);
                 p1 = 1;
             }
             else if (controllerCount == 1)
             {
                 Player2.SetActive(!Player2.activeInHierarchy);
                 controllerCount++;
                 isController2Active = true;
                 Player2.GetComponent <PlayerInput>().SetController(XboxController.Second);
                 p2 = 1;
             }
             else if (controllerCount == 2)
             {
                 Player3.SetActive(!Player3.activeInHierarchy);
                 controllerCount++;
                 isController2Active = true;
                 Player3.GetComponent <PlayerInput>().SetController(XboxController.Second);
                 p3 = 1;
             }
             else if (controllerCount == 3)
             {
                 Player4.SetActive(!Player4.activeInHierarchy);
                 controllerCount++;
                 isController2Active = true;
                 Player4.GetComponent <PlayerInput>().SetController(XboxController.Second);
                 p4 = 1;
             }
         }
     }
     //if controller three's start button is pressed assign controller three to the next avaliable player
     if (XCI.GetButtonDown(XboxButton.A, XboxController.Third))
     {
         //checks to see if the controller has already been assigned
         if (!isController3Active)
         {
             //checks the controller count to see what plater needs to be set next
             if (controllerCount == 0)
             {
                 Player1.SetActive(!Player1.activeInHierarchy);
                 controllerCount++;
                 isController3Active = true;
                 Player1.GetComponent <PlayerInput>().SetController(XboxController.Third);
                 p1 = 2;
             }
             else if (controllerCount == 1)
             {
                 Player2.SetActive(!Player2.activeInHierarchy);
                 controllerCount++;
                 isController3Active = true;
                 Player2.GetComponent <PlayerInput>().SetController(XboxController.Third);
                 p2 = 2;
             }
             else if (controllerCount == 2)
             {
                 Player3.SetActive(!Player3.activeInHierarchy);
                 controllerCount++;
                 isController3Active = true;
                 Player3.GetComponent <PlayerInput>().SetController(XboxController.Third);
                 p3 = 2;
             }
             else if (controllerCount == 3)
             {
                 Player4.SetActive(!Player4.activeInHierarchy);
                 controllerCount++;
                 isController3Active = true;
                 Player4.GetComponent <PlayerInput>().SetController(XboxController.Third);
                 p4 = 2;
             }
         }
     }
     //if controller four's start button is pressed assign controller four to the next avaliable player
     if (XCI.GetButtonDown(XboxButton.A, XboxController.Fourth))
     {
         //checks to see if the controller has already been assigned
         if (!isController4Active)
         {
             //checks the controller count to see what plater needs to be set next
             if (controllerCount == 0)
             {
                 Player1.SetActive(!Player1.activeInHierarchy);
                 controllerCount++;
                 isController4Active = true;
                 Player1.GetComponent <PlayerInput>().SetController(XboxController.Fourth);
                 p1 = 3;
             }
             else if (controllerCount == 1)
             {
                 Player2.SetActive(!Player2.activeInHierarchy);
                 controllerCount++;
                 isController4Active = true;
                 Player2.GetComponent <PlayerInput>().SetController(XboxController.Fourth);
                 p2 = 3;
             }
             else if (controllerCount == 2)
             {
                 Player3.SetActive(!Player3.activeInHierarchy);
                 controllerCount++;
                 isController4Active = true;
                 Player3.GetComponent <PlayerInput>().SetController(XboxController.Fourth);
                 p3 = 3;
             }
             else if (controllerCount == 3)
             {
                 Player4.SetActive(!Player4.activeInHierarchy);
                 controllerCount++;
                 isController4Active = true;
                 Player1.GetComponent <PlayerInput>().SetController(XboxController.Fourth);
                 p4 = 3;
             }
         }
     }
 }
    void Update()
    {
        _xaxis     = XCI.GetAxis(XboxAxis.LeftStickX, _controller);
        _yaxis     = XCI.GetAxis(XboxAxis.LeftStickY, _controller);
        _baseSpeed = new Vector2(_xaxis, _yaxis).normalized;

        _pushedSpeed /= 2f;

        switch (_state)
        {
        case CharacterState.Roaming:

            if (!_collider.enabled)
            {
                _collider.enabled = true;
                _stunEmoji.SetActive(false);
            }

            if ((Mathf.Sign(_baseSpeed.x) != -Mathf.Sign(_t.localScale.x)) && _baseSpeed.x != 0f)
            {
                _t.localScale = new Vector3(-_t.localScale.x, 1f, 1f);
            }

            _t.Translate(new Vector2(_baseSpeed.x * XSPEED * _dashMultiplier, _baseSpeed.y * YSPEED * _dashMultiplier) + _pushedSpeed);

            if (XCI.GetButtonDown(XboxButton.A, _controller))
            {
                Dash(DASH_DECAY, DASH_COOLDOWN);
            }

            if (XCI.GetButtonDown(XboxButton.B, _controller))
            {
                Deceive();
            }

            if (XCI.GetButtonDown(XboxButton.Y, _controller))
            {
                var hit = Physics2D.CircleCastAll(_t.position, 0.5f, Vector2.up, 0.5f, 1 << LayerMask.NameToLayer("Poopoo"));
                if (hit.Length > 0)
                {
                    EatDaPoopoo(hit[0]);
                }
            }

            if (XCI.GetButtonDown(XboxButton.X, _controller))
            {
                var hits = Physics2D.CircleCastAll(_t.position, 0.5f, Vector2.up, 0.5f, 1 << LayerMask.NameToLayer("Player"));
                foreach (var h in hits)
                {
                    if (h.transform != _t)
                    {
                        var other = h.transform.GetComponent <Character>();
                        other.ReceiveStun(2f);
                        other.ReceivePush(other.transform.position - _t.position);
                    }
                }
            }

            break;

        case CharacterState.Dashing:
            _t.Translate(new Vector2(_baseSpeed.x * XSPEED * _dashMultiplier, _baseSpeed.y * YSPEED * _dashMultiplier));
            break;

        case CharacterState.Deceiving:
            if (XCI.GetButtonUp(XboxButton.B, _controller))
            {
                GetComponent <Animator>().Play("Idle");
                Interrupt();
            }
            break;

        case CharacterState.Mining:

            if (XCI.GetButtonUp(XboxButton.Y, _controller))
            {
                GetComponent <Animator>().Play("Idle");
                Interrupt();
            }
            break;

        case CharacterState.Stunned:
            _stunTime = Mathf.Clamp(_stunTime - Time.deltaTime, 0f, _stunTime);
            if (_stunTime == 0f)
            {
                _state            = CharacterState.Roaming;
                _collider.enabled = true;
                _stunEmoji.SetActive(false);
            }

            _t.Translate(_pushedSpeed);

            break;

        default:
            break;
        }

        if (_t.position.x < -9)
        {
            _t.position = new Vector3(-9, _t.position.y, _t.position.z);
        }

        if (_t.position.x > 9)
        {
            _t.position = new Vector3(9, _t.position.y, _t.position.z);
        }

        if (_t.position.y < -4.5)
        {
            _t.position = new Vector3(_t.position.x, -4.5f, _t.position.z);
        }

        if (_t.position.y > 4.5)
        {
            _t.position = new Vector3(_t.position.x, 4.5f, _t.position.z);
        }
    }
Example #13
0
 public override bool GetButtonDown(XboxButton button)
 {
     return(XCI.GetButtonDown(button, XboxController));
 }
Example #14
0
    //Update is called once per frame
    void Update()
    {
        if (m_gameActive)
        {
            //Checks if a controller is plugged in
            if (XCI.IsPluggedIn(m_playerID))
            {
                //Checks if the ammount of ammo fired is not equal to the mag size
                if (m_ammoFired != m_magSize)
                {
                    //Checks if the shot timer is greater then shot delay so the player can shoot again
                    if (m_shotTimer >= m_shotDelay)
                    {
                        //Checks if the right bumper is pressed down
                        if (XCI.GetButtonDown(XboxButton.RightBumper, (XboxController)m_playerID))
                        {
                            m_objectArray[m_shotFired].SetActive(true);
                            m_objectArray[m_shotFired].GetComponent <Bullet>().OnFired();
                            ++m_ammoFired;
                            ++m_shotFired;
                            m_shotTimer = 0.0f;
                            print("Fired " + m_ammoFired);
                        }
                    }
                    else
                    {
                        m_shotTimer += Time.deltaTime;
                    }
                }
                else
                {
                    m_reloadTimer += Time.deltaTime;

                    //Checks if the reload timer is greater then reload time
                    if (m_reloadTimer >= m_reloadTime)
                    {
                        m_ammoFired   = 0;
                        m_reloadTimer = 0;

                        //Checks if the shots fired is equal to the ammo count
                        if (m_shotFired == m_ammoCount)
                        {
                            m_shotFired = 0;
                        }
                    }
                }

                //Checks if the right analog stick is moved
                if (XCI.GetAxis(XboxAxis.RightStickX, (XboxController)m_playerID) != 0 || XCI.GetAxis(XboxAxis.RightStickY, (XboxController)m_playerID) != 0)
                {
                    m_lookDirection.x  = XCI.GetAxis(XboxAxis.RightStickX, (XboxController)m_playerID);
                    m_lookDirection.z  = XCI.GetAxis(XboxAxis.RightStickY, (XboxController)m_playerID);
                    transform.rotation = Quaternion.LookRotation(m_lookDirection);
                }
            }
            //Checks if the rapidfire bool is true
            if (m_rapidFire)
            {
                m_rapidfireTimer += Time.deltaTime;
                m_shotDelay       = m_rapidfireShotDelay;
                m_reloadTime      = m_RapidfireReloadTime;
            }

            //Checks if the timer is greater then the time for the pickup
            if (m_rapidfireTimer >= m_rapidfireTime)
            {
                m_shotDelay      = m_defaultShotDelay;
                m_reloadTime     = m_defaultReloadTime;
                m_rapidFire      = false;
                m_rapidfireTimer = 0.0f;
            }
        }
    }
Example #15
0
    void Update()
    {
        UpdateUI_Speed();

        if (IsActiveGame())
        {
            _LapTimes[_CurrentLap] += Time.deltaTime;
            UpdateUI_LapTime();
        }

        if (_IsGameOver)
        {
            if (!_GlobalMusic.isPlaying)
            {
                _GlobalMusic.clip = _GlobalSounds._Sounds[1];
                _GlobalMusic.loop = true;
                _GlobalMusic.Play();
            }
            if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Space) || XCI.GetButtonDown(XboxButton.Start) || XCI.GetButtonDown(XboxButton.A))
            {
                _ResultsUI.SetLapTimeLabels(_LapTimeUI.LapTimeLabels);
                _ResultsUI.SetFinalTimeLabel(_LapTimeUI.FinalTimeLabel);

                _PlayerUI.gameObject.SetActive(false);
                _LapTimeUI.gameObject.SetActive(false);
                _FinishUI.gameObject.SetActive(false);
                _ResultsUI.gameObject.SetActive(true);
            }
        }
    }
Example #16
0
    // Update is called once per frame
    public void Update() { 
        //Loads player UI at beginning of game
        if(!uiSet && GameInit.arena != null) {
            uiSet = true;
            GameInit.arena.setUI(playerNum);
            elementL.sprite = Resources.Load("UI Art Assets/mana/" + elements [0].getName() + "_element", typeof(Sprite)) as Sprite;
            elementR.sprite = Resources.Load("UI Art Assets/mana/" + elements [1].getName() + "_element", typeof(Sprite)) as Sprite;
            Debug.Log("color: "+color.ToString());
			playerPic.sprite = Resources.Load("UI Art Assets/mana/"+color.ToString()+"_figure", typeof(Sprite)) as Sprite;
			if(!isDead)
				anim.runtimeAnimatorController = Resources.Load("Animation Controllers/"+color.ToString()+" Player", typeof(RuntimeAnimatorController)) as RuntimeAnimatorController;
        }
        
        if (!isDead) {
			timeAlive++;
            //turns off animator bools so cast animations do not repeat forever. 
            if(anim.GetCurrentAnimationClipState(0)!= null) {
                if(anim.GetCurrentAnimationClipState(0)[0].clip.name.EndsWith("Cast Slash"))
                    anim.SetBool("Slash", false);
                if (anim.GetCurrentAnimationClipState(0)[0].clip.name.EndsWith("Cast Missile 1"))
                    anim.SetBool("Missile", false);
                if (anim.GetCurrentAnimationClipState(0)[0].clip.name.EndsWith("Cast Wall"))
                    anim.SetBool("Wall", false);
            }
            if(chargeLeft>0)
				chargeLeft--;
			else if(chargeLeft<=0 && charging){
				charging=false;
				chargeLeft=0;
				anim.SetBool("isCharging",false);
			}
            
			float lt = XCI.GetAxis(XboxAxis.LeftTrigger, controllerNum); //true if left trigger is pushed, else false
			float rt = XCI.GetAxis(XboxAxis.RightTrigger, controllerNum); //true if right trigger is pushed, else false
			regenMana();
			if (mana > 100)
				mana = 100;
			if(stunT>0){stunT--;}			
			else{
                if(anim.GetBool("isHit"))
                    anim.SetBool("isHit", false);
                if(anim.GetBool("isBlockAndHit"))
					anim.SetBool("isBlockAndHit", false);
                    
//                if(!casting)
	            //Debug.Log (lt+" || "+rt);
	            //Code for casting Slash
				if (XCI.GetButtonDown(XboxButton.X, controllerNum)) {
	//                elementLoaded.SetActive(false);
	                if (((rt>.5 && lt>.5) || !(rt > .5 || lt > .5)) && casting) {
	                    //Actually, punch, but for now, nothing
	                    //Debug.Log ("I'm here");
	                } 
	                else if(!(rt>.5 || lt>.5) && !casting){
						Punch punch = spells[3].GetComponent("Punch") as Punch;
						if(punch.cd==0){
							punch.start();
							currentSpell=punch;
						}
						else
							playSound("OutOfMana2");
	                }
	                else if(!casting){
	                    bool justMade = false;
	                    if (spells [0] == null) {
	                        slashMaker();
	                        //Slash s=spells[0].GetComponent("Slash") as Slash;
	                        justMade = true;
	                        //s.prepSlash(this,spells[0]);
	                    }
	                    //			Debug.Log(spells[0].transform.position+" HI");
	                    Slash slash = spells [0].GetComponent("Slash") as Slash;
	                    if (lt > .5)
	                        slash.infuse(elements [0]);
	                    else if (rt > .5)
	                        slash.infuse(elements [1]);	
	                    Debug.Log("Slash's Element is " + slash.getElement().getName());
	                    if (mana < slash.getMana()) {
							Debug.Log("no slash mana");
	                        playNoMana();
	                        slash.kill();
	                    }
	                    else {
							slash.sound.Play();
							reduceMana(slash);
	                        currentSpell=slash;
	                        casting = true;
	                        if (slash.casting) {
	                            return;
	                        }
	                        anim.SetFloat("Speed",0);
							slash.charge(); 
					
	                        if (slash.facingRight && !facingRight)
	                            slash.Flip();
	                        else if (!slash.facingRight && facingRight)
	                            slash.Flip();
	                    }
	                }
	            }
				//Code for casting Missile
				else if (XCI.GetButtonDown(XboxButton.B, controllerNum)) {
	                //Debug.Log("FIRE DA MISSILES");
					if ((rt>.5 && lt>.5) || !(rt > .5 || lt > .5) || casting) {
	                    //Actually, dodgeroll, but for now, nothing
	                    //Debug.Log ("I'm here");
	                } 
	                else {
	                    bool justMade = false;
	                    if (spells [1] == null) {
	                        missileMaker();
	                        //Slash s=spells[0].GetComponent("Slash") as Slash;
	                        //justMade = true;
	                        //s.prepSlash(this,spells[0]);
	                    }
	                    //			Debug.Log(spells[0].transform.position+" HI");
	                    Missile missile = Instantiate(spells [1].GetComponent("Missile")) as Missile;
	                    if (lt > .5)
	                        missile.infuse(elements [0]);
	                    else if (rt > .5)
	                        missile.infuse(elements [1]);
	                    Debug.Log("Missile's Element is " + missile.getElement().getName());
	                    if (mana < missile.getMana()){
							Debug.Log("no missile mana");
	                        playNoMana();
	                        missile.kill();
	                    }
	                    else {
							missile.sound.Play();
	                        reduceMana(missile);
	                        currentSpell=missile;
	                        casting = true;
	                        if (missile.casting) {
	                            return;
	                        }
							anim.SetFloat("Speed",0);
							missile.charge();
	
	                        if (missile.facingRight && !facingRight)
	                            missile.Flip();
	                        else if (!missile.facingRight && facingRight)
	                            missile.Flip();
	                    }
	                }
	            } 
	            //code for wall
				else if (XCI.GetButtonDown(XboxButton.Y, controllerNum)) {
					if(!(rt > .5 || lt > .5)){
						setBlock(true);
						anim.SetFloat("Speed", 0f);
						anim.SetBool("isBlocking",true); //?
					}
					else if ((rt>.5 && lt>.5) || casting) {
						//Actually, block, but for now, nothing
						//Debug.Log ("I'm here");
					} 
					else {
						bool justMade = false;
						if (spells [2] == null) {
							wallMaker();
							//Slash s=spells[0].GetComponent("Slash") as Slash;
							//justMade = true;
							//s.prepSlash(this,spells[0]);
						}
						//			Debug.Log(spells[0].transform.position+" HI");
						Wall wall = Instantiate(spells [2].GetComponent("Wall")) as Wall;
						if (lt > .5)
							wall.infuse(elements [0]);
						else if (rt > .5)
							wall.infuse(elements [1]);
						Debug.Log("Missile's Element is " + wall.getElement().getName());
						if (mana < wall.getMana()){
							Debug.Log("no wall mana");
							playNoMana();
							wall.kill();
						}
						else {
							wall.sound.Play();
							reduceMana(wall);
							currentSpell=wall;
							casting = true;
							if (wall.casting) {
								return;
							}
							anim.SetFloat("Speed",0);
							wall.charge();
							
							/*if (wall.facingRight && !facingRight)
								wall.Flip();
							else if (!wall.facingRight && facingRight)
								wall.Flip();*/
						}
					}
				}
				else if(XCI.GetButtonUp(XboxButton.Y, controllerNum) && block){
					block=false;
					anim.SetBool("isBlocking",false);
				}
				else {
				            if (!(rt > .5 && lt > .5) && !casting && !charging) {
														
				                if (lt > .5) {
                                    aura.gameObject.SetActive(true);
                                    aura.color = elements[0].getColor();
                                }
                                else if (rt > .5) {
				                    aura.gameObject.SetActive(true);
                                    aura.color = elements[1].getColor();
                                }
				                else
                                    aura.gameObject.SetActive(false);
				            } else
                                aura.gameObject.SetActive(false);
				}
			}
		}
        //update health and mana bars
		healthBarTrans.sizeDelta = new Vector2(hp * healthSize, healthBarTrans.sizeDelta.y);
		manaBarTrans.sizeDelta = new Vector2(mana * manaSize, manaBarTrans.sizeDelta.y);
    }
Example #17
0
    void PlayerControls()
    {
        XAxis = XCI.GetAxis(XboxAxis.LeftStickX);
        YAxis = XCI.GetAxis(XboxAxis.LeftStickY);
        //WHILE PLAYER IS ON THE GROUND
        if (Control.isGrounded)
        {
            MoveDirection   = new Vector3(XAxis, 0.0f, YAxis);
            MoveDirection   = Camera.main.transform.TransformDirection(MoveDirection);
            MoveDirection   = MoveDirection * Speed;
            MoveDirection.y = 0;

            // transform.eulerAngles = new Vector3(transform.eulerAngles.x, Mathf.Atan2(-XAxis, -YAxis) * Mathf.Rad2Deg, transform.eulerAngles.z);
        }

        //WHILE PLAYER IS NOT ON THE GROUND
        if (!Control.isGrounded)
        {
            Grounded = false;
        }
        MoveDirection.y = MoveDirection.y - (GravityY * Time.deltaTime);
        // IF THE PLAYER CAN JUMP
        if (Canjump)
        {
            if (XCI.GetButtonDown(XboxButton.A))
            {
                MoveDirection.y = Jumpheight;
                Djump          += 1;
                if (Djump >= 2)
                {
                    Canjump = false;
                }
            }
        }
        Control.Move(MoveDirection * Time.deltaTime);

        // SPRINTING
        if (XCI.GetAxis(XboxAxis.LeftTrigger) > 0.35f)
        {
            IsSprinting = true;
        }
        if (XCI.GetAxis(XboxAxis.LeftTrigger) < 0.35f)
        {
            IsSprinting = false;
        }

        // rotate to where camera is looking
        if (XCI.GetAxis(XboxAxis.LeftStickY) > 0.55 || Input.GetKey(KeyCode.W))
        {
            TargetDirection.x = transform.position.x - Camera.main.transform.position.x;
            TargetDirection.z = transform.position.z - Camera.main.transform.position.z;

            Vector3 Forward      = new Vector3(TargetDirection.x, 0.0f, TargetDirection.z);
            Vector3 NewDirection = Vector3.RotateTowards(transform.forward, Forward, 3 * Time.deltaTime, 0);
            transform.rotation = Quaternion.LookRotation(NewDirection);
        }
        if (XCI.GetAxis(XboxAxis.LeftStickY) < -0.55 || Input.GetKey(KeyCode.S))
        {
            TargetDirection.x = transform.position.x - Camera.main.transform.position.x;
            TargetDirection.z = transform.position.z - Camera.main.transform.position.z;

            Vector3 Forward      = new Vector3(TargetDirection.x, 0.0f, TargetDirection.z);
            Vector3 NewDirection = Vector3.RotateTowards(transform.forward, -Forward, 3 * Time.deltaTime, 0);
            transform.rotation = Quaternion.LookRotation(NewDirection);
        }

        if (XCI.GetAxis(XboxAxis.LeftStickX) < -0.85 || Input.GetKey(KeyCode.A))
        {
            TargetDirection.x = transform.position.x - LookLeft.transform.position.x;
            TargetDirection.z = transform.position.z - LookLeft.transform.position.z;

            Vector3 Forward      = new Vector3(TargetDirection.x, 0.0f, TargetDirection.z);
            Vector3 NewDirection = Vector3.RotateTowards(transform.forward, -Forward, 5 * Time.deltaTime, 0);
            transform.rotation = Quaternion.LookRotation(NewDirection);
        }
        if (XCI.GetAxis(XboxAxis.LeftStickX) > 0.85 || Input.GetKey(KeyCode.D))
        {
            TargetDirection.x = transform.position.x - LookRight.transform.position.x;
            TargetDirection.z = transform.position.z - LookRight.transform.position.z;

            Vector3 Forward      = new Vector3(TargetDirection.x, 0.0f, TargetDirection.z);
            Vector3 NewDirection = Vector3.RotateTowards(transform.forward, -Forward, 5 * Time.deltaTime, 0);
            transform.rotation = Quaternion.LookRotation(NewDirection);
        }
    }
Example #18
0
    // Update is called once per frame
    void Update()
    {
        //Single Player
        if (m_singlePlayer)
        {
            //User interface updates
            if (m_player1Health != m_player1.GetComponent <Player>().GetHealth())
            {
                m_player1Health = m_player1.GetComponent <Player>().GetHealth();
                GetComponentInChildren <UI>().UpdateHealthUI(m_player1Health, m_player2Health);
            }

            if (m_player1.GetComponent <Player>().IsDead())
            {
                //Gameover State
                gameOverTimer += Time.deltaTime;
                if (gameOverTimer >= 3)
                {
                    m_gameoverPanel.SetActive(true);
                    Time.timeScale = 0.0f;
                    gameOverTimer  = 0;
                }
            }
        }
        else //Two player
        {
            //User interface updates
            if (m_player1Health != m_player1.GetComponent <Player>().GetHealth())
            {
                m_player1Health = m_player1.GetComponent <Player>().GetHealth();
                GetComponentInChildren <UI>().UpdateHealthUI(m_player1Health, m_player2Health);
            }

            if (m_player2Health != m_player2.GetComponent <Player>().GetHealth())
            {
                m_player2Health = m_player2.GetComponent <Player>().GetHealth();
                GetComponentInChildren <UI>().UpdateHealthUI(m_player1Health, m_player2Health);
            }

            //Gameover State
            if (m_player1.GetComponent <Player>().IsDead() && m_player2.GetComponent <Player>().IsDead()) //Game over two player
            {
                gameOverTimer += Time.deltaTime;
                if (gameOverTimer >= 3)
                {
                    m_gameoverPanel.SetActive(true);
                    Time.timeScale = 0.0f;
                    gameOverTimer  = 0;
                }
            }
        }

        if (m_singlePlayer)
        {
            //Pausing Screen
            if (XCI.GetButtonDown(XboxButton.Start, m_player1.GetComponent <Player>().controller))
            {
                m_pausePanel.SetActive(true);
                Time.timeScale = 0.0f;
            }

            //Show controls
            if (XCI.GetButtonDown(XboxButton.Back, m_player1.GetComponent <Player>().controller))
            {
                m_controlsPanel.SetActive(true);
            }
        }
        else
        {
            //Pausing Screen
            if (XCI.GetButtonDown(XboxButton.Start, m_player1.GetComponent <Player>().controller) || XCI.GetButtonDown(XboxButton.Start, m_player2.GetComponent <Player>().controller))
            {
                m_pausePanel.SetActive(true);
                Time.timeScale = 0.0f;
            }

            //Show controls
            if (XCI.GetButtonDown(XboxButton.Back, m_player1.GetComponent <Player>().controller) || XCI.GetButtonDown(XboxButton.Back, m_player2.GetComponent <Player>().controller))
            {
                m_controlsPanel.SetActive(true);
            }
        }
    }
    void Update()
    {
        transform.position = Vector3.MoveTowards(transform.position, buttonPositions[currentIndex].transform.position, 15);


        if (XCI.GetDPadDown(XboxDPad.Up, allContollers))
        {
            //shift down
            if (currentIndex > 0)
            {
                currentIndex--;
            }
        }


        if (XCI.GetDPadDown(XboxDPad.Down, allContollers))
        {
            //shift up
            if (currentIndex < buttonPositions.Count - 1)
            {
                currentIndex++;
            }
        }

        if (XCI.GetButtonDown(XboxButton.A, allContollers))
        {
            buttonPositions[currentIndex].GetComponent <Button>().onClick.Invoke();

            //reset all button Positons


            if (currentScene.buildIndex == 1)
            {
                gameObject.SetActive(false);
            }
            else
            {
                buttonPositions.Clear();
            }



            /*
             * for every menu panel
             * if the menu panel is active in scene
             * for every child of that menu panel that has children
             * add all children to the buttonPositions list
             *
             */

            for (int outerIndex = 0; outerIndex < menuButtonCollection.Length; outerIndex++)
            {
                if (menuButtonCollection[outerIndex].activeInHierarchy)
                {
                    for (int innerIndex = 0; innerIndex < menuButtonCollection[outerIndex].transform.GetChild(1).childCount; innerIndex++)
                    {
                        buttonPositions.Add(menuButtonCollection[outerIndex].transform.GetChild(1).GetChild(innerIndex).gameObject);
                    }
                }
            }



            currentIndex = 0;
        }



        //keyBoard Code
        if (Input.GetKeyDown(KeyCode.W))
        {
            //shift down
            if (currentIndex > 0)
            {
                currentIndex--;
            }
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            //shift up
            if (currentIndex < buttonPositions.Count - 1)
            {
                currentIndex++;
            }
        }
    }
Example #20
0
 public bool GetKeyDown(InputAlias alias, int inputIndex)
 {
     return(inputIndex == 0 ? Input.GetKeyDown(_keyboardButtons[alias]) : XCI.GetButtonDown(_xboxButtons[alias], inputIndex));
 }
Example #21
0
        public override void UpdateState()
        {
            // Triggers button down game events
            foreach (KeyValuePair <XboxButton, GameInputButton> entry in buttonMapper)
            {
                if (XCI.GetButtonDown(entry.Key, xboxControllerInputNumber))
                {
                    currentButtonState[entry.Value] = GameInputButtonState.Down;
                }
                else if (XCI.GetButton(entry.Key, xboxControllerInputNumber))
                {
                    currentButtonState[entry.Value] = GameInputButtonState.Pressed;
                }
            }

            // Special mapping for special mapper
            foreach (KeyValuePair <XboxAxis, GameInputButton> entry in specialMapper)
            {
                float triggerValue = XCI.GetAxis(entry.Key, xboxControllerInputNumber);

                if (triggerValue > 0 && previousTriggerState[entry.Key] == 0)
                {
                    currentButtonState[entry.Value] = GameInputButtonState.Down;
                }
                else if (XCI.GetAxis(entry.Key, xboxControllerInputNumber) > 0)
                {
                    currentButtonState[entry.Value] = GameInputButtonState.Pressed;
                }

                previousTriggerState[entry.Key] = triggerValue;
            }

            float[] leftStickValues  = new float[2];
            float[] rightStickValues = new float[2];

            // Triggers axis actions
            foreach (KeyValuePair <XboxAxis, GameInputAxis> entry in axisMapper)
            {
                switch (entry.Key)
                {
                case XboxAxis.LeftStickX:
                    leftStickValues[0] = XCI.GetAxis(XboxAxis.LeftStickX, xboxControllerInputNumber);
                    break;

                case XboxAxis.LeftStickY:
                    leftStickValues[1] = XCI.GetAxis(XboxAxis.LeftStickY, xboxControllerInputNumber);
                    break;

                case XboxAxis.RightStickX:
                    rightStickValues[0] = XCI.GetAxis(XboxAxis.RightStickX, xboxControllerInputNumber);
                    break;

                case XboxAxis.RightStickY:
                    rightStickValues[1] = XCI.GetAxis(XboxAxis.RightStickY, xboxControllerInputNumber);
                    break;
                }
            }

            // Updates the GameInput stick (axis) states
            currentStickState[GameInputStick.Left]  = leftStickValues;
            currentStickState[GameInputStick.Right] = rightStickValues;
        }
Example #22
0
    //--------------------------------------------------------------------------------------
    // Update is called once per frame.
    //--------------------------------------------------------------------------------------
    void Update()
    {
        // Spawns the second set of snowballs.
        if (!m_bDeathSnowballsSpawned && m_fDeathSnowballCount < m_fDeathSnowballTime)
        {
            m_fDeathSnowballCount += Time.deltaTime;
        }
        else if (!m_bDeathSnowballsSpawned && m_fDeathSnowballCount > m_fDeathSnowballTime)
        {
            for (int i = 0; i < m_goLstDeathSnowballLoc.Count; i++)
            {
                GameObject goSnowball = ObjectPool.m_SharedInstance.GetPooledObject();
                // Putting the snowballs into the list.
                goSnowball.transform.position = m_goLstDeathSnowballLoc[i].transform.position;
            }

            m_bDeathSnowballsSpawned = true;
        }

        // With all these random buttons are pressed the game quits, we are realising we should have removed this from the build.
        if (XCI.GetButton(XboxButton.A, controller) && XCI.GetButton(XboxButton.B, controller) && XCI.GetButton(XboxButton.X, controller) && XCI.GetButton(XboxButton.Y, controller) && XCI.GetButton(XboxButton.LeftBumper, controller) && XCI.GetButton(XboxButton.RightBumper, controller))
        {
            Application.Quit();
        }

        // If start and back are pressed, restart game.
        ResetGame();

        if (Input.GetKeyDown(KeyCode.Escape) || XCI.GetButtonDown(XboxButton.Start, controller))
        {
            // If you press start in the main menu or end round the pause menu won't show because it will just return out.
            if (SceneManager.GetActiveScene().name == "EndRound" || SceneManager.GetActiveScene().name == "Main Menu")
            {
                return;
            }

            // Access to the player so we can free their movement.
            Player scpPlayer = GameObject.FindObjectOfType <Player>().GetComponent <Player>();

            // After start is pressed if the pause canvas is inactive in the hierarchy set it to active.
            if (!m_goPauseCanvas.activeInHierarchy)
            {
                m_goPauseCanvas.SetActive(true);
                // Game time is frozen.
                Time.timeScale = 0;
                UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(m_btnFirstButton);

                // Game is paused so tell the player! currently only used to stop the player throwing the ball when the game is paused.
                scpPlayer.m_bGamePaused = true;

                // Player can't move.
                scpPlayer.m_bMovementLock = true;
            }
            // After start is pressed if the pause canvas is active in the hierarchy set it to inactive.
            else
            {
                m_goPauseCanvas.SetActive(false);
                // Game time is unfrozen.
                Time.timeScale = 1;
                UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(null);

                // Game is unpaused so tell the player! currently only used to stop the player throwing the ball when the game is paused.
                scpPlayer.m_bGamePaused = false;

                // Player can move again.
                scpPlayer.m_bMovementLock = false;
            }
        }
    }
    void menuStateUpdate()
    {
        //if the current gamestate is main menu
        if (CurrentGameState == GameState.MainMenu)
        {
            if (mainScreenMesh.activeInHierarchy == false)
            {
                mainScreenMesh.SetActive(true);
            }
            //if up or down is pressed switch current selected UI
            if ((Input.GetKeyDown(KeyCode.DownArrow) || XCI.GetButtonDown(XboxButton.DPadDown, XboxController.First) || XCI.GetAxisRaw(XboxAxis.LeftStickY, XboxController.First) > 0 || XCI.GetAxisRaw(XboxAxis.LeftStickY, XboxController.First) < 0 || Input.GetKeyDown(KeyCode.UpArrow) || XCI.GetButtonDown(XboxButton.DPadUp, XboxController.First)) && axisInUse == false)
            {
                axisInUse = true;
                if (currentControllerUISelection == ControllerUISelection.play)
                {
                    currentControllerUISelection = ControllerUISelection.exit;
                    UICrowm.transform.position  += new Vector3(0, -2.5f, 0);
                }
                else if (currentControllerUISelection == ControllerUISelection.exit)
                {
                    UICrowm.transform.position  += new Vector3(0, 2.5f, 0);
                    currentControllerUISelection = ControllerUISelection.play;
                }
                //Debug.Log(axisInUse);
            }

            if (XCI.GetAxisRaw(XboxAxis.LeftStickY, XboxController.First) == 0)
            {
                axisInUse = false;
            }

            //current selected ui is highlighted
            if (currentControllerUISelection == ControllerUISelection.play)
            {
                mainMenu.transform.GetChild(1).GetComponent <Button>().Select();
            }
            if (currentControllerUISelection == ControllerUISelection.exit)
            {
                mainMenu.transform.GetChild(2).GetComponent <Button>().Select();
            }

            //if enter or a is pressed select current highlighted ui
            if (Input.GetKeyDown(KeyCode.KeypadEnter) || XCI.GetButtonDown(XboxButton.A, XboxController.First))
            {
                if (currentControllerUISelection == ControllerUISelection.play)
                {
                    mainStartButton();
                }
                if (currentControllerUISelection == ControllerUISelection.exit)
                {
                    mainQuitButton();
                }
            }
        }

        // If the current game state is the Main Menu and Y is pressed.
        if (CurrentGameState == GameState.MainMenu)
        {
            if (Input.GetKeyDown(KeyCode.Y) || XCI.GetButtonDown(XboxButton.Y))
            {
                // Disable elements from the Main Menu.
                GameObject.FindGameObjectWithTag("MenuSlimeText").GetComponent <MeshRenderer>().enabled   = false;
                GameObject.FindGameObjectWithTag("MenuRedSlime").GetComponent <MeshRenderer>().enabled    = false;
                GameObject.FindGameObjectWithTag("MenuBlueSlime").GetComponent <MeshRenderer>().enabled   = false;
                GameObject.FindGameObjectWithTag("MenuYellowSlime").GetComponent <MeshRenderer>().enabled = false;
                GameObject.FindGameObjectWithTag("MenuPurpleSlime").GetComponent <MeshRenderer>().enabled = false;
                GameObject.FindGameObjectWithTag("MenuCrownLeft").GetComponent <MeshRenderer>().enabled   = false;
                GameObject.FindGameObjectWithTag("MenuCrownRight").GetComponent <MeshRenderer>().enabled  = false;
                GameObject.FindGameObjectWithTag("mainMenu").GetComponent <Canvas>().enabled = false;
                // Set current state to Credits.
                CurrentGameState = GameState.Credits;
                // Enable Credits canvas.
                GameObject.FindGameObjectWithTag("creditsScreen").GetComponent <Canvas>().enabled = true;
            }
        }

        // If the current game state is the Credits Screen and B is pressed.
        if (CurrentGameState == GameState.Credits)
        {
            if (Input.GetKeyDown(KeyCode.Backspace) || XCI.GetButtonDown(XboxButton.B))
            {
                // Disable elements from the Credits.
                GameObject.FindGameObjectWithTag("creditsScreen").GetComponent <Canvas>().enabled = false;
                // Set current state to Main Menu.
                CurrentGameState = GameState.MainMenu;
                // Enable Main Menu elements.
                GameObject.FindGameObjectWithTag("mainMenu").GetComponent <Canvas>().enabled              = true;
                GameObject.FindGameObjectWithTag("MenuSlimeText").GetComponent <MeshRenderer>().enabled   = true;
                GameObject.FindGameObjectWithTag("MenuRedSlime").GetComponent <MeshRenderer>().enabled    = true;
                GameObject.FindGameObjectWithTag("MenuBlueSlime").GetComponent <MeshRenderer>().enabled   = true;
                GameObject.FindGameObjectWithTag("MenuYellowSlime").GetComponent <MeshRenderer>().enabled = true;
                GameObject.FindGameObjectWithTag("MenuPurpleSlime").GetComponent <MeshRenderer>().enabled = true;
                GameObject.FindGameObjectWithTag("MenuCrownLeft").GetComponent <MeshRenderer>().enabled   = true;
                GameObject.FindGameObjectWithTag("MenuCrownRight").GetComponent <MeshRenderer>().enabled  = true;
            }
        }

        //if current game state is playerselect and enter or a is pressed and and there is more then one player
        if (CurrentGameState == GameState.PlayerSelect)
        {
            if (mainScreenMesh.activeInHierarchy == true)
            {
                mainScreenMesh.SetActive(false);
            }

            if (Input.GetKeyDown(KeyCode.KeypadEnter) || XCI.GetButtonDown(XboxButton.Start, XboxController.First))
            {
                if (gsm.controllers.Count > 1)
                {
                    //start the game
                    selectStartButton();
                }
            }
        }
    }
 public static bool AnyButtonAnyControll()
 {
     return(XCI.GetButtonDown(XboxButton.A | XboxButton.B | XboxButton.DPadDown |
                              XboxButton.DPadLeft | XboxButton.DPadRight | XboxButton.DPadUp | XboxButton.LeftBumper | XboxButton.LeftStick | XboxButton.RightBumper
                              | XboxButton.RightStick | XboxButton.Start | XboxButton.X | XboxButton.Y, XboxController.Any));
 }
Example #25
0
    // Update
    void Update()
    {
        GameObject bulletReference = null;

        // Jump (Left Stick)
        if (XCI.GetButtonDown(XboxButton.LeftStick, playerphys) && canJump)
        {
            canJump = false;
            GetComponent <Rigidbody>().AddRelativeForce(0.0f, jumpImpulse, 0.0f, ForceMode.Impulse);
        }

        // Slam (Right Stick)
        if (XCI.GetButtonDown(XboxButton.RightStick, playerphys) && !canJump)
        {
            GetComponent <Rigidbody>().AddRelativeForce(0.0f, (-jumpImpulse * 1.5f), 0.0f, ForceMode.Impulse);
        }


        // Shoot colored laser (A,B,X,Y)
        if (bulletTimer > 0.0f)
        {
            bulletTimer -= Time.deltaTime;
        }

        if (bulletTimer <= 0.0f)
        {
            if (XCI.GetButton(XboxButton.A, playerphys))
            {
                Instantiate(laserAPrefab, transform.position, laserAPrefab.transform.rotation);
                bulletTimer = MAX_BUL_TME;
            }
            if (XCI.GetButton(XboxButton.B, playerphys))
            {
                Instantiate(laserBPrefab, transform.position, laserBPrefab.transform.rotation);
                bulletTimer = MAX_BUL_TME;
            }
            if (XCI.GetButton(XboxButton.X, playerphys))
            {
                Instantiate(laserXPrefab, transform.position, laserXPrefab.transform.rotation);
                bulletTimer = MAX_BUL_TME;
            }
            if (XCI.GetButton(XboxButton.Y, playerphys))
            {
                Instantiate(laserYPrefab, transform.position, laserYPrefab.transform.rotation);
                bulletTimer = MAX_BUL_TME;
            }
        }

        // Left stick movement
        newPosition = transform.position;
        float axisX   = XCI.GetAxis(XboxAxis.LeftStickX, playerphys);
        float axisY   = XCI.GetAxis(XboxAxis.LeftStickY, playerphys);
        float newPosX = newPosition.x + (axisX * maxMoveSpeed * Time.deltaTime);
        float newPosZ = newPosition.z + (axisY * maxMoveSpeed * Time.deltaTime);

        newPosition        = new Vector3(newPosX, transform.position.y, newPosZ);
        transform.position = newPosition;


        // Right stick movement
        newPosition        = transform.position;
        axisX              = XCI.GetAxis(XboxAxis.RightStickX, playerphys);
        axisY              = XCI.GetAxis(XboxAxis.RightStickY, playerphys);
        newPosX            = newPosition.x + (axisX * maxMoveSpeed * 0.3f * Time.deltaTime);
        newPosZ            = newPosition.z + (axisY * maxMoveSpeed * 0.3f * Time.deltaTime);
        newPosition        = new Vector3(newPosX, transform.position.y, newPosZ);
        transform.position = newPosition;


        // D-Pad testing
        if (dpUpBulletTimer > 0.0f)
        {
            dpUpBulletTimer -= Time.deltaTime;
        }
        if (dpDownBulletTimer > 0.0f)
        {
            dpDownBulletTimer -= Time.deltaTime;
        }
        if (dpLeftBulletTimer > 0.0f)
        {
            dpLeftBulletTimer -= Time.deltaTime;
        }
        if (dpRightBulletTimer > 0.0f)
        {
            dpRightBulletTimer -= Time.deltaTime;
        }
        if (dpUpBulletTimer <= 0.0f)
        {
            if (XCI.GetDPad(XboxDPad.Up, playerphys))
            {
                bulletReference = Instantiate(laserBumpPrefab, transform.position, laserYPrefab.transform.rotation) as GameObject;
                bulletReference.transform.localScale = new Vector3(0.1f, 0.1f, 1.0f);
                dpUpBulletTimer = MAX_BUL_TME * 2;
            }
        }
        if (dpDownBulletTimer <= 0.0f)
        {
            if (XCI.GetDPad(XboxDPad.Down, playerphys))
            {
                bulletReference = Instantiate(laserBumpPrefab, transform.position, laserAPrefab.transform.rotation) as GameObject;
                bulletReference.transform.localScale = new Vector3(0.1f, 0.1f, 1.0f);
                dpDownBulletTimer = MAX_BUL_TME * 2;
            }
        }
        if (dpLeftBulletTimer <= 0.0f)
        {
            if (XCI.GetDPad(XboxDPad.Left, playerphys))
            {
                bulletReference = Instantiate(laserBumpPrefab, transform.position, laserXPrefab.transform.rotation) as GameObject;
                bulletReference.transform.localScale = new Vector3(0.1f, 0.1f, 1.0f);
                dpLeftBulletTimer = MAX_BUL_TME * 2;
            }
        }
        if (dpRightBulletTimer <= 0.0f)
        {
            if (XCI.GetDPad(XboxDPad.Right, playerphys))
            {
                bulletReference = Instantiate(laserBumpPrefab, transform.position, laserBPrefab.transform.rotation) as GameObject;
                bulletReference.transform.localScale = new Vector3(0.1f, 0.1f, 1.0f);
                dpRightBulletTimer = MAX_BUL_TME * 2;
            }
        }


        // Trigger input
        float trigSclX        = triggerLeftPrefab.transform.localScale.x;
        float trigSclZ        = triggerLeftPrefab.transform.localScale.z;
        float leftTrigHeight  = MAX_TRG_SCL * (1.0f - XCI.GetAxis(XboxAxis.LeftTrigger, playerphys));
        float rightTrigHeight = MAX_TRG_SCL * (1.0f - XCI.GetAxis(XboxAxis.RightTrigger, playerphys));

        triggerLeftPrefab.transform.localScale  = new Vector3(trigSclX, leftTrigHeight, trigSclZ);
        triggerRightPrefab.transform.localScale = new Vector3(trigSclX, rightTrigHeight, trigSclZ);


        // Bumper input
        if (XCI.GetButtonDown(XboxButton.LeftBumper, playerphys))
        {
            Instantiate(laserBumpPrefab, triggerLeftPrefab.transform.position, laserBumpPrefab.transform.rotation);
        }
        if (XCI.GetButtonDown(XboxButton.RightBumper, playerphys))
        {
            Instantiate(laserBumpPrefab, triggerRightPrefab.transform.position, laserBumpPrefab.transform.rotation);
        }


        // Start and back, same as bumpers but smaller bullets
        if (XCI.GetButtonUp(XboxButton.Back, playerphys))
        {
            bulletReference = Instantiate(laserBumpPrefab, triggerLeftPrefab.transform.position, laserBumpPrefab.transform.rotation) as GameObject;
            bulletReference.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
        }
        if (XCI.GetButtonUp(XboxButton.Start, playerphys))
        {
            bulletReference = Instantiate(laserBumpPrefab, triggerRightPrefab.transform.position, laserBumpPrefab.transform.rotation) as GameObject;
            bulletReference.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
        }


        // To quit the program (with keyboard)
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            Application.Quit();
        }
    }
Example #26
0
    /// Update is called once per frame
    void Update()
    {
        if (talking)
        {
            Debug.Log("ISTALKING");
            if (XCI.GetButtonDown(XboxButton.B))
            {
                TouristNumber++;
            }
            TouristDialogue.SetActive(true);
            pause = false;
            PlayerScript.CanMove = false;
        }
        if (pause == false)
        {
            PauseTimer -= Time.deltaTime;
            if (PauseTimer <= 0)
            {
                pause      = true;
                PauseTimer = 0.05f;
            }
        }

        switch (TouristNumber)
        {
        case 1:
        {
            if (TestPatience >= 4)
            {
                TouristNumber += 6;
            }
            if (HasTalkedToTourist && TestPatience <= 3)
            {
                TouristNumber += 4;
            }
            if (HasTalkedToTourist == false)
            {
                text.text = "Im not really sure how i ended up here";
            }
        }

        break;

        case 2:
        {
            text.text = "But it beats having to go to work so....";
        }

        break;

        case 3:
        {
            text.text          = "Why are you still looking at me?";
            HasTalkedToTourist = true;
        }

        break;

        case 4:
        {
            TouristDialogue.SetActive(false);
            PlayerScript.CanMove = true;
            TouristNumber        = 0;
            talking = false;
        }
        break;

        case 5:
        {
            text.text          = "Can you stop staring at me?!?";
            HasTalkedToTourist = true;
        }
        break;

        case 6:
        {
            TouristDialogue.SetActive(false);
            PlayerScript.CanMove = true;
            TouristNumber        = 0;
            TestPatience++;
            talking = false;
        }
        break;

        case 7:
        {
            text.text          = "You think you're funny huh?";
            HasTalkedToTourist = true;
        }
        break;

        case 8:
        {
            text.text          = "Bugging me on my accidental vacation";
            HasTalkedToTourist = true;
        }
        break;

        case 9:
        {
            text.text          = "Shame on you!";
            HasTalkedToTourist = true;
        }
        break;

        case 10:
        {
            TouristDialogue.SetActive(false);
            PlayerScript.CanMove = true;
            TouristNumber        = 0;
            talking = false;
        }
        break;
        }
    }
Example #27
0
    // Update is called once per frame
    void Update()
    {
        aScore.text = currScore.ToString();

        if (throwCooldown > 0)
        {
            throwCooldown -= Time.deltaTime;
        }
        else if (throwCooldown <= 0)
        {
            throwCooldown = 0;
        }

        //--------------------------------------------------
        // LEFT ANALOG STICK AIM
        //--------------------------------------------------

        Vector2 leftInput = new Vector2(XCI.GetAxisRaw(XboxAxis.LeftStickX, controller),
                                        XCI.GetAxisRaw(XboxAxis.LeftStickY, controller));



        if (leftInput.x != 0 || leftInput.y != 0)
        {
            aim.x = leftInput.x;
            aim.y = 0;
            aim.z = leftInput.y;
            aim.Normalize();

            Vector3 up = new Vector3(0, 0.2f);

            Debug.DrawRay(this.transform.position + up, aim);
        }

        if ((throwCooldown <= 0 && sr_cook.doneChopping) &&
            ((XCI.GetButtonDown(XboxButton.LeftBumper, controller)) || (XCI.GetButtonDown(XboxButton.RightBumper, controller))))
        {
            if (initiateCharge)
            {
                if (throwCharge <= 0.9f)
                {
                    throwCharge = Mathf.Clamp(throwCharge, 0.55f, 0.9f);
                    ThrowFood(currentFood, throwPos.position, throwAngle, throwForce * throwCharge);
                }

                if (throwCharge > 0.9f && throwCharge <= 1.35f)
                {
                    throwCharge = Mathf.Clamp(throwCharge, 0.9f, 1.3f);
                    ThrowFood(currentFood, throwPos.position, throwAngle, throwForce * throwCharge);
                }

                if (throwCharge > 1.35f)
                {
                    throwCharge = Mathf.Clamp(throwCharge, 1.35f, 1.4f);
                    ThrowFood(currentFood, throwPos.position, throwAngle, throwForce * throwCharge);
                }
            }

            else
            {
                initiateCharge = true;

                if (currentFood != null)
                {
                    canThrow = true;
                }
            }
        }

        else if (leftInput.x == 0 || leftInput.y == 0)
        {
            ResetAim();
        }

        if (initiateCharge)
        {
            throwCharge += Time.deltaTime;
        }
    }
Example #28
0
 public virtual bool CanCast(XboxController controller)
 {
     return(XCI.GetButtonDown(activationButton, controller));
 }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            SceneManager.LoadScene(0);
        }

        if (Input.GetKey(KeyCode.LeftShift) == false)
        {
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                SetColor(0);
            }
            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                SetColor(1);
            }
            if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                SetColor(2);
            }
            if (Input.GetKeyDown(KeyCode.Alpha4))
            {
                SetColor(3);
            }
            if (Input.GetKeyDown(KeyCode.Alpha5))
            {
                SetColor(4);
            }
            if (Input.GetKeyDown(KeyCode.Alpha6))
            {
                SetColor(5);
            }
            if (Input.GetKeyDown(KeyCode.Alpha7))
            {
                SetColor(6);
            }
            if (Input.GetKeyDown(KeyCode.Alpha8))
            {
                SetColor(7);
            }
            if (Input.GetKeyDown(KeyCode.Alpha9))
            {
                SetColor(8);
            }
            if (Input.GetKeyDown(KeyCode.Alpha0))
            {
                SetColor(9);
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                SetColor(10);
            }
            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                SetColor(11);
            }
            if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                SetColor(12);
            }
            if (Input.GetKeyDown(KeyCode.Alpha4))
            {
                SetColor(13);
            }
            if (Input.GetKeyDown(KeyCode.Alpha5))
            {
                SetColor(14);
            }
            if (Input.GetKeyDown(KeyCode.Alpha6))
            {
                SetColor(15);
            }
            if (Input.GetKeyDown(KeyCode.Alpha7))
            {
                SetColor(16);
            }
            if (Input.GetKeyDown(KeyCode.Alpha8))
            {
                SetColor(17);
            }
            if (Input.GetKeyDown(KeyCode.Alpha9))
            {
                SetColor(18);
            }
            if (Input.GetKeyDown(KeyCode.Alpha0))
            {
                SetColor(19);
            }
        }

        // Left Bumper/Trigger

        bbc.ScreenShakeAmount = XCI.GetAxis(XboxAxis.LeftTrigger) * 3;
        if (XCI.GetButtonDown(XboxButton.LeftBumper) || Input.GetKeyDown(KeyCode.O))
        {
            bbc.SnapToStraight = !bbc.SnapToStraight;
        }

        // Right Bumper/Trigger
        CubeTunnle.RandomRotationSpeedMultiplier = 1f - XCI.GetAxis(XboxAxis.RightTrigger);
        if (XCI.GetButtonDown(XboxButton.RightBumper))
        {
            bbc.InvertColours = !bbc.InvertColours;
        }

        // Left Stick
        bbc.ForwardSpeed        += XCI.GetAxis(XboxAxis.LeftStickY) * Time.deltaTime * 15;
        bbc.DigitalGlitchAmount += XCI.GetAxis(XboxAxis.LeftStickX) * Time.deltaTime * 1f;
        if (XCI.GetButtonDown(XboxButton.LeftStick))
        {
            bbc.MotionBlur = !bbc.MotionBlur;
        }

        // Right Stick
        bbc.Size     += XCI.GetAxis(XboxAxis.RightStickY) * Time.deltaTime * 0.33f;
        bbc.Size      = Mathf.Clamp01(bbc.Size);
        bbc.Fidelity += XCI.GetAxis(XboxAxis.RightStickX) * Time.deltaTime * 0.33f;
        bbc.Fidelity  = Mathf.Clamp01(bbc.Fidelity);
        if (XCI.GetButtonDown(XboxButton.RightStick))
        {
            bbc.ScaleFlashesAmount = bbc.ScaleFlashesAmount == 0 ? 1 : 0;
        }


        // DPAD
        if (XCI.GetButtonDown(XboxButton.DPadLeft))
        {
            bbc.AnalogGlitchVertJump = bbc.AnalogGlitchVertJump == 0 ? 1 : 0;
        }
        if (XCI.GetButtonDown(XboxButton.DPadDown))
        {
            bbc.AnalogGlitchAmount = bbc.AnalogGlitchAmount == 0 ? 1 : 0;
        }
        if (XCI.GetButtonDown(XboxButton.DPadRight))
        {
            bbc.AnalogGlitchColor = bbc.AnalogGlitchColor == 0 ? 1 : 0;
        }
        if (XCI.GetButtonDown(XboxButton.DPadUp))
        {
            bbc.AnalogGlitchVertJump = 0;
            bbc.AnalogGlitchAmount   = 0;
            bbc.AnalogGlitchColor    = 0;
        }

        // Action Buttons

        // NOTEL: The "A" and "B" button are in the Beat Finder class!!
        if (XCI.GetButtonDown(XboxButton.Y))
        {
            bbc.CameraPerspectiveToggle = !bbc.CameraPerspectiveToggle;
        }

        if (XCI.GetButtonDown(XboxButton.X))
        {
            bbc.OceanToggle = !bbc.OceanToggle;
        }

        // Start/Select
        if (XCI.GetButtonDown(XboxButton.Start))
        {
            bbc.OrthCameraZoomToggle = !bbc.OrthCameraZoomToggle;
        }
        if (XCI.GetButtonDown(XboxButton.Back))
        {
            bbc.Edges = !bbc.Edges;
        }

        // Keyboard

        if (Input.GetKey(KeyCode.T))
        {
            BeatFinder.beatStartTimeOffsetHack -= Time.deltaTime * 0.33f;
        }
        if (Input.GetKey(KeyCode.Y))
        {
            BeatFinder.beatStartTimeOffsetHack += Time.deltaTime * 0.33f;
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            tunnleControl.pulseRather = !tunnleControl.pulseRather;
        }

        if (Input.GetKey(KeyCode.Q))
        {
            tunnleControl.flashChanceAdd -= Time.deltaTime * 0.33f;
        }
        if (Input.GetKey(KeyCode.W))
        {
            tunnleControl.flashChanceAdd = 0;
        }
        if (Input.GetKey(KeyCode.E))
        {
            tunnleControl.flashChanceAdd += Time.deltaTime * 0.33f;
        }

        if (Input.GetKey(KeyCode.Tab))
        {
            tunnleControl.flashChanceAdd = -tunnleControl.FlashChanceBase + 0.05f;
        }

        if (Input.GetKey(KeyCode.A))
        {
            tunnleControl.offsetAdd -= Time.deltaTime * 0.33f;
        }
        if (Input.GetKey(KeyCode.S))
        {
            tunnleControl.offsetAdd = 0;
        }
        if (Input.GetKey(KeyCode.D))
        {
            tunnleControl.offsetAdd += Time.deltaTime * 0.33f;
        }

        if (Input.GetKey(KeyCode.Z))
        {
            tunnleControl.twistAdd -= Time.deltaTime * 0.33f;
        }
        if (Input.GetKey(KeyCode.X))
        {
            tunnleControl.twistAdd = 0;
        }
        if (Input.GetKey(KeyCode.C))
        {
            tunnleControl.twistAdd += Time.deltaTime * 0.33f;
        }
    }
Example #30
0
 static public bool GamePadButtonDown(XboxController controller, XboxButton button)
 {
     return(XCI.GetButtonDown(button, controller));
 }