Exemple #1
0
 public void Prone()
 {
     m_stanceState = StanceState.Prone;
     m_animator.SetInteger("MoveState", (int)m_stanceState);
 }
Exemple #2
0
 public void Stand()
 {
     m_stanceState = StanceState.Standing;
     m_animator.SetInteger("MoveState", (int)m_stanceState);
 }
Exemple #3
0
 public void Crouch()
 {
     m_stanceState = StanceState.Crouching;
     m_animator.SetInteger("MoveState", (int)m_stanceState);
 }
Exemple #4
0
 private void OnProneStop()
 {
     this.stanceState = StanceState.Stand;
 }
Exemple #5
0
 private void OnProneStart()
 {
     this.stanceState = StanceState.Prone;
 }
Exemple #6
0
 private void OnCrouchStop()
 {
     this.stanceState = StanceState.Stand;
 }
Exemple #7
0
 private void OnCrouchStart()
 {
     this.stanceState = StanceState.Crouch;
 }
    // Update Event
    void Update()
    {
        // Movement
        player_velocity.x = 0f;
        if (player_control)
        {
            // Gun Button Press & Gun Stance
            if (Input.GetMouseButton(1))
            {
                gun_transition = Mathf.Lerp(gun_transition, 1f, stance_transition_spd * Time.deltaTime);
                if (gun_transition > 0.7f)
                {
                    stance = StanceState.gun;
                }
            }
            else
            {
                gun_transition = Mathf.Lerp(gun_transition, 0f, stance_transition_spd * Time.deltaTime);
            }

            // Player Key Movement
            if (gun_transition > 0.8f)
            {
                // Gun Control
            }
            else if (gun_transition < 0.3f)
            {
                // Moving Left and Right
                if (Input.GetKey(KeyCode.A))
                {
                    player_velocity.x = -spd;
                }
                else if (Input.GetKey(KeyCode.D))
                {
                    player_velocity.x = spd;
                }

                // Jumping (Jumping won't be in the game it's just here to test the physics)
                if (grounded)
                {
                    if (Input.GetKeyDown(KeyCode.W))
                    {
                        jumped     = true;
                        grounded   = false;
                        velocity.y = jump_spd;

                        sprite_stretch = new Vector2(0.7f, 1.3f);
                    }
                }
            }

            // Sword Stances
            Vector2 mouse_position = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            float   mouse_angle    = Mathf.Atan2(mouse_position.y - (transform.position.y + stance_mouse_yoffset), mouse_position.x - transform.position.x) * Mathf.Rad2Deg;
            if (Mathf.Abs(90 - mouse_angle) < stance_mouse_angle)
            {
                stance_transition = Mathf.Lerp(stance_transition, 1f, stance_transition_spd * Time.deltaTime);
                if (Mathf.Abs(stance_transition - 1f) < 0.5f && gun_transition < 0.3f)
                {
                    stance = StanceState.up;
                }
            }
            else if (Mathf.Abs(-90 - mouse_angle) < stance_mouse_angle)
            {
                stance_transition = Mathf.Lerp(stance_transition, -1f, stance_transition_spd * Time.deltaTime);
                if (Mathf.Abs(stance_transition + 1f) < 0.5f && gun_transition < 0.3f)
                {
                    stance = StanceState.down;
                }
            }
            else
            {
                stance_transition = Mathf.Lerp(stance_transition, 0f, stance_transition_spd * Time.deltaTime);
                if (Mathf.Abs(stance_transition) < 0.5f && gun_transition < 0.3f)
                {
                    stance = StanceState.center;
                }
            }
        }

        // Squash and Stretch
        transform.localScale = new Vector3(sprite_stretch.x, sprite_stretch.y, transform.localScale.z);
        sprite_stretch       = Vector2.Lerp(sprite_stretch, Vector2.one, Time.deltaTime * 5f);
    }