//Playerに
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MovingObj : MonoBehaviour
{
public GameObject Player;
int gemCount = 0;
int gemCount2 = 0;
public Text diamondUICount;
public Text diamondUICount2;
void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.tag == "Meat")
{
col.gameObject.SetActive(false);
UpdateDiamondCountUI();
}
if (col.gameObject.tag == "Meat2")
{
Destroy(col.gameObject);
UpdateDiamondCountUI2();
}
if (col.gameObject.tag == "over")
{
SceneManager.LoadScene("GameOver");
}
}
void UpdateDiamondCountUI()
{
gemCount += 10;
diamondUICount.text = "Score:" + gemCount.ToString();
}
void UpdateDiamondCountUI2()
{
gemCount2 += 5;
diamondUICount2.text = "Score:" + gemCount2.ToString();
}
}
///////////////////////////
//GameObjetに
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
class GameClear : MonoBehaviour
{
public GameObject score_object = null;
public float score_num = 0;
void Update()
{
Text score_text = score_object.GetComponent();
int count = GameObject.FindGameObjectsWithTag("blocktag").Length;
score_text.text = "Score:" + count * 10;
if (count == 0)
{
SceneManager.LoadScene("GameClear");
}
}
}