Santi
16784160a1
CubeGravity - Added increased gravity to the special object BoxTP_Catch - Added spcial object, more items spawn as timer goes down, at 0 game stops.
81 lines
2.1 KiB
C#
81 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Dynamic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
//* General Comments or Finished Tasks
|
|
//TODO Tasks left to be done for game
|
|
//! Bugs or Issues
|
|
//? Questions or Suggestions
|
|
|
|
//* Prevent player from moving when they are hitting the moles
|
|
public class Hamor : MonoBehaviour
|
|
{
|
|
public Animator hamorAnimator;
|
|
public GameObject bonkParticles;
|
|
public GameObject contact;
|
|
public bool particles = false;
|
|
public TextMeshProUGUI scoreText;
|
|
public int score = 0;
|
|
public Moles_IsHit moles;
|
|
public Movement movement;
|
|
//* Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
//* Update is called once per frame
|
|
void Update()
|
|
{
|
|
if(Input.GetMouseButtonDown(0))
|
|
{
|
|
movement.hammer = true;
|
|
hamorAnimator.SetTrigger("Bonk"); //* Play the bonk animation
|
|
StartCoroutine(MoveTimer());
|
|
}
|
|
}
|
|
|
|
IEnumerator MoveTimer()
|
|
{
|
|
yield return new WaitForSeconds(1);
|
|
movement.hammer = false;
|
|
}
|
|
IEnumerator BonkTimer()
|
|
{
|
|
yield return new WaitForSeconds(1);
|
|
particles = false;
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other) {
|
|
if(particles == false)
|
|
{
|
|
if(other.tag != "Player")
|
|
{
|
|
//* Play the bonk particles
|
|
var parLocation = Instantiate(bonkParticles, contact.transform.position, Quaternion.identity);
|
|
Destroy(parLocation, 1);
|
|
particles = true;
|
|
StartCoroutine(BonkTimer());
|
|
}
|
|
}
|
|
|
|
if(other.gameObject.tag == "Mole")
|
|
{
|
|
//* Get the Moles_IsHit script from the mole
|
|
moles = other.gameObject.GetComponent<Moles_IsHit>();
|
|
|
|
//* If the mole has not been hit, increase the score and change bool
|
|
if(moles.IsHit == false)
|
|
{
|
|
score += 1;
|
|
scoreText.text = "Score: " + score.ToString();
|
|
moles.IsHit = true;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|