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; }
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()); } } }
public override void Update(GunController gun) { // End reload. if (!gun.m_gunAnimator.GetCurrentAnimatorStateInfo(0).IsName("reload")) { gun.ChangeState(new GunStateIdle()); } }
public override void Update(GunController gun) { m_currPlayingDraw = gun.m_gunAnimator.GetCurrentAnimatorStateInfo(0).IsName("draw"); if (m_prevPlayingDraw && !m_currPlayingDraw) { gun.ChangeState(new GunStateIdle()); } m_prevPlayingDraw = m_currPlayingDraw; }
public override void Update(GunController gun) { // To fire state. if (MyInput.GetButtonDown("Fire1") && (gun.m_fireMode != FireMode.Launcher)) { if (gun.NBullets > 0) { gun.ChangeState(new GunStateFire()); } else { GameStats._MessageNotifier.PushFloatMessage("Out of bullet"); GameStats._GunsManager.GetComponent <AudioSource>().PlayOneShot(gun.m_emptyFireSound); } } // To aim state. if (MyInput.GetButtonDown("Fire2")) { gun.ChangeState(new GunStateAim()); } // To reload state. if (MyInput.GetButtonDown("Reload") && (gun.m_fireMode != FireMode.Launcher)) { if (gun.NMagazines > 0) { gun.ChangeState(new GunStateReload()); } else { GameStats._MessageNotifier.PushFloatMessage("Out of magazine"); GameStats._GunsManager.GetComponent <AudioSource>().PlayOneShot(gun.m_emptyFireSound); } } }
void FixedUpdate() { float mouseXMovement = Input.GetAxis("Mouse X"); float mouseYMovement = Input.GetAxis("Mouse Y"); float tankMovement = Input.GetAxis("Horizontal"); float bodyMovement = Input.GetAxis("Vertical"); body.Turn(tankMovement); turret.Turn(mouseXMovement); MoveTank(bodyMovement); cannon.Turn(mouseYMovement); if (Input.GetButton("Fire1") && cannonTimer >= cannonFireRate && cannon.CanFire()) { cannonTimer = 0f; cannon.Fire(); } if (Input.GetButtonDown("Fire2") && gun.currentState != FireMode.Auto) { gun.Fire(); } else if (Input.GetButton("Fire2") && !isGunShooting && gun.currentState == FireMode.Auto) { isGunShooting = true; gun.Auto(); } else if (Input.GetButtonUp("Fire2") && isGunShooting && gun.currentState == FireMode.Auto) { isGunShooting = false; gun.StopFire(); } if (Input.GetKeyDown(KeyCode.F)) { gun.ChangeState(); gun.StopFire(); isGunShooting = false; } }