58 lines
1000 B
C#
58 lines
1000 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
public static GameManager instance;
|
|
|
|
public float Score;
|
|
public int DotNum;
|
|
|
|
public TMPro.TextMeshProUGUI scoreText;
|
|
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
// 单例初始化
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
// 吃豆加分减少数量
|
|
public void AddScore(float amount)
|
|
{
|
|
Score += amount;
|
|
DotNum--;
|
|
UpdateScoreDisplay();
|
|
if(DotNum<=0)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public void AddDotNum(int addNotNum)
|
|
{
|
|
DotNum += addNotNum;
|
|
// UpdateScoreDisplay();
|
|
}
|
|
|
|
private void UpdateScoreDisplay()
|
|
{
|
|
if (scoreText != null)
|
|
{
|
|
scoreText.text = Score.ToString();
|
|
}
|
|
}
|
|
|
|
}
|