/** * Called if the player X press the fire button * * */ void TryToFire() { if (weaponState == WeaponState.READY) { if (timer >= shootFrequenzy) { timer = 0; for (int i = 0; i < bulletCount; i++) { GameObject obj = Instantiate(bullet, firePoint.position, firePoint.rotation); MachineGunBullet bulletOrigin = obj.GetComponent <MachineGunBullet>(); bulletOrigin.player = GetComponentInParent <CharacterControll>().gameObject; obj.SetActive(true); } setAmmunition(currentAmmunition - 1); } } else if (weaponState == WeaponState.REALOAD) { } else if (weaponState == WeaponState.OUT_OF_AMMO) { } else { throw new NotImplementedException(); } }
private void Shoot(IGetDamage target) { IBullet bullet = new MachineGunBullet(bulletType, currentMachineGunStats.damage); target.GetDamage(bullet); machineGunClip--; }
public void ApplyDamage(MachineGunBullet bullet) { float damage = bullet.damage; foreach (GameObject obj in bullet.tables) { if (this.tables.Contains(obj)) { damage = damage * (1 - protectionFactor); break; } } if (currentLive > 0) { setLive(currentLive - damage); if (currentLive <= 0) { bullet.player.GetComponent <CharacterControll>().addToScore(SCORE_ON_DEATH); } } }
using UnityEngine;