40 lines
840 B
C#
40 lines
840 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Collectible : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private int amount;
|
|
[SerializeField]
|
|
private float rotSpeed;
|
|
[SerializeField]
|
|
private float timeToAppear;
|
|
|
|
void Update()
|
|
{
|
|
transform.Rotate(0, rotSpeed, 0, Space.World);
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other) {
|
|
if(other.gameObject.tag.Equals("Player")){
|
|
GameController.Instance.AddCoins(amount);
|
|
Vanish();
|
|
}
|
|
}
|
|
|
|
private void Vanish(){
|
|
gameObject.SetActive(false);
|
|
if(timeToAppear > -1){
|
|
Invoke("Appear", timeToAppear);
|
|
}else{
|
|
Destroy(this.gameObject);
|
|
}
|
|
|
|
}
|
|
|
|
private void Appear(){
|
|
gameObject.SetActive(true);
|
|
}
|
|
}
|