88 lines
1.8 KiB
C#
88 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
|
|
public class gameGlobal : Base
|
|
{
|
|
public delegate void GameItem();
|
|
public event GameItem OnGameInit;
|
|
public event GameItem OnGameStart;
|
|
public event GameItem OnGamePlay;
|
|
public event GameItem OnGameVictory;
|
|
public event GameItem OnGameOver;
|
|
|
|
|
|
public List<string> CarryCardId = new List<string>();
|
|
|
|
|
|
/// <summary>
|
|
/// 游戏初始化
|
|
/// </summary>
|
|
public static void GameInit()
|
|
{
|
|
Base.GlobalObj.GetComponent<gameGlobal>().OnGameInit?.Invoke();
|
|
}
|
|
/// <summary>
|
|
/// 游戏可以开始,准备完成
|
|
/// </summary>
|
|
public static void GameStart()
|
|
{
|
|
Base.GlobalObj.GetComponent<gameGlobal>().OnGameStart?.Invoke();
|
|
}
|
|
/// <summary>
|
|
/// 游戏进行
|
|
/// </summary>
|
|
public static void GamePlay()
|
|
{
|
|
Debug.Log("游戏开始");
|
|
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay?.Invoke();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 游戏暂停
|
|
/// </summary>
|
|
public static void GameStop()
|
|
{
|
|
Time.timeScale = 0f;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 游戏恢复
|
|
/// </summary>
|
|
public static void GameRecovery()
|
|
{
|
|
Time.timeScale = 1f;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 游戏退出
|
|
/// </summary>
|
|
public static void GameExit()
|
|
{
|
|
|
|
Application.Quit();
|
|
|
|
// 如果在编辑器中测试退出游戏效果
|
|
#if UNITY_EDITOR
|
|
UnityEditor.EditorApplication.isPlaying = false; // 在编辑器中停止游戏
|
|
#endif
|
|
}
|
|
|
|
/// <summary>
|
|
/// GameVictory
|
|
/// </summary>
|
|
public static void GameVictory()
|
|
{
|
|
Base.GlobalObj.GetComponent<gameGlobal>().OnGameVictory?.Invoke();
|
|
}
|
|
|
|
/// <summary>
|
|
/// GameVictory
|
|
/// </summary>
|
|
public static void GameOver()
|
|
{
|
|
Base.GlobalObj.GetComponent<gameGlobal>().OnGameOver?.Invoke();
|
|
}
|
|
}
|