void Update()
    {
        healthBar.SetHealth(hitPoints);


        CalculateCrosshairPosition();
        if (alive)
        {
            Movment();
            if (Keyboard.current.gKey.isPressed && Time.time > nextGrenade)
            {
                nextGrenade = Time.time + 1f;
                Grenade newGrenade = Instantiate(grenade, new Vector3(transform.position.x, transform.position.y + 1f, transform.position.z), Quaternion.identity) as Grenade;
                newGrenade.CalculatePath(this.transform, crosshairPosition);
            }
            if (Mouse.current.leftButton.isPressed)
            {
                isShooting = 1;
                equipedWeapon.Fire(crosshairPosition);
            }
            else
            {
                isShooting -= 0.05f;
            }
            playerAnimator.SetFloat("isShooting", isShooting);
        }
    }
Beispiel #2
0
 // ------------------------------------------------- Pistol -------------------------------------------------
 public override void PrimaryAttack()
 {
     if (!primary.is_reloading)
     {
         ShakeCamera(0.04f, 0.07f, Quaternion.Euler(0, 0, GetMouseDirection(attacking_offset.position)));
         primary.Fire(GetMouseDirection(attacking_offset.position));
     }
     else
     {
         ability_primary.Reset();
     }
 }
    void Shoot()
    {
        // Firing.
        float      deviation = UnityEngine.Random.Range(-_deviation, _deviation);
        Quaternion direction = Quaternion.Euler(transform.rotation.eulerAngles + (Vector3.forward * deviation));

        _weapon.Fire(gameObject, direction);

        // Deviation, ammo and timer update.
        _timer      = 0;
        _deviation += _weapon.FireDeviation;
        _deviation  = _deviation > _weapon.MaxDeviation ? _weapon.MaxDeviation : _deviation;
        _weapon.Magazine--;
        if (ammoUpdate != null)
        {
            ammoUpdate(_weapon.Magazine);
        }
    }
 protected void Activate(XRBaseInteractor a_interactor)
 {
     weapon.Fire(a_interactor);
 }