Пример #1
0
    private void Update()
    {
        var currentSaw = new HashSet <Renderer>();

        foreach (var saw in SensorsUtils.InSights(transform, playerLight, frontLight, sensorCount))
        {
            currentSaw.Add(saw);
            inSights.Add(saw);
            saw.enabled = true;
        }

        var remaining = new HashSet <Renderer>(inSights);

        remaining.ExceptWith(currentSaw);
        foreach (var remained in remaining)
        {
            remained.enabled = false;
            inSights.Remove(remained);
        }
    }
    private void Update()
    {
        ShootingLightPenalty();
        if (SensorsUtils.FrontView(transform, shootingLight, sensorCount).Any())
        {
            Shoot();
        }

        if (Input.GetKeyUp(KeyCode.R))
        {
            if (allAmmo > 0)
            {
                isReload        = true;
                reloadStartTime = Time.time;
            }
        }

        if (isReload)
        {
            ReloadAnimation();
        }

        ammoText.text = $"{currentMag}/{allAmmo}";
    }