void Update() { if (Input.GetButtonDown("Fire1")) { weapon.Attack(lookDirection); ammoText.text = "Ammo: " + weapon.GetAmmo().ToString(); } }
int raycastLayer; // Created this layer exclusively for raycast #endregion void Start() { raycastLayer = LayerMask.GetMask("Raycast"); timeManager = TimeManager.instance; rb = GetComponent <Rigidbody>(); weapon = GetComponentInChildren <IWeapon>(); ammoText.text = "Ammo: " + weapon.GetAmmo().ToString(); }
private void UpdateAmmoDisplay() { Player player = personController.player; if (player == null) { animator.SetInteger(AMMO_LVL_INT, 0); ammoText.text = ""; return; } IWeapon weapon = player.Weapon; if (weapon == null) { animator.SetInteger(AMMO_LVL_INT, 0); ammoText.text = ""; } else { int ammo = weapon.GetAmmo(); if (ammo < 0) { animator.SetInteger(AMMO_LVL_INT, 3); ammoText.text = "∞"; return; } if (ammo > 16) { animator.SetInteger(AMMO_LVL_INT, 3); } else if (ammo > 8) { animator.SetInteger(AMMO_LVL_INT, 2); } else if (ammo > 0) { animator.SetInteger(AMMO_LVL_INT, 1); } else { animator.SetInteger(AMMO_LVL_INT, 0); } ammoText.text = ammo.ToString(); } }