Ejemplo n.º 1
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            Debug.Log("E键按下");
            foreach (FullBodyBipedEffector e in effectors)
            {
                interactionSystem.StartInteraction(e, interactionObject, true);
            }
        }

        if (Input.GetKeyDown(KeyCode.R) || Input.GetMouseButtonDown(0))
        {
            Debug.Log("R键按下");
            recoil.Fire(magnitude);
        }
    }
Ejemplo n.º 2
0
 private void Shoot()
 {
     if (ammo.GetCurrentAmmo() > 0)
     {
         recoil.Fire();
         PlayMuzzleFlash();
         ProcessRayCastTarget();
         ProcessRayCastTarget_Single();
         ProcessRayCastTarget_Boss();
         PlayAllAudio();
         ammo.ReduceCurrentAmmo();
     }
     else if (ammo.GetCurrentAmmo() == 0)
     {
         audios.PlayOneShot(ammoEmpty);
     }
 }
Ejemplo n.º 3
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            Debug.Log("E键按下");
            foreach (FullBodyBipedEffector e in effectors)
            {
                interactionSystem.StartInteraction(e, interactionObject, true);
                mAimIK.solver.transform        = interactionObject.transform.Find("Gun/FBXExport_Props:MP40/AimTransform");
                mAimIK.solver.IKPositionWeight = 1f;
            }
        }

        if (Input.GetKeyDown(KeyCode.R) || Input.GetMouseButtonDown(0))
        {
            Debug.Log("R键按下");
            recoil.Fire(magnitude);
        }

        mAimIK.solver.IKPosition = transform.forward * 10f;
        mAimIK.solver.Update();
    }
    void Update()
    {
        isFiring = PlayerInput.isFiring;

        if (isFiring && readyToFire)
        {
            readyToFire = false;
            recoil.Fire();

            if (Physics.Raycast(myCamera.transform.position, myCamera.transform.forward, out hit, 1000))
            {
                Vector3    position = hit.point + (hit.normal * .1f);
                Quaternion rotation = Quaternion.LookRotation(hit.normal);
                if (bulletHole != null)
                {
                    Instantiate(bulletHole, position, rotation);
                }
            }

            StartCoroutine(FireFrequency());
        }
    }
Ejemplo n.º 5
0
    private void Update()
    {
        // Update time since last bullet passes...
        _timeSinceLastFire += Time.fixedDeltaTime;

        if (ammo == 0)
        {
            StartCoroutine(Reload());
        }

        // If user wants to fire bullet and enough time has passed since last bullet, then proceed ...
        if (Input.GetMouseButton(0) && _timeSinceLastFire >= fireRate && ammo > 0)
        {
            ammo         -= 1;
            ammoText.text = $"{ammo}/{ammoMax}";
            // ... to reset time counter
            _timeSinceLastFire = 0f;

            // ... to apply recoil and fire particles
            _recoil.Fire();
            _partTracers.Emit(1);
            _partFlare.Emit(1);

            // ... to apply bullet force if the bullet hit
            if (Physics.Raycast(_barrelTransform.position, _barrelTransform.forward, out _enemyHit,
                                Mathf.Infinity, _enemyLayer))
            {
                StartCoroutine(nameof(ApplyBulletForce), _enemyHit);
                EnemyBehaviour script = _enemyHit.transform.root.gameObject.GetComponent <EnemyBehaviour>();
                if (script)
                {
                    script.Kill();
                }
            }
        }
    }
Ejemplo n.º 6
0
    void Shoot()
    {
        muzzleFlash.Play();
        gunshot.Play();
        recoil.Fire();

        RaycastHit hit;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);

            SimpleAIController target = hit.transform.GetComponent <SimpleAIController>();

            if (target != null)
            {
                target.TakeDamage(damage);
            }

            GameObject impactGo = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));

            Destroy(impactGo, 0.5f);
        }
    }
Ejemplo n.º 7
0
 public void onWeaponFire(float weight)
 {
     m_recoil.Fire(weight);
 }