private void Awake() { playerHookup = FindObjectOfType <PlayerBase>(); healthBarUI = GetComponent <HealthBar>(); gunnerHookup = FindObjectOfType <Gunner>(); gunnerPrimaryFireHookup = gunnerHookup.GetComponent <GunnerPrimaryFire>(); gunnerDOTGrenadeHookup = gunnerHookup.GetComponent <GunnerDOTGrenade>(); gunnerGrenadeHookup = gunnerHookup.GetComponent <GunnerGrenade>(); gunnerSecondaryFireHookup = gunnerHookup.GetComponent <GunnerAltFire>(); }
private void FixedUpdate() { fireRate = (float)SubsystemManager.weaponHealth / 100.0f * fireRateMax; if (SubsystemManager.weaponHealth > 75) { fireRate = fireRateMax; } else if (SubsystemManager.weaponHealth > 50) { fireRate = 0.75f * fireRateMax; } else if (SubsystemManager.weaponHealth > 0) { fireRate = 0.5f * fireRateMax; } else { fireRate = 0; fireTimer = 0; } if (fireTimer > 0 || isShooting) { fireTimer += Time.fixedDeltaTime; } if (fireRate > 0 && fireTimer >= (1 / fireRate)) { if (isShooting) { Vector3 shotPos; if (instance.input == Vector2.zero) { shotPos = transform.up; } else { shotPos = new Vector3(instance.input.x, 0, instance.input.y); } Laser laser = Instantiate(instance.laser, instance.gunPosition.position, Quaternion.LookRotation(shotPos, Vector3.up)); laser.GetComponent <Weapon>().caster = instance.GetComponent <Damageable>(); } fireTimer = 0; } }