Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using static Sio.Basic;
- using Sio;
- using Sio.Atai;
- using Sio.LibDX;
- using DxLibDLL;
- namespace Sio.Bibo.Vis
- {
- public class MandaraManager
- {
- static string[] s_varNames = { "dist", "ptCnt", "methodType" };
- List<Mandara> _mandaraList = new();
- List<Mandara> _mandaraOutLine = new();
- static bool s_perFrameRunFlag = true;
- // CurSIORI
- // ToDo
- //
- // <==>Float
- FlipFlop _distFF { get { return _flipFlops[0]; } }
- FlipFlop _pointsCountFF { get { return _flipFlops[1]; } }
- FlipFlop _methodTypeFF { get { return _flipFlops[2]; } }
- FlipFlop[] _flipFlops = new FlipFlop[3];
- int _Dist { get => _params[0]; set => _params[0] = value; }
- int _PointsCount { get => _params[1]; set => _params[1] = value; }
- int _MethodType { get => _params[2]; set => _params[2] = value; }
- int[] _params = new int[3];
- const int MinLimitPointsCount = 7;
- int _pointsCountChangeGap = 2;
- const int GapMax = 4;
- static readonly string[] s_DistFuncNames =
- { "Fix as Points.Cnt/2", "KeepRatio","Fix as Points.Cnt/3", "DistFix1","Default" };
- int _distFunc = 0;
- const int DIST_FUNC_MAX = 5;
- public MandaraManager(int firstCount = 7)
- {
- _PointsCount = firstCount;
- _MethodType = -1;
- _Dist = 2;
- _pointsCountChangeGap = 2;
- _mandaraList.Add(new Mandara(_PointsCount, _Dist, _MethodType));
- for (int i = 0; i < _flipFlops.Length; i++)
- {
- _flipFlops[i] = new FlipFlop();
- }
- _pointsCountFF.Run(_PointsCount);
- _distFF.Run(_Dist);
- _methodTypeFF.Run(_MethodType);
- Update();
- }
- public void InputCheck()
- {
- static bool PerFrameRun(int arg)
- {
- if (!s_perFrameRunFlag) { return false; }
- return Glo.Frame % arg == 1;
- }
- if (Input.KeyRelease(DX.KEY_INPUT_S) || PerFrameRun(323)) { Mandara.s_SwitchColorSwapMode(); }
- if (Input.Key[DX.KEY_INPUT_SPACE] == 1 || PerFrameRun(190)) { ChangeGap(); }
- //if (Input.Defined.SubPushed || 99<Sio.Basic.FixRandom(100))
- if (Input.Defined.SubPushed || 99 < Sio.Basic.FixRandom(100))
- {
- _distFunc++;
- _distFunc %= DIST_FUNC_MAX;
- Console.WriteLine("_distFunc [{0}] name " + s_DistFuncNames[_distFunc], _distFunc);
- }
- bool createNewObject = false;
- int prevPointCnt = _PointsCount;
- System.Numerics.Vector2 keyV2 = Input.Defined.Move.ConvertedToVector2();
- if (Input.Defined.Decide || 10 < Input.Defined.KetteiNagaosi() || Input.Defined.Move.Move_8_Pushing() == 1 || PerFrameRun(113))
- {
- _PointsCount += _pointsCountChangeGap;
- //_pointsCount += 2;
- createNewObject = true;
- }
- else
- {
- if (Input.Defined.CancelPushing || Input.Defined.Move.Move_2_Pushing() == 1 || PerFrameRun(159))
- {
- _PointsCount -= _pointsCountChangeGap;
- //_pointsCount -= 2;
- createNewObject = true;
- if (_PointsCount < 3)
- {
- createNewObject = false;
- _PointsCount = prevPointCnt;
- }
- }
- }
- if (0 < Input.MouseWheel || 0 < keyV2.X || PerFrameRun(231))
- {
- //Console.WriteLine("keyVec" + keyV2);
- _Dist++;
- createNewObject = true;
- }
- if (Input.MouseWheel < 0 || keyV2.X < 0 || PerFrameRun(317))
- {
- _Dist--;
- //if (_Dist < 1) _Dist = 1;
- createNewObject = true;
- }
- if (_PointsCount < MinLimitPointsCount) _PointsCount = MinLimitPointsCount;
- if (createNewObject)
- {
- _Dist += _PointsCount;
- _Dist %= _PointsCount;
- //if (_PointsCount <= _Dist) { _Dist = _PointsCount - 1; }
- //int _Dist = _Dist;
- if (prevPointCnt != _PointsCount)
- {
- //Console.WriteLine("PointsCount changed. ");
- //DxLibDLL.DX.WaitKey();
- switch (_distFunc)
- {
- case 0:
- {
- _Dist = _PointsCount / 2;
- //if(_PointsCount%2==0)
- break;
- }
- case 1: //KeepRatio
- {
- if (prevPointCnt < _PointsCount)
- {
- _Dist += _pointsCountChangeGap;
- }
- else
- {
- _Dist -= _pointsCountChangeGap;
- }
- //Console.WriteLine();
- //Console.WriteLine("dist change in switch KeepRatio dist[{0}]",_Dist);
- break;
- }
- case 2:
- {
- _Dist = _PointsCount / 3;
- break;
- }
- case 3:
- {
- _Dist = 1;
- break;
- }
- default:
- {
- break;
- }
- }
- }
- _mandaraList.Last().Vanish();
- _mandaraList.Add(new Mandara(_PointsCount, _Dist, _MethodType));
- //KakkOut(s_varNames, _params);//array
- if (_pointsCountFF.PrevResult != 0)
- {
- if (_mandaraOutLine.Count > 0)
- {
- _mandaraOutLine.Last().Vanish();
- }
- var outLine = new Mandara(_PointsCount, 1, -1);
- _mandaraOutLine.Add(outLine);
- outLine.SetBlendParam(200);
- outLine.Vanish();
- }
- }
- }
- public void Update()
- {
- for (int i = _mandaraList.Count - 1; i >= 0; i--)
- {
- var m = _mandaraList[i];
- m.Update();
- if (m.IIGetRemoveFlag())
- {
- _mandaraList.RemoveAt(i);
- }
- }
- for (int i = _mandaraOutLine.Count - 1; i >= 0; i--)
- {
- var m = _mandaraOutLine[i];
- m.Update();
- if (m.IIGetRemoveFlag())
- {
- _mandaraOutLine.RemoveAt(i);
- }
- }
- for (int i = 0; i < _flipFlops.Length; i++)
- {
- _flipFlops[i].Run(_params[i]);
- }
- }
- public void Draw()
- {
- foreach (Mandara m in _mandaraList)
- {
- m.Draw();
- }
- foreach (Mandara m in _mandaraOutLine)
- {
- m.Draw();
- }
- }
- public void Run()
- {
- InputCheck();
- Draw();
- Update();
- }
- void ChangeGap()
- {
- _pointsCountChangeGap++;
- _pointsCountChangeGap %= GapMax;
- if (_pointsCountChangeGap == 0) _pointsCountChangeGap++;
- //KakkOut("Gap", _pointsCountChangeGap);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment