示例#1
0
    void Update()
    {
        aim = Input.GetButton("Fire2");
        if (aim)
        {
            if (Input.GetMouseButton(0) && m_reloadCounter > m_ReloadTime)
            {
                if (currentArrowForce < maxBowLoadupDuration)
                {
                    currentArrowForce += Time.deltaTime;
                }
            }
            else
            {
                m_reloadCounter += Time.deltaTime;
            }
            if (Input.GetButtonUp("Fire1"))
            {
                anim.SetTrigger("Fire");

                GameObject             arrow        = (GameObject)Instantiate(m_arrow, m_arrowSpawnpoint.position, m_player.GetComponent <Transform>().rotation);
                scr_projectileMovement projMovement = arrow.GetComponent <scr_projectileMovement>();
                projMovement.OnProjectileSpawn();
                projMovement.SetProjectileOriginator(this.gameObject);
                Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0.0f));
                //projMovement.AddVelocity(ray.direction, m_projectileSpeed + m_rgd.velocity);
                Rigidbody arrowRgd = arrow.GetComponent <Rigidbody>();
                arrowRgd.AddForce((ray.direction) * (m_projectileSpeed + (currentArrowForce * bowAccumulationMultiplier)), ForceMode.Impulse);
                m_reloadCounter   = 0;
                currentArrowForce = 0;
            }
        }
        else
        {
            m_reloadCounter += Time.deltaTime;
        }
    }
示例#2
0
    private void Update()
    {
        CheckClimbViability();
        ClimbingJump();
        WallClimbing();


        if (Input.GetButtonDown("ChangeEquippedArrow"))
        {
            print("ChangeEquippedArrow" + ropeAttachedToArrow);

            if (ropeAttachedToArrow == true)
            {
                ropeAttachedToArrow = false;
            }
            else
            {
                ropeAttachedToArrow = true;
            }
        }
        if (!m_Jump)
        {
            m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
        }
        if (Input.GetKey(KeyCode.T))
        {
            m_psm.SetPlayerPose(scr_PSM.PlayerPose.pose_wallclimbing);
        }
        else
        {
            m_sliding = false;
        }


        aim = Input.GetAxisRaw("AimAxis") > 0;  //Controller
        //  aim = Input.GetMouseButton(1);

        if (aim)
        {
            if (Input.GetMouseButtonDown(1))
            {
                m_audioManager.PlayDrawBow();
            }
            if (Input.GetMouseButton(0) && m_reloadCounter > m_ReloadTime)
            {
                print("AIM");
            }
            if (Input.GetAxisRaw("FireAxis") > 0) //load the bow
            {
                arrowIsLoaded = true;
                if (currentArrowForce < maxBowLoadupDuration)
                {
                    currentArrowForce += Time.deltaTime;
                }
            }
            else
            {
                m_reloadCounter += Time.deltaTime; // nothing happens
            }
            if (arrowIsLoaded)
            {
                if (Input.GetAxisRaw("FireAxis") == 0 && m_reloadCounter > m_ReloadTime)
                {
                    if (ropeAttachedToArrow)
                    {
                        //   anim.SetTrigger("Fire");
                        GameObject             arrow        = (GameObject)Instantiate(m_arrowPrefab, m_arrowSpawnpoint.position, m_player.GetComponent <Transform>().rotation);
                        scr_projectileMovement projMovement = arrow.GetComponent <scr_projectileMovement>();
                        projMovement.SetRopeAttachedToArrow(ropeAttachedToArrow);
                        projMovement.OnProjectileSpawn();
                        projMovement.SetProjectileOriginator(this.gameObject);
                        Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0.0f));
                        //projMovement.AddVelocity(ray.direction, m_projectileSpeed + m_rgd.velocity);
                        Rigidbody arrowRgd = (Rigidbody)arrow.GetComponent <Rigidbody>();
                        arrowRgd.AddForce((ray.direction * (m_projectileSpeed + (currentArrowForce * bowAccumulationMultiplier))), ForceMode.Impulse);
                        m_reloadCounter   = 0;
                        currentArrowForce = 0;
                        arrowIsLoaded     = false;
                    }
                    else
                    {
                        GameObject             arrow        = (GameObject)Instantiate(m_arrowPrefab, m_arrowSpawnpoint.position, m_player.GetComponent <Transform>().rotation);
                        scr_projectileMovement projMovement = arrow.GetComponent <scr_projectileMovement>();
                        projMovement.SetRopeAttachedToArrow(ropeAttachedToArrow);
                        projMovement.OnProjectileSpawn();
                        projMovement.SetProjectileOriginator(this.gameObject);
                        projMovement.GetComponent <LineRenderer>().enabled = false;
                        Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0.0f));
                        //projMovement.AddVelocity(ray.direction, m_projectileSpeed + m_rgd.velocity);
                        Rigidbody arrowRgd = (Rigidbody)arrow.GetComponent <Rigidbody>();
                        arrowRgd.AddForce((ray.direction * (m_projectileSpeed + (currentArrowForce * bowAccumulationMultiplier))), ForceMode.Impulse);
                        m_reloadCounter   = 0;
                        currentArrowForce = 0;
                        arrowIsLoaded     = false;
                        m_audioManager.PlayBowShoot();
                    }
                }
            }
        }
        else
        {
            m_reloadCounter += Time.deltaTime;
        }
    }