You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
|
|
public class ItemColliector : MonoBehaviour
|
|
|
|
{
|
|
|
|
private int Blue_Cheese = 0;
|
|
|
|
|
|
|
|
public TMP_Text BlueCheeseText;
|
|
|
|
private Inputs Input;
|
|
|
|
private InputAction Eat;
|
|
|
|
public float Speed;
|
|
|
|
private PlayerMovement Player;
|
|
|
|
private float SpeedTime;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
Input = new Inputs();
|
|
|
|
Player = gameObject.GetComponent<PlayerMovement>();
|
|
|
|
}
|
|
|
|
private void OnEnable()
|
|
|
|
{
|
|
|
|
Eat = Input.Movement.Eat;
|
|
|
|
Eat.Enable();
|
|
|
|
}
|
|
|
|
private void OnDisable()
|
|
|
|
{
|
|
|
|
Eat.Disable();
|
|
|
|
}
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
|
|
{
|
|
|
|
if (collision.gameObject.CompareTag("Blue Cheese"))
|
|
|
|
{
|
|
|
|
Destroy(collision.gameObject);
|
|
|
|
Blue_Cheese++;
|
|
|
|
Debug.Log(Blue_Cheese);
|
|
|
|
BlueCheeseText.text = "" + Blue_Cheese;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
Eat.performed += _ => Eating();
|
|
|
|
SpeedTime -= Time.deltaTime;
|
|
|
|
Mathf.Clamp(SpeedTime, 0, 100);
|
|
|
|
if(SpeedTime <= 0)
|
|
|
|
{
|
|
|
|
//Player.speedBoost = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void Eating()
|
|
|
|
{
|
|
|
|
if (Blue_Cheese > 0 && SpeedTime <= 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
Blue_Cheese--;
|
|
|
|
Debug.Log(Blue_Cheese);
|
|
|
|
BlueCheeseText.text = "" + Blue_Cheese;
|
|
|
|
//Player.speedBoost = 1.5f;
|
|
|
|
SpeedTime = 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|