コード例 #1
0
    void Update()
    {
        if (container.Selected() == null)
        {
            return;
        }

        if (container.ShootAttempt() && Time.time > nextHit)
        {
            if (!container.Selected().canAttack(player, container))
            {
                return;
            }
            nextHit = Time.time + container.Selected().rate;
            StartCoroutine(container.Selected().Effect());
            container.Selected().Attack(player, blood);
            container.UpdateSelected();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            RangedWeapon rangedWeapon = container.Selected() as RangedWeapon;
            if (rangedWeapon != null)
            {
                rangedWeapon.TryReload(player, container);
            }
        }
    }
コード例 #2
0
ファイル: RangedWeapon.cs プロジェクト: Pro100Boh/KpiSurvival
    public IEnumerator Reload(Actor a, WeaponContainer container)
    {
        container.Lock();
        PlayReload();
        a.Animator().SetBool("Reloading", true);
        yield return(reloadWait);

        magazineFill = magazineSize;
        container.UpdateSelected();
        reloading = false;
        container.Unlock();
        a.Animator().SetBool("Reloading", false);
    }