Beispiel #1
0
    public override void Update(GunController gun)
    {
        m_currPlayingFire = gun.m_gunAnimator.GetCurrentAnimatorStateInfo(0).IsName("fire");

        // To aim state.
        if (MyInput.GetButtonDown("Fire2"))
        {
            if (gun.IsSecondaryState(this))
            {
                gun.ChangeState(new GunStateAim());
            }
            else
            {
                gun.AddSecondaryState(new GunStateAim());
            }
        }

        // End fire.
        if (
            ((gun.m_fireMode != FireMode.Launcher) && MyInput.GetButtonUp("Fire1")) ||
            ((gun.m_fireMode == FireMode.Launcher) && m_prevPlayingFire && !m_currPlayingFire)
            )
        {
            if (gun.IsSecondaryState(this))
            {
                gun.RemoveSecondaryState();
            }
            else
            {
                gun.ChangeState(new GunStateIdle());
            }
        }

        m_prevPlayingFire = m_currPlayingFire;
    }
Beispiel #2
0
    public override void Update(GunController gun)
    {
        // To fire state.
        if (MyInput.GetButtonDown("Fire1"))
        {
            if (gun.NBullets > 0)
            {
                gun.AddSecondaryState(new GunStateFire());
            }
            else
            {
                GameStats._MessageNotifier.PushFloatMessage("Out of bullet");
                GameStats._GunsManager.GetComponent <AudioSource>().PlayOneShot(gun.m_emptyFireSound);
            }
        }

        // End aim.
        if (MyInput.GetButtonUp("Fire2"))
        {
            if (gun.IsSecondaryState(this))
            {
                gun.RemoveSecondaryState();
            }
            else
            {
                gun.ChangeState(new GunStateIdle());
            }
        }
    }