Exemplo n.º 1
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* Redefined Method: Update
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    void Update()
    {
        XboxInputHandler.UpdateInput();

        if (XboxInputHandler.KeyTriggered(XboxInputHandler.Controls.DPad_Up))
        {
            UICamera.selectedObject = GetUpperButton();
        }
        else if (XboxInputHandler.KeyTriggered(XboxInputHandler.Controls.DPad_Down))
        {
            UICamera.selectedObject = GetBelowButton();
        }

        // If B is Pressed, NGUI Button Selection gets disabled. This Stops that.
        if (XboxInputHandler.KeyPressed(XboxInputHandler.Controls.B))
        {
            UICamera.selectedObject = m_SelectedObject;
        }
        m_SelectedObject = UICamera.selectedObject;
    }
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Update Pause Input
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private void UpdatePauseInput()
    {
        // Update Vignette Alpha
        m_UIObjects.VignetteObject.GetComponent <UISprite>().alpha = Mathf.Abs(Mathf.Cos(Time.realtimeSinceStartup * 0.8f));

        if (m_PauseTrigger.Keys != null)
        {
            foreach (KeyCode Key in m_PauseTrigger.Keys)
            {
                if (Input.GetKey(Key))
                {
                    m_PauseTrigger.Paused  = false;
                    m_PauseTrigger.JoyAxis = null;
                    m_PauseTrigger.Keys    = null;
                    Time.timeScale         = 1.0f;
                    GameHandler.SetPausedGame(false);
                    GameHandler.SetDialogueBoxPaused(false);
                    m_UIObjects.VignetteObject.GetComponent <UISprite>().alpha = 0.0f;
                    return;
                }
            }
        }

        if (m_PauseTrigger.JoyAxis != null)
        {
            foreach (XboxInputHandler.Controls Axis in m_PauseTrigger.JoyAxis)
            {
                if (XboxInputHandler.KeyTriggered(Axis))
                {
                    m_PauseTrigger.Paused  = false;
                    m_PauseTrigger.JoyAxis = null;
                    m_PauseTrigger.Keys    = null;
                    Time.timeScale         = 1.0f;
                    GameHandler.SetPausedGame(false);
                    GameHandler.SetDialogueBoxPaused(false);
                    m_UIObjects.VignetteObject.GetComponent <UISprite>().alpha = 0.0f;
                    return;
                }
            }
        }
    }
Exemplo n.º 3
0
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //	* New Method: Has Pressed Pause?
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 private bool PressedPause()
 {
     return(Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.P) || XboxInputHandler.KeyTriggered(XboxInputHandler.Controls.Start));
 }
    // Update is called once per frame
    void Update()
    {
        m_Velocity = new Vector3(0, 0, 0);

        MovePlayer();

        GetInput();

        RollShip();

        //CameraFollow();

        if (m_bIsShot)
        {
            m_fHitTimer += DynamicUpdateManager.GetDeltaTime();
        }

        if (m_fHitTimer > m_fHitReset)
        {
            m_bIsShot = false;
            gameObject.GetComponent <Animator>().SetBool("PlayerHit", m_bIsShot);
            m_fHitTimer = 0;
        }

        if (m_bDead)
        {
            deathTimer += DynamicUpdateManager.GetDeltaTime();
        }

        if (m_bBrainBugged)
        {
            m_fBBTimer += DynamicUpdateManager.GetDeltaTime();

            if (m_fBBTimer > m_fBBResetTime)
            {
                SetBugged(false);
            }
        }

        if (Input.GetKey(KeyCode.Escape))
        {
            GameHandler.Quit();
        }


        if (m_fCollTimer > m_fCollReset)
        {
            gameObject.GetComponent <Collider>().enabled = true;
        }
        /////////////////////////////////////////////////////

        //Controls the state of the rolling ship
        if (m_bRollingLeft || m_bRollingRight)
        {
            m_fRollTimer += DynamicUpdateManager.GetDeltaTime();
        }

        if (m_fRollTimer > 0.5)
        {
            m_bRollingLeft        = false;
            targetAim.m_bRollLeft = false;
            gameObject.GetComponent <Animator>().SetBool("RollingLeft", m_bRollingLeft);
            m_bRollingRight        = false;
            targetAim.m_bRollRight = false;
            gameObject.GetComponent <Animator>().SetBool("RollingRight", m_bRollingRight);
            m_fRollTimer     = 0f;
            m_fMoveMultipier = 0f;
        }

        //Rolls the ship left or right based on input
        if (Input.GetKey(KeyCode.Q))
        {
            RollShipLeft();
        }
        else if (Input.GetKey(KeyCode.E))
        {
            RollShipRight();
        }

        //////////////////////////////////////////////////////////////////////////
        //Read the buttons used to pick up shooting a bullet or missile
        //Only shoots as fast as you can press
        //////////////////////////////////////////////////////////////////////////
        if (Input.GetKeyDown(KeyCode.Space) || XboxInputHandler.KeyTriggered(m_aFireTriggerAxis))
        {
            ShootBullet();
        }
    }