Pink/Assets/Scripts/Items/FruitController.cs

31 lines
739 B
C#
Raw Normal View History

using UnityEngine;
2020-10-01 23:35:00 +01:00
using UnityEngine.SceneManagement;
using Pink.Mechanics;
namespace Pink.Items
{
class FruitController : MonoBehaviour
{
public Animator animator;
void OnTriggerEnter2D(Collider2D collider)
{
var userController = collider.gameObject.GetComponent<PinkController>();
if (userController != null)
{
animator.SetTrigger("collected");
2020-10-01 23:35:00 +01:00
Collect();
SceneManager.LoadScene("second");
}
}
public void Collect()
{
animator.enabled = false;
GetComponent<CapsuleCollider2D>().enabled = false;
gameObject.SetActive(false);
}
}
}