Пример #1
0
    private void SpiritStart()
    {
        m_SpiritMode = true;
        m_StaminaComponent.UseStamina(10f * Time.deltaTime);

        SpiritStartFeedback();
    }
Пример #2
0
    private void CharacterMovement()
    {
        float l_Horizontal = Input.GetAxisRaw("Horizontal");
        float l_Vertical   = Input.GetAxisRaw("Vertical");

        Vector3 l_Direction = new Vector3(l_Horizontal, 0f, l_Vertical).normalized;

        if (l_Direction != Vector3.zero)
        {
            m_PlayerAnim.SetBool("IsMoving", true);
        }
        else
        {
            m_PlayerAnim.SetBool("IsMoving", false);
        }

        if (Input.GetButton("Glide") && m_StaminaComponent.CurrentStamina >= 0 /* Input.GetKey(KeyCode.LeftShift)*/)
        {
            l_Direction = m_PlayerGliding.Glide(m_Camera, m_Controller, l_Direction);
            m_PlayerAnim.SetBool("IsGliding", true);
            m_Cloth.material = m_GlowMaterial;
            m_Pagne.material = m_GlowMaterial;
            //foreach (var clothToReplace in m_Cloth)
            //{
            //    clothToReplace.material = m_GlowMaterial;
            //}
            m_StaminaComponent.UseStamina(10f * Time.deltaTime);
            foreach (ParticleSystem glideParticle in m_GlideParticle)
            {
                glideParticle.Play();
            }
        }
        else if (Input.GetButtonUp("Glide"))
        {
            m_PlayerGliding.GlideSpeed = 0;
            m_PlayerWallGliding.EndWallGlide();
            m_PlayerAnim.SetBool("IsGliding", false);
            //for (int i = 0; i < m_Cloth.Length; i++)
            //{
            //    m_Cloth[i].material = m_SavedMaterial[i];
            //}
            m_Cloth.material = m_ClothSavedMaterial;
            m_Pagne.material = m_PagneSavedMaterial;

            foreach (ParticleSystem glideParticle in m_GlideParticle)
            {
                glideParticle.Stop();
            }
        }
        else
        {
            l_Direction = m_PlayerWalking.Walk(m_Camera, m_Controller, l_Direction);
        }

        if (!m_PlayerWallGliding.IsWallGliding())
        {
            // Apply gravity to the velocity
            float gravityDownForce = 0f;
            if (!Input.GetButton("Glide"))
            {
                gravityDownForce = -30f;
            }
            else if (Input.GetButton("Glide"))
            {
                gravityDownForce = -10f;
            }
            m_CharacterVelocityY += gravityDownForce * Time.deltaTime;

            // Apply Y velocity to move vector
            l_Direction.y = m_CharacterVelocityY;
        }
        else
        {
            l_Direction += m_PlayerWallGliding.WallGlideGravity;
        }

        // Apply momentum
        l_Direction += m_CharacterVelocityMomentum;
        // Move Character Controller
        m_Controller.Move(l_Direction * Time.deltaTime);

        // Dampen momentum
        if (m_CharacterVelocityMomentum.magnitude > 0f)
        {
            float momentumDrag = 3f;
            m_CharacterVelocityMomentum -= m_CharacterVelocityMomentum * momentumDrag * Time.deltaTime;
            if (m_CharacterVelocityMomentum.magnitude < 1f)
            {
                m_CharacterVelocityMomentum = Vector3.zero;
            }
        }
    }