public override void Update()
    {
        if (Input.GetButton("Reset"))
        {
            // if we are on android, kill the game
            if (Application.platform == RuntimePlatform.Android)
            {
                Application.Quit();
            }

            OnDeath();
            return;
        }

        if (m_physics.Direction != 0)
        {
            m_standingStillTime = Time.time * 1000.0f;
        }


        if (m_playerState == PlayerState.FallingFromTower)
        {
            return;
        }

        m_physics.OnUpdate(ref m_playerState);
    }
    public override void Update()
    {
        // only allow dev cheats in the editor

        /*if (Application.isEditor && CurrentGameState != GameState.Paused)
         * {
         *      if (Input.GetButton("CheckpointNext") && !m_isCheckpointSkipDown)
         *      {
         *              m_isCheckpointSkipDown = true;
         *
         *              if (m_lastCheckpoint != null && m_lastCheckpoint.NextCheckPoint != null)
         *              {
         *                      m_lastCheckpoint = m_lastCheckpoint.NextCheckPoint;
         *              }
         *              OnDeath();
         *              return;
         *      }
         *      else if (m_isCheckpointSkipDown && !Input.GetButton("CheckpointNext"))
         *      {
         *              m_isCheckpointSkipDown = false;
         *      }
         * }*/

        if (Input.GetButton("Reset") && !m_isEscapeDown)
        {
            m_isEscapeDown = true;
            if (CurrentGameState == GameState.Running)
            {
                CurrentGameState = GameState.Paused;
                Time.timeScale   = 0.0f;
            }

            return;
        }
        else if (m_isEscapeDown && !Input.GetButton("Reset"))
        {
            m_isEscapeDown = false;
        }

        if (m_playerState == PlayerState.InCutScene)
        {
            return;
        }

        if (m_playerState == PlayerState.FallingFromTower)
        {
            return;
        }

        m_physics.OnUpdate(ref m_playerState);
    }
示例#3
0
    public override void Update()
    {
        if (Input.GetButton("CheckpointNext") && !m_isCheckpointSkipDown)
        {
            m_isCheckpointSkipDown = true;

            if (m_lastCheckpoint != null && m_lastCheckpoint.NextCheckPoint != null)
            {
                m_lastCheckpoint = m_lastCheckpoint.NextCheckPoint;
            }
            OnDeath();
            return;
        }
        else if (m_isCheckpointSkipDown && !Input.GetButton("CheckpointNext"))
        {
            m_isCheckpointSkipDown = false;
        }

        if (Input.GetButton("Reset") && !m_isEscapeDown)
        {
            m_isEscapeDown = true;
            if (CurrentGameState == GameState.Running)
            {
                CurrentGameState = GameState.Paused;
                Time.timeScale   = 0.0f;
            }

            return;
        }
        else if (m_isEscapeDown && !Input.GetButton("Reset"))
        {
            m_isEscapeDown = false;
        }

        if (m_playerState == PlayerState.FallingFromTower)
        {
            return;
        }

        m_physics.OnUpdate(ref m_playerState);
    }
    /*
     * \brief Called once per frame
     */
    public override void Update()
    {
        m_physics.OnUpdate(ref m_playerState);

        m_playerPositionAlpha -= m_physics.Velocity;

        m_position = new Vector3(
            Mathf.Sin(m_playerPositionAlpha * Mathf.Deg2Rad) * PlayerPathRadius,
            transform.position.y,
            Mathf.Cos(m_playerPositionAlpha * Mathf.Deg2Rad) * PlayerPathRadius
            );

        // Handle wall jumping.
        m_wallJump.onUpdate(ref m_physics, ref m_playerState);

        //position the lookat
        Vector3 lookat = new Vector3(0.0f, transform.position.y, 0.0f);

        m_cameraClass.TendToMaxOffset(m_physics.Direction);

        float cameraAlpha = (m_playerPositionAlpha - m_cameraClass.CameraOffset) * Mathf.Deg2Rad;

        // position the camera
        Vector3 camPostion = new Vector3(
            Mathf.Sin(cameraAlpha) * (m_cameraClass.DistanceFromPlayer + PlayerPathRadius),
            transform.position.y,
            Mathf.Cos(cameraAlpha) * (m_cameraClass.DistanceFromPlayer + PlayerPathRadius)
            );

        m_cameraClass.SetPosition(camPostion);
        m_cameraClass.SetLookAt(lookat);

        base.Update();

        if (m_physics.Direction >= 0)
        {
            this.transform.GetChild(0).transform.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0));
        }
        else if (m_physics.Direction < 0)
        {
            this.transform.GetChild(0).transform.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y - 90, 0));
        }

        // move animation stuff to a class
        if (m_playerState == PlayerState.Walking)
        {
            if (!m_animation.IsPlaying("walk"))
            {
                m_animation.CrossFade("walk", 0.25f);
            }
            m_animation["walk"].speed = Mathf.Abs(m_physics.Velocity) * 2.0f;

            if (!m_footSteps.isPlaying)
            {
                m_footSteps.Play();
            }
        }
        else if (m_playerState == PlayerState.Standing)
        {
            if (!m_animation.IsPlaying(m_idleAnimations[m_idleAnimID]))
            {
                m_animation.CrossFade(m_idleAnimations[m_idleAnimID]);
                m_idleAnimID = Random.Range(0, 4);
            }

            if (!m_footSteps.isPlaying)
            {
                m_footSteps.Stop();
            }
        }
        else if (m_playerState == PlayerState.Jumping)
        {
            if (!m_animation.IsPlaying("jump"))
            {
                m_animation.CrossFade("jump");
            }

            if (!m_footSteps.isPlaying)
            {
                m_footSteps.Stop();
            }
        }

        //debug scene reset - probably want this somewhere else (also worth being able to toggle debug controls on and off)
        if (Input.GetKeyDown(KeyCode.F5))
        {
            OnDeath();
        }
    }
示例#5
0
 public override void Update()
 {
     m_physics.OnUpdate(ref m_playerState);
 }