Пример #1
0
    public override void PullTrigger(Player player)
    {
        if (state != SniperRifleState.Ready)
        {
            return;
        }

        state = SniperRifleState.Prefire;
        remainingPrefireTime = PreFireDuration;
        animator.SetBool("PreFire", true);
    }
Пример #2
0
    void FireBullet()
    {
        var projectile = Instantiate(ProjectilePrefab, transform.position, transform.rotation);

        Destroy(projectile, 1f);
        state = SniperRifleState.Reload;
        remainingReloadTime = ReloadDuration;
        muzzleFlash.Stop();
        muzzleFlash.Play();
        fireSound.Play();

        var muzzle = transform.position + transform.forward * muzzleOffset;

        CheckForValidHitscan(muzzle, transform.forward, layerMask);
    }
Пример #3
0
 void Update()
 {
     if (state == SniperRifleState.Reload && remainingReloadTime <= 0f)
     {
         state = SniperRifleState.Ready;
     }
     if (state == SniperRifleState.Prefire && remainingPrefireTime <= 0f)
     {
         FireBullet();
         state = SniperRifleState.Reload;
         animator.SetBool("PreFire", false);
     }
     else
     {
         remainingReloadTime  -= Time.deltaTime;
         remainingPrefireTime -= Time.deltaTime;
     }
     player.canMove = state != SniperRifleState.Prefire;
 }