-
Notifications
You must be signed in to change notification settings - Fork 0
/
AmmoBoost.cs
42 lines (37 loc) · 1.05 KB
/
AmmoBoost.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AmmoBoost : MonoBehaviour
{
[Header("Ammo Boost")]
public Riffle rifle;
public AmmoCount ammoUI;
private int magToGive = 10;
private float radious = 2.5f;
[Header("Sound")]
public AudioClip ammoBoostSound;
public AudioSource audioSource;
[Header("HealthBox Animator")]
public Animator animator;
public GameObject pickupUI;
private void Update()
{
if (Vector3.Distance(transform.position, rifle.transform.position) < radious)
{
pickupUI.SetActive(true);
if (Input.GetKeyDown(KeyCode.F))
{
animator.SetBool("Open", true);
rifle.mag = magToGive;
ammoUI.magtext.text = "Magzines" + magToGive;
//sound effect
audioSource.PlayOneShot(ammoBoostSound);
Object.Destroy(gameObject, 1.5f);
}
}
else
{
pickupUI.SetActive(false);
}
}
}