void ReadStates()
        {
            CustomInput customInput = CustomInput.Instance;

            this.ReadCameraInput();

            m_ped.MouseScrollInput = Input.mouseScrollDelta;


            m_ped.IsAimOn  = customInput.GetButton("RightClick");
            m_ped.IsFireOn = customInput.GetButton("LeftClick");

            m_ped.IsJumpOn = customInput.GetButton("Jump");


            Vector3 inputMove = Vector3.zero;

            if (m_smoothMovement)
            {
                inputMove = new Vector3(customInput.GetAxis("Horizontal"), 0f, customInput.GetAxis("Vertical"));
            }
            else
            {
                inputMove = new Vector3(customInput.GetAxisRaw("Horizontal"), 0f, customInput.GetAxisRaw("Vertical"));
            }

            if (inputMove.sqrMagnitude > 0f)
            {
                inputMove.Normalize();

                if (customInput.GetButton("Walk"))
                {
                    m_ped.IsWalkOn = true;
                }
                else if (customInput.GetButton("Sprint"))
                {
                    m_ped.IsSprintOn = true;
                }
                else
                {
                    m_ped.IsRunOn = true;
                }
            }

            if (m_ped.Camera != null)
            {
                m_ped.Movement = m_ped.Camera.transform.TransformVector(inputMove).normalized;
            }
            else
            {
                m_ped.Movement = inputMove.normalized;
            }

            if (m_ped.Movement.sqrMagnitude > float.Epsilon)
            {
                // only assign heading if there is any movement - we don't want the heading to be zero vector
                m_ped.Heading = m_ped.Movement;
            }
        }
예제 #2
0
    private void HandleFiring()
    {
        if (GameScript.instance.controllerState == GameScript.ControllerState.Player && GameScript.instance.isAlive && canFire && CustomInput.GetButton("Fire1"))
        {
            GameObject  newBullet          = Instantiate(this.laserBulletTemp);
            Rigidbody2D newBulletRigidBody = newBullet.GetComponent <Rigidbody2D>();
            // Set position
            newBullet.transform.position = this.laserLocation.transform.position;
            // Set velocity and direction
            newBulletRigidBody.velocity = Vector2.up * laserBulletSpeed;

            if (isPower1Active)
            {
                GameObject  rightBullet          = Instantiate(this.laserBulletTemp, this.gunRight.transform.position, gunRight.transform.rotation);
                Rigidbody2D rightBulletRigidBody = rightBullet.GetComponent <Rigidbody2D>();
                rightBulletRigidBody.velocity = gunRight.transform.rotation * Vector2.up * laserBulletSpeed;

                GameObject  leftBullet          = Instantiate(this.laserBulletTemp, this.gunLeft.transform.position, gunLeft.transform.rotation);
                Rigidbody2D leftBulletRigidBody = leftBullet.GetComponent <Rigidbody2D>();
                leftBulletRigidBody.velocity = gunLeft.transform.rotation * Vector2.up * laserBulletSpeed;
            }

            Debug.Log(gunLeft.transform.rotation.eulerAngles.z);

            // Create a bullet sound
            if (this.laserBulletSound != null)
            {
                Instantiate(this.laserBulletSound);
            }

            StartCoroutine(DisableFire(1f / fireRatePerSeconds));
        }
    }