53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class Menu : MonoBehaviour{
|
|
|
|
public TextMeshProUGUI insertCoin;
|
|
float playAnimation;
|
|
bool readyToStart;
|
|
|
|
// Start is called before the first frame update
|
|
void Start(){
|
|
InvokeRepeating("InsertCoin", 0, 1);
|
|
AudioManager.instance.Play("MenuSong");
|
|
Invoke("Ready", 1);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update(){
|
|
if (Input.anyKeyDown && readyToStart){
|
|
CancelInvoke("InsertCoin");
|
|
InvokeRepeating("Play", 0, .05f);
|
|
}
|
|
}
|
|
|
|
void Ready(){
|
|
readyToStart = true;
|
|
}
|
|
|
|
void Play(){
|
|
if(playAnimation < 10f){
|
|
if (insertCoin.color.a == 0){
|
|
insertCoin.color = new Color(insertCoin.color.r, insertCoin.color.g, insertCoin.color.b, 1);
|
|
}else{
|
|
insertCoin.color = new Color(insertCoin.color.r, insertCoin.color.g, insertCoin.color.b, 0);
|
|
}
|
|
playAnimation++;
|
|
}else{
|
|
SceneManager.LoadScene(1);
|
|
}
|
|
}
|
|
|
|
void InsertCoin(){
|
|
if(insertCoin.color.a == 0){
|
|
insertCoin.color = new Color(insertCoin.color.r, insertCoin.color.g, insertCoin.color.b, 1);
|
|
}else{
|
|
insertCoin.color = new Color(insertCoin.color.r, insertCoin.color.g, insertCoin.color.b, 0);
|
|
}
|
|
}
|
|
}
|