SioDxLibDotNet

Untitled

Sep 20th, 2023
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using static Sio.Basic;
  7. using Sio;
  8. using Sio.Atai;
  9. using Sio.LibDX;
  10. using DxLibDLL;
  11. namespace Sio.Bibo.Vis
  12. {
  13. public class MandaraManager
  14. {
  15. static string[] s_varNames = { "dist", "ptCnt", "methodType" };
  16. List<Mandara> _mandaraList = new();
  17. List<Mandara> _mandaraOutLine = new();
  18. static bool s_perFrameRunFlag = true;
  19. // CurSIORI
  20. // ToDo
  21. //
  22. // <==>Float
  23.  
  24.  
  25.  
  26. FlipFlop _distFF { get { return _flipFlops[0]; } }
  27. FlipFlop _pointsCountFF { get { return _flipFlops[1]; } }
  28. FlipFlop _methodTypeFF { get { return _flipFlops[2]; } }
  29. FlipFlop[] _flipFlops = new FlipFlop[3];
  30.  
  31. int _Dist { get => _params[0]; set => _params[0] = value; }
  32. int _PointsCount { get => _params[1]; set => _params[1] = value; }
  33. int _MethodType { get => _params[2]; set => _params[2] = value; }
  34.  
  35. int[] _params = new int[3];
  36. const int MinLimitPointsCount = 7;
  37. int _pointsCountChangeGap = 2;
  38. const int GapMax = 4;
  39.  
  40. static readonly string[] s_DistFuncNames =
  41. { "Fix as Points.Cnt/2", "KeepRatio","Fix as Points.Cnt/3", "DistFix1","Default" };
  42. int _distFunc = 0;
  43. const int DIST_FUNC_MAX = 5;
  44. public MandaraManager(int firstCount = 7)
  45. {
  46. _PointsCount = firstCount;
  47. _MethodType = -1;
  48. _Dist = 2;
  49. _pointsCountChangeGap = 2;
  50. _mandaraList.Add(new Mandara(_PointsCount, _Dist, _MethodType));
  51. for (int i = 0; i < _flipFlops.Length; i++)
  52. {
  53. _flipFlops[i] = new FlipFlop();
  54. }
  55. _pointsCountFF.Run(_PointsCount);
  56. _distFF.Run(_Dist);
  57. _methodTypeFF.Run(_MethodType);
  58. Update();
  59.  
  60. }
  61. public void InputCheck()
  62. {
  63. static bool PerFrameRun(int arg)
  64. {
  65. if (!s_perFrameRunFlag) { return false; }
  66. return Glo.Frame % arg == 1;
  67. }
  68. if (Input.KeyRelease(DX.KEY_INPUT_S) || PerFrameRun(323)) { Mandara.s_SwitchColorSwapMode(); }
  69. if (Input.Key[DX.KEY_INPUT_SPACE] == 1 || PerFrameRun(190)) { ChangeGap(); }
  70. //if (Input.Defined.SubPushed || 99<Sio.Basic.FixRandom(100))
  71. if (Input.Defined.SubPushed || 99 < Sio.Basic.FixRandom(100))
  72. {
  73. _distFunc++;
  74. _distFunc %= DIST_FUNC_MAX;
  75. Console.WriteLine("_distFunc [{0}] name " + s_DistFuncNames[_distFunc], _distFunc);
  76. }
  77. bool createNewObject = false;
  78. int prevPointCnt = _PointsCount;
  79. System.Numerics.Vector2 keyV2 = Input.Defined.Move.ConvertedToVector2();
  80. if (Input.Defined.Decide || 10 < Input.Defined.KetteiNagaosi() || Input.Defined.Move.Move_8_Pushing() == 1 || PerFrameRun(113))
  81. {
  82. _PointsCount += _pointsCountChangeGap;
  83. //_pointsCount += 2;
  84. createNewObject = true;
  85. }
  86. else
  87. {
  88. if (Input.Defined.CancelPushing || Input.Defined.Move.Move_2_Pushing() == 1 || PerFrameRun(159))
  89. {
  90. _PointsCount -= _pointsCountChangeGap;
  91. //_pointsCount -= 2;
  92.  
  93. createNewObject = true;
  94. if (_PointsCount < 3)
  95. {
  96. createNewObject = false;
  97. _PointsCount = prevPointCnt;
  98. }
  99. }
  100. }
  101.  
  102.  
  103.  
  104.  
  105. if (0 < Input.MouseWheel || 0 < keyV2.X || PerFrameRun(231))
  106. {
  107. //Console.WriteLine("keyVec" + keyV2);
  108. _Dist++;
  109. createNewObject = true;
  110. }
  111. if (Input.MouseWheel < 0 || keyV2.X < 0 || PerFrameRun(317))
  112. {
  113. _Dist--;
  114. //if (_Dist < 1) _Dist = 1;
  115. createNewObject = true;
  116. }
  117. if (_PointsCount < MinLimitPointsCount) _PointsCount = MinLimitPointsCount;
  118.  
  119.  
  120. if (createNewObject)
  121. {
  122. _Dist += _PointsCount;
  123. _Dist %= _PointsCount;
  124. //if (_PointsCount <= _Dist) { _Dist = _PointsCount - 1; }
  125. //int _Dist = _Dist;
  126. if (prevPointCnt != _PointsCount)
  127. {
  128. //Console.WriteLine("PointsCount changed. ");
  129. //DxLibDLL.DX.WaitKey();
  130. switch (_distFunc)
  131. {
  132. case 0:
  133. {
  134. _Dist = _PointsCount / 2;
  135. //if(_PointsCount%2==0)
  136. break;
  137. }
  138. case 1: //KeepRatio
  139. {
  140.  
  141. if (prevPointCnt < _PointsCount)
  142. {
  143. _Dist += _pointsCountChangeGap;
  144. }
  145. else
  146. {
  147. _Dist -= _pointsCountChangeGap;
  148. }
  149. //Console.WriteLine();
  150. //Console.WriteLine("dist change in switch KeepRatio dist[{0}]",_Dist);
  151. break;
  152. }
  153. case 2:
  154. {
  155. _Dist = _PointsCount / 3;
  156. break;
  157. }
  158. case 3:
  159. {
  160. _Dist = 1;
  161. break;
  162. }
  163.  
  164. default:
  165. {
  166. break;
  167. }
  168. }
  169. }
  170. _mandaraList.Last().Vanish();
  171. _mandaraList.Add(new Mandara(_PointsCount, _Dist, _MethodType));
  172. //KakkOut(s_varNames, _params);//array
  173. if (_pointsCountFF.PrevResult != 0)
  174. {
  175. if (_mandaraOutLine.Count > 0)
  176. {
  177. _mandaraOutLine.Last().Vanish();
  178. }
  179. var outLine = new Mandara(_PointsCount, 1, -1);
  180. _mandaraOutLine.Add(outLine);
  181. outLine.SetBlendParam(200);
  182. outLine.Vanish();
  183. }
  184. }
  185. }
  186. public void Update()
  187. {
  188. for (int i = _mandaraList.Count - 1; i >= 0; i--)
  189. {
  190. var m = _mandaraList[i];
  191. m.Update();
  192. if (m.IIGetRemoveFlag())
  193. {
  194. _mandaraList.RemoveAt(i);
  195. }
  196. }
  197. for (int i = _mandaraOutLine.Count - 1; i >= 0; i--)
  198. {
  199. var m = _mandaraOutLine[i];
  200. m.Update();
  201. if (m.IIGetRemoveFlag())
  202. {
  203. _mandaraOutLine.RemoveAt(i);
  204. }
  205. }
  206. for (int i = 0; i < _flipFlops.Length; i++)
  207. {
  208. _flipFlops[i].Run(_params[i]);
  209. }
  210. }
  211. public void Draw()
  212. {
  213. foreach (Mandara m in _mandaraList)
  214. {
  215. m.Draw();
  216. }
  217. foreach (Mandara m in _mandaraOutLine)
  218. {
  219. m.Draw();
  220. }
  221. }
  222. public void Run()
  223. {
  224. InputCheck();
  225. Draw();
  226. Update();
  227. }
  228. void ChangeGap()
  229. {
  230. _pointsCountChangeGap++;
  231. _pointsCountChangeGap %= GapMax;
  232. if (_pointsCountChangeGap == 0) _pointsCountChangeGap++;
  233. //KakkOut("Gap", _pointsCountChangeGap);
  234. }
  235. }
  236. }
  237.  
Advertisement
Add Comment
Please, Sign In to add comment