29 lines
804 B
C#
29 lines
804 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Ammo : MonoBehaviour
|
|
{
|
|
public int amount;
|
|
public Sprite one, two, three;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
amount = Random.Range(1, 4);
|
|
SpriteRenderer sr = GetComponent<SpriteRenderer>();
|
|
if (amount == 1)
|
|
sr.sprite = one;
|
|
else if (amount == 2)
|
|
sr.sprite = two;
|
|
else if (amount == 3)
|
|
sr.sprite = three;
|
|
}
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if (collision.transform.tag.Equals("Player"))
|
|
{
|
|
collision.transform.GetComponent<PlayerWeaponController>().currentBullets += amount;
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
}
|