using System.Collections;
using UnityEngine;
public class Activator : MonoBehaviour {
SpriteRenderer sr;
public KeyCode key;
bool active = false;
GameObject note, gm;
Color old;
public bool createMode;
public GameObject n;
void Awake() {
sr = GetComponent();
}
void Start() {
gm = GameObject.Find(“GameManager”);
old = sr.color;
}
private void OnMouseDown()
{
StartCoroutine(TaskOnClick());
}
void Update() {
if (createMode && Input.GetMouseButtonDown(0)) {
if (Input.GetMouseButtonDown(0))
Instantiate(n, transform.position, Quaternion.identity);
} else {
if (Input.GetKeyDown(KeyCode.Mouse0) && active)
{
Destroy(note);
AddScore();
gm.GetComponent().AddStreak();
active = false;
}
else if (Input.GetMouseButtonDown(0) && !active)
{
gm.GetComponent().ResetStreak();
}
}
{ }
void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.tag == “WinNote”)
gm.GetComponent().Win();
if (col.gameObject.tag == “Note”) { }
note = col.gameObject;
active = true;
}
}
void OnTriggerExit2D(Collider2D col){
active=false;
gm.GetComponent().ResetStreak();
}
void AddScore() {
PlayerPrefs.SetInt(“Score”, PlayerPrefs.GetInt(“Score”) + gm.GetComponent().GetScore());
}
IEnumerator TaskOnClick() {
sr.color = new Color(0, 0, 0);
yield return new WaitForSeconds(0.2f);
sr.color = old;
}
}
3468999–275485–GameManager.cs (1.67 KB)
3469003–275490–Note.cs (353 Bytes)
3468999–275487–PPText.cs (320 Bytes)
3469003–275492–RockMeter.cs (454 Bytes)