52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class FrutasMakeSalad : MonoBehaviour
|
|
{
|
|
public GameObject SlicedFruit, gameFObject;
|
|
public int cortadas;
|
|
Animator textoanim;
|
|
private void Start()
|
|
{
|
|
textoanim = GameObject.Find("Chops").GetComponent<Animator>();
|
|
}
|
|
void OnTriggerExit2D(Collider2D coll)
|
|
{
|
|
if (coll.tag == "Blade")
|
|
{
|
|
|
|
Vector2 direction = (coll.transform.position - transform.position).normalized;
|
|
Quaternion rotation = Quaternion.LookRotation(direction);
|
|
GameObject slicedfruit = Instantiate(SlicedFruit);
|
|
slicedfruit.transform.position = transform.position;
|
|
cortadas++;
|
|
Destroy(slicedfruit, 5f);
|
|
Destroy(gameObject, 6f);
|
|
}
|
|
}
|
|
private void OnTriggerEnter2D(Collider2D other)
|
|
{
|
|
if (other.tag == "Mesa")
|
|
{
|
|
textoanim.SetTrigger("Chop");
|
|
StartCoroutine(timerEscrita(1.2f));
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (cortadas >= 5)
|
|
{
|
|
Destroy(gameFObject);
|
|
}
|
|
}
|
|
|
|
IEnumerator timerEscrita(float time)
|
|
{
|
|
yield return new WaitForSeconds(time);
|
|
textoanim.SetTrigger("Chop");
|
|
}
|
|
}
|