FightDataManager.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using UnityEngine;
  2. namespace GFGGame
  3. {
  4. public class FightDataManager : SingletonBase<FightDataManager>
  5. {
  6. public byte[] FightRoleRes { get; set; }
  7. public Texture2D RoleTextuex { get; set; }
  8. //角色基础分+部件基础分
  9. private int _score;
  10. public int score
  11. {
  12. get
  13. {
  14. return _score;
  15. }
  16. set
  17. {
  18. _score = value;
  19. EventAgent.DispatchEvent(ConstMessage.DRESS_UP_SCORE_CHANGED, _score);
  20. }
  21. }
  22. //最终得分
  23. private int _totalScore;
  24. public int totalScore
  25. {
  26. get
  27. {
  28. return _totalScore;
  29. }
  30. set
  31. {
  32. _totalScore = value;
  33. }
  34. }
  35. //战斗对象最终得分
  36. private int _targetTotalScore;
  37. public int npcTotalScore
  38. {
  39. get
  40. {
  41. return _targetTotalScore;
  42. }
  43. set
  44. {
  45. _targetTotalScore = value;
  46. }
  47. }
  48. private bool _autoPlay = false;
  49. public bool autoPlay
  50. {
  51. get
  52. {
  53. return _autoPlay;
  54. }
  55. set
  56. {
  57. _autoPlay = value;
  58. if (!_autoPlay) fightSpeed = 1;
  59. StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_AUTO_PLAY, _autoPlay == true ? 1 : 0).Coroutine();
  60. }
  61. }
  62. public int maxFightSpeed = 2;
  63. private int _fightSpeed = 1;
  64. public int fightSpeed
  65. {
  66. get
  67. {
  68. return _fightSpeed;
  69. }
  70. set
  71. {
  72. _fightSpeed = value;
  73. StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_FIGHT_AUTO_PLAY_SPEED, _fightSpeed).Coroutine();
  74. }
  75. }
  76. private int _storyDialogSpeed = 1;
  77. public int dialogSpeed
  78. {
  79. get
  80. {
  81. return _storyDialogSpeed;
  82. }
  83. set
  84. {
  85. _storyDialogSpeed = value;
  86. StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_DIALOG_AUTO_PLAY_SPEED, _storyDialogSpeed).Coroutine();
  87. }
  88. }
  89. //根据位置原点和随机范围获取评分位置
  90. public void GetCirclePos(Vector2 pos, int range, out float x, out float y)
  91. {
  92. int numX = UnityEngine.Random.Range(0, 2);
  93. int signX = numX % 2 == 0 ? 1 : -1;
  94. float rangeX = UnityEngine.Random.Range(0, range);
  95. x = pos.x + signX * (rangeX);
  96. int numY = UnityEngine.Random.Range(0, 2);
  97. int signY = numY % 2 == 0 ? 1 : -1;
  98. float rangeY = UnityEngine.Random.Range(0, range);
  99. y = pos.y + signY * (rangeY);
  100. }
  101. public Texture2D GetPrintscreenNTexture(Camera camera)
  102. {
  103. RenderTexture rt = new RenderTexture(UnityEngine.Screen.width, UnityEngine.Screen.height, 0);//渲染一张1920*1080的图
  104. camera.targetTexture = rt;//传到主摄像机上
  105. camera.Render();//渲染
  106. RenderTexture.active = rt;
  107. Texture2D screenShot = new Texture2D(UnityEngine.Screen.width, UnityEngine.Screen.height, TextureFormat.ARGB32, false);
  108. screenShot.ReadPixels(new Rect(0, 0, UnityEngine.Screen.width, UnityEngine.Screen.height), 0, 0);//读像素
  109. screenShot.Apply();
  110. camera.targetTexture = null;
  111. RenderTexture.active = null;
  112. Object.Destroy(rt);
  113. return screenShot;
  114. }
  115. }
  116. }