ScaleTimeAntiCheat.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. //检测Time.ScaleTime修改
  5. public class ScaleTimeAntiCheat : AntiCheatBase
  6. {
  7. protected override bool IsCheckAntiCheat()
  8. {
  9. if (Time.timeScale > AntiCheatCfg.c_fTimeScaleMaxValidTime)
  10. {
  11. Time.timeScale = AntiCheatCfg.c_fTimeScaleNorlValidTime;
  12. return true;
  13. }
  14. else
  15. {
  16. if (Time.timeScale > GameMgr.Instance.GetGameSpeed())
  17. {
  18. Time.timeScale = GameMgr.Instance.GetGameSpeed();
  19. return true;
  20. }
  21. }
  22. return false;
  23. }
  24. protected override void OnAntiCheat()
  25. {
  26. //检测到非法运行速度 显示提示框
  27. LuaInterface.LuaState pLuaState = LuaMgr.GetMainState();
  28. if (null != pLuaState)
  29. {
  30. bool bIsConnect = NetworkMgr.Instance.GetConnectStatus();
  31. if (!bIsConnect)
  32. LuaMgr.GetMainState().DoString("ManagerContainer.LuaBattleMgr:ShowAntiCheatMsgBox(1)");
  33. else
  34. LuaMgr.GetMainState().DoString("ManagerContainer.LuaBattleMgr:SendAntiCheat(1)");
  35. BattleMgr.Instance.DoPauseFighting(true);
  36. }
  37. else
  38. {
  39. TimerManager.Instance.AddTimer(3000, 1, (nTime) =>
  40. {
  41. GameMgr.Instance.QuitGame();
  42. });
  43. }
  44. Debug.Log("非法速度");
  45. }
  46. }