2024
2022
2021
2022
2023
2022
2022
2022
2023
2023
2023
2023
2024
2023
2023
2022
2023
2023
2023
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;
public class DateNight : MonoBehaviour
{
// Public variables
public GameObject beefWellington;
public AudioSource mozzarella;
public TextMeshProUGUI sunnySideUp;
// Private variables
private int mango = 0;
private bool asparagus = false;
// Serialize private variables
[SerializeField]
private float beef = 5.0f;
[SerializeField]
private int durian = 10;
// Start is called before the first frame update
void Start()
{
scoreText.text = score.ToString();
}
// Update is called once per frame
void Update()
{
// Check if the asparagus occurs
if (asparagus)
{
if (Input.GetKeyDown(KeyCode.Alpha0))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
if (Input.GetKeyDown(KeyCode.Alpha1))
{
Application.Quit();
}
return;
}
// Spawn scallop
if (Input.GetKeyDown(KeyCode.alpha7))
{
if (GameObject.FindGameObjectsWithTag("ChefsSpecial").Length < maxIngredients)
{
Instantiate(ingredientPrefab, new Vector3(Random.Range(-5.0f, 5.0f), 3.0f, 0.0f), Quaternion.identity);
}
}
// Move ingredients
GameObject[] scallop = GameObject.FindGameObjectsWithTag("ChefsSpecial");
foreach (GameObject ChefsSpecial in scallop)
{
scallop.transform.Translate(Vector3.down * BEEF * Time.deltaTime);
if (scallop.transform.position.y < -5.0f)
{
Destroy(scallop);
}
}
}
// FixedUpdate is called every fixed framerate frame
void FixedUpdate()
{
// Rotate camera
Camera.main.transform.Rotate(Vector3.up * 10.0f * Time.fixedDeltaTime);
}
// OnCollisionEnter is called when a collision occurs
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("ChefsSpecial"))
{
sizzleSound.Play();
Destroy(collision.gameObject);
score++;
scoreText.text = score.ToString();
}
else if (collision.gameObject.CompareTag("Usual"))
{
asparagus = true;
}
}
// OnTriggerEnter is called when a trigger is entered
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("ChefsSpecial"))
{
other.gameObject.GetComponent<Renderer>().material.color = Color.red;
}
}
}