2025-03-17 21:56:02 +08:00
|
|
|
|
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;
|
2025-03-18 22:32:00 +08:00
|
|
|
|
public float invincibleTime;//<2F><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
|
|
|
|
|
public TMPro.TextMeshProUGUI scoreText;//<2F><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
|
|
|
|
|
public TMPro.TextMeshProUGUI invincibleText;//<2F><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ı<EFBFBD>
|
2025-03-17 21:56:02 +08:00
|
|
|
|
|
2025-03-20 22:28:26 +08:00
|
|
|
|
public bool GameStart = false;//<2F><>Ϸ<EFBFBD><CFB7>ʼ
|
2025-03-17 21:56:02 +08:00
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
if (instance == null)
|
|
|
|
|
{
|
|
|
|
|
instance = this;
|
|
|
|
|
DontDestroyOnLoad(gameObject);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Destroy(gameObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-18 22:32:00 +08:00
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
UpdateInvincibleTime();
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-17 21:56:02 +08:00
|
|
|
|
|
|
|
|
|
// <20>Զ<EFBFBD><D4B6>ӷּ<D3B7><D6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public void AddScore(float amount)
|
|
|
|
|
{
|
|
|
|
|
Score += amount;
|
|
|
|
|
DotNum--;
|
|
|
|
|
UpdateScoreDisplay();
|
|
|
|
|
if(DotNum<=0)
|
|
|
|
|
{
|
2025-03-18 22:32:00 +08:00
|
|
|
|
//<2F><>Ϸʤ<CFB7><CAA4>
|
2025-03-17 21:56:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddDotNum(int addNotNum)
|
|
|
|
|
{
|
|
|
|
|
DotNum += addNotNum;
|
|
|
|
|
// UpdateScoreDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateScoreDisplay()
|
|
|
|
|
{
|
|
|
|
|
if (scoreText != null)
|
|
|
|
|
{
|
|
|
|
|
scoreText.text = Score.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-18 22:32:00 +08:00
|
|
|
|
private void UpdateInvincibleTime()
|
|
|
|
|
{
|
|
|
|
|
if (invincibleText != null)
|
|
|
|
|
{
|
|
|
|
|
invincibleText.text = invincibleTime.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static float GetAnimaTime(Animator animtorName, string animName)//<2F><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
{
|
|
|
|
|
if (animtorName != null)
|
|
|
|
|
{
|
|
|
|
|
RuntimeAnimatorController AC = animtorName.runtimeAnimatorController;
|
|
|
|
|
foreach (var item in AC.animationClips)
|
|
|
|
|
{
|
|
|
|
|
if (item.name == animName)
|
|
|
|
|
{
|
|
|
|
|
return item.length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2025-03-17 21:56:02 +08:00
|
|
|
|
}
|