Mini-Games-Game/Assets/Scripts/Catch/Catch.cs

46 lines
1.1 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
//* General Comments or Finished Tasks
//TODO Tasks left to be done for game
//! Bugs or Issues
//? Questions or Suggestions
public class Catch : MonoBehaviour
{
public int score;
public TextMeshProUGUI scoreText;
public Movement movement;
private void OnTriggerEnter(Collider other) {
if(other.gameObject.tag == "PickupObject")
{
Destroy(other.gameObject);
score = score + 1;
scoreText.text = "Score: " + score;
}
else if(other.gameObject.tag == "Bomb")
{
Destroy(other.gameObject);
score = score - 3;
scoreText.text = "Score: " + score;
StartCoroutine(ConcussionTime());
}
else if(other.gameObject.tag == "SpecialObject")
{
Destroy(other.gameObject);
score = score + 2;
scoreText.text = "Score: " + score;
}
}
IEnumerator ConcussionTime()
{
movement.speed = 0;
yield return new WaitForSeconds(2);
movement.speed = 7.0f;
}
}