diff --git a/.gitignore b/.gitignore index 3dc430c..92e0dda 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ SlaveMatrix/obj/ 2DGAMELIB/bin/ SlaveMatrix/bin/ .vs/ +game_folder/save/* +/game_folder/save diff --git a/2DGAMELIB/_2DGAMELIB/AreM.cs b/2DGAMELIB/_2DGAMELIB/AreM.cs index cd7dae3..13e4229 100644 --- a/2DGAMELIB/_2DGAMELIB/AreM.cs +++ b/2DGAMELIB/_2DGAMELIB/AreM.cs @@ -11,43 +11,33 @@ namespace _2DGAMELIB public AreM(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength) { - Setting(Unit, XRatio, YRatio, Size, DisMag, HitMag, Strength); - } + SetXYRatio(XRatio, YRatio); + base.Size = Size; + unit = Unit; + strength = Strength; + disUnit = Unit * DisMag; + double num = 1.0 - Strength; + unitS = disUnit * num; - private void Setting(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength) - { - SetXYRatio(XRatio, YRatio); - base.Size = Size; - unit = Unit; - strength = Strength; - disUnit = Unit * DisMag; - double num = 1.0 - Strength; - unitS = disUnit * num; - WH.Width = (int)(base.LocalWidth * Unit); - WH.Height = (int)(base.LocalHeight * Unit); - WHA.Width = (int)(base.LocalWidth * disUnit); - WHA.Height = (int)(base.LocalHeight * disUnit); - Dis = new Bitmap((int)((double)WH.Width * DisMag * num), (int)((double)WH.Height * DisMag * num)); - gd = Graphics.FromImage(Dis); - gd.SmoothingMode = SmoothingMode.None; - gd.PixelOffsetMode = PixelOffsetMode.None; - hitUnit = Unit * HitMag; - WHH.Width = (int)(base.LocalWidth * hitUnit); - WHH.Height = (int)(base.LocalHeight * hitUnit); - Hit = new Bitmap(WHH.Width, WHH.Height); - gh = Graphics.FromImage(Hit); - gh.SmoothingMode = SmoothingMode.None; - gh.PixelOffsetMode = PixelOffsetMode.None; - } - public new void Draw(ParT ParT) - { - ParT.Draw(unitS, gd); - if (gh != null) - { - ParT.DrawH(hitUnit, gh); - } - } + WH.Width = (int)(base.LocalWidth * Unit); + WH.Height = (int)(base.LocalHeight * Unit); + WHA.Width = (int)(base.LocalWidth * disUnit); + WHA.Height = (int)(base.LocalHeight * disUnit); + Dis = new Bitmap((int)((double)WH.Width * DisMag * num), (int)((double)WH.Height * DisMag * num)); + gd = Graphics.FromImage(Dis); + gd.SmoothingMode = SmoothingMode.None; + gd.PixelOffsetMode = PixelOffsetMode.None; + + + hitUnit = Unit * HitMag; + WHH.Width = (int)(base.LocalWidth * hitUnit); + WHH.Height = (int)(base.LocalHeight * hitUnit); + Hit = new Bitmap(WHH.Width, WHH.Height); + gh = Graphics.FromImage(Hit); + gh.SmoothingMode = SmoothingMode.None; + gh.PixelOffsetMode = PixelOffsetMode.None; + } public new void Draw(Pars Pars) { diff --git a/2DGAMELIB/_2DGAMELIB/But.cs b/2DGAMELIB/_2DGAMELIB/But.cs index 8f61a18..9184757 100644 --- a/2DGAMELIB/_2DGAMELIB/But.cs +++ b/2DGAMELIB/_2DGAMELIB/But.cs @@ -50,24 +50,12 @@ namespace _2DGAMELIB public Pars Pars => pars; - public But(Par Par, Action Action) - { - pars = new Pars(Par); - this.Action = Action; - } - public But(ParT ParT, Action Action) { pars = new Pars(ParT); this.Action = Action; } - public But(Pars Pars, Action Action) - { - pars = Pars; - this.Action = Action; - } - public bool Move(ref Color HitColor) { if (Dra && !f2 && pars.IsHit(ref HitColor)) @@ -129,14 +117,6 @@ namespace _2DGAMELIB } } - public void Draw(AreM AreM) - { - if (dra) - { - AreM.Draw(pars); - } - } - public void SetHitColor(Med Med) { foreach (Par item in pars.EnumAllPar()) diff --git a/2DGAMELIB/_2DGAMELIB/Dif.cs b/2DGAMELIB/_2DGAMELIB/Dif.cs index b907346..a2bf5bd 100644 --- a/2DGAMELIB/_2DGAMELIB/Dif.cs +++ b/2DGAMELIB/_2DGAMELIB/Dif.cs @@ -201,22 +201,6 @@ namespace _2DGAMELIB parss.Add(Pars); } - public void Draws(Are Are) - { - foreach (Pars item in parss) - { - Are.Draw(item); - } - } - - public void Draws(AreM AreM) - { - foreach (Pars item in parss) - { - AreM.Draw(item); - } - } - public List GetHitTags(ref Color HitColor) { List list = new List(); diff --git a/2DGAMELIB/_2DGAMELIB/Difs.cs b/2DGAMELIB/_2DGAMELIB/Difs.cs index ca245ed..d65b555 100644 --- a/2DGAMELIB/_2DGAMELIB/Difs.cs +++ b/2DGAMELIB/_2DGAMELIB/Difs.cs @@ -21,8 +21,6 @@ namespace _2DGAMELIB public Dictionary pr; - public List Difss => difs; - public int CountX => difs.Count; public int CountY @@ -366,26 +364,6 @@ namespace _2DGAMELIB return difs.FirstOrDefault((Dif d) => d.IsHit(ref HitColor)).Parss.FirstOrDefault((Pars ps) => ps.IsHit(ref HitColor)).EnumAllPar().FirstOrDefault((Par e) => e.HitColor == HitColor); } - public List GetHitTags(ref Color HitColor) - { - List list = new List(); - foreach (Dif dif in difs) - { - list.AddRange(dif.GetHitTags(ref HitColor)); - } - return list; - } - - public List GetHitPars(ref Color HitColor) - { - List list = new List(); - foreach (Dif dif in difs) - { - list.AddRange(dif.GetHitPars(ref HitColor)); - } - return list; - } - public bool IsHit(ref Color HitColor) { foreach (Dif dif in difs) diff --git a/2DGAMELIB/_2DGAMELIB/HSV.cs b/2DGAMELIB/_2DGAMELIB/HSV.cs index 36d9238..c80d043 100644 --- a/2DGAMELIB/_2DGAMELIB/HSV.cs +++ b/2DGAMELIB/_2DGAMELIB/HSV.cs @@ -240,10 +240,5 @@ namespace _2DGAMELIB HSV.ToRGB(H, S, V, out var r, out var g, out var b); ret = Color.FromArgb(a, r, g, b); } - - public override string ToString() - { - return "H : " + H + " S : " + S + " V : " + V; - } } } diff --git a/2DGAMELIB/_2DGAMELIB/JointD.cs b/2DGAMELIB/_2DGAMELIB/JointD.cs index 5608805..9ba88e5 100644 --- a/2DGAMELIB/_2DGAMELIB/JointD.cs +++ b/2DGAMELIB/_2DGAMELIB/JointD.cs @@ -39,30 +39,6 @@ namespace _2DGAMELIB Difs1.JoinPA(); } - public void JoinPall() - { - foreach (Par item in Difs1.EnumJoinRoot) - { - Difs0.Current.GetPar(Path0).SetJointP(Index, item); - } - foreach (Pars item2 in Difs1.EnumAllPars()) - { - Difs1.JoinPA(item2); - } - } - - public void JoinPAall() - { - foreach (Par item in Difs1.EnumJoinRoot) - { - Difs0.Current.GetPar(Path0).SetJointPA(Index, item); - } - foreach (Pars item2 in Difs1.EnumAllPars()) - { - Difs1.JoinPA(item2); - } - } - public void Set(JointS 接続元) { Difs0 = 接続元.Difs; diff --git a/2DGAMELIB/_2DGAMELIB/Lab.cs b/2DGAMELIB/_2DGAMELIB/Lab.cs index 50cd0e3..9b1de6a 100644 --- a/2DGAMELIB/_2DGAMELIB/Lab.cs +++ b/2DGAMELIB/_2DGAMELIB/Lab.cs @@ -117,33 +117,6 @@ namespace _2DGAMELIB parT.OP[0].ps[3] = new Vector2D(0.0, parT.RectSize.Y); } - public bool Double(ref Color HitColor) - { - //TODO fix? - //if (Input && parT.HitColor == HitColor && !Med.BaseControl.Controls.Contains(tb)) - /*{ - tb.Text = parT.Text; - parT.Text = ""; - SetRectT(); - //Med.BaseControl.Controls.Add(tb); - tb.SelectAll(); - tb.Focus(); - tb.BringToFront(); - return true; - }*/ - return false; - } - - public void Click(ref Color HitColor) - { - //TODO fix? - /*if (Input && parT.HitColor != HitColor && Med.BaseControl.Controls.Contains(tb)) - { - //Med.BaseControl.Controls.Remove(tb); - SetText(tb.Text); - }*/ - } - public void Dispose() { parT.Dispose(); diff --git a/2DGAMELIB/_2DGAMELIB/Matrix.cs b/2DGAMELIB/_2DGAMELIB/Matrix.cs deleted file mode 100644 index c9edc8e..0000000 --- a/2DGAMELIB/_2DGAMELIB/Matrix.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; - -namespace _2DGAMELIB -{ - public static class Matrix - { - public static MatrixD RotationZ(this double angle) - { - MatrixD result = default(MatrixD); - result.M11 = System.Math.Cos(angle); - result.M12 = System.Math.Sin(angle); - result.M13 = 0.0; - result.M14 = 0.0; - result.M21 = 0.0 - result.M12; - result.M22 = result.M11; - result.M23 = 0.0; - result.M24 = 0.0; - result.M31 = 0.0; - result.M32 = 0.0; - result.M33 = 1.0; - result.M34 = 0.0; - result.M41 = 0.0; - result.M42 = 0.0; - result.M43 = 0.0; - result.M44 = 1.0; - return result; - } - - public static void TransformCoordinate(ref Vector2D coord, ref MatrixD transform, out Vector2D result) - { - double num = 1.0 / (coord.X * transform.M14 + coord.Y * transform.M24 + transform.M44); - result.X = (coord.X * transform.M11 + coord.Y * transform.M21 + transform.M41) * num; - result.Y = (coord.X * transform.M12 + coord.Y * transform.M22 + transform.M42) * num; - } - - public static Vector2D TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, MatrixD transform) - { - Vec.Subtract(ref coord, ref BasePoint, out coord); - TransformCoordinate(ref coord, ref transform, out var result); - Vec.Add(ref result, ref BasePoint, out result); - return result; - } - - public static Vector2D TransformCoordinateBP(ref Vector2D coord, ref Vector2D BasePoint, ref MatrixD transform) - { - Vec.Subtract(ref coord, ref BasePoint, out var r); - TransformCoordinate(ref r, ref transform, out var result); - Vec.Add(ref result, ref BasePoint, out result); - return result; - } - } -} diff --git a/2DGAMELIB/_2DGAMELIB/MatrixD.cs b/2DGAMELIB/_2DGAMELIB/MatrixD.cs index 117128d..1805f5b 100644 --- a/2DGAMELIB/_2DGAMELIB/MatrixD.cs +++ b/2DGAMELIB/_2DGAMELIB/MatrixD.cs @@ -38,168 +38,6 @@ namespace _2DGAMELIB public double M44; - public double this[int row, int col] - { - get - { - switch (row) - { - case 0: - switch (col) - { - case 0: - return M11; - case 1: - return M12; - case 2: - return M13; - case 3: - return M14; - default: - error(row, col); - return 0.0; - } - case 1: - switch (col) - { - case 0: - return M21; - case 1: - return M22; - case 2: - return M23; - case 3: - return M24; - default: - error(row, col); - return 0.0; - } - case 2: - switch (col) - { - case 0: - return M31; - case 1: - return M32; - case 2: - return M33; - case 3: - return M34; - default: - error(row, col); - return 0.0; - } - case 3: - switch (col) - { - case 0: - return M41; - case 1: - return M42; - case 2: - return M43; - case 3: - return M44; - default: - error(row, col); - return 0.0; - } - default: - error(row, col); - return 0.0; - } - } - set - { - switch (row) - { - case 0: - switch (col) - { - case 0: - M11 = value; - break; - case 1: - M12 = value; - break; - case 2: - M13 = value; - break; - case 3: - M14 = value; - break; - default: - error(row, col); - break; - } - break; - case 1: - switch (col) - { - case 0: - M21 = value; - break; - case 1: - M22 = value; - break; - case 2: - M23 = value; - break; - case 3: - M24 = value; - break; - default: - error(row, col); - break; - } - break; - case 2: - switch (col) - { - case 0: - M31 = value; - break; - case 1: - M32 = value; - break; - case 2: - M33 = value; - break; - case 3: - M34 = value; - break; - default: - error(row, col); - break; - } - break; - case 3: - switch (col) - { - case 0: - M41 = value; - break; - case 1: - M42 = value; - break; - case 2: - M43 = value; - break; - case 3: - M44 = value; - break; - default: - error(row, col); - break; - } - break; - default: - error(row, col); - break; - } - } - } - public MatrixD(double M11, double M12, double M13, double M14, double M21, double M22, double M23, double M24, double M31, double M32, double M33, double M34, double M41, double M42, double M43, double M44) { this.M11 = M11; @@ -219,17 +57,5 @@ namespace _2DGAMELIB this.M43 = M43; this.M44 = M44; } - - private void error(int row, int col) - { - if (row < 0 || row > 3) - { - throw new ArgumentOutOfRangeException("row", "Rows and columns for matrices run from 0 to 3, inclusive."); - } - if (col < 0 || col > 3) - { - throw new ArgumentOutOfRangeException("col", "Rows and columns for matrices run from 0 to 3, inclusive."); - } - } } } diff --git a/2DGAMELIB/_2DGAMELIB/Shas.cs b/2DGAMELIB/_2DGAMELIB/Shas.cs index 42808bb..4caea1d 100644 --- a/2DGAMELIB/_2DGAMELIB/Shas.cs +++ b/2DGAMELIB/_2DGAMELIB/Shas.cs @@ -77,12 +77,12 @@ namespace _2DGAMELIB private static Vector2D GetTP2() { - return Matrix.TransformCoordinateBP(ref TP1, ref 中央中央, ref m120); + return Math.TransformCoordinateBP(ref TP1, ref 中央中央, ref m120); } private static Vector2D GetTP3() { - return Matrix.TransformCoordinateBP(ref TP1, ref 中央中央, ref m240); + return Math.TransformCoordinateBP(ref TP1, ref 中央中央, ref m240); } public static Vector2D MulX(this Vector2D Vector, double X) diff --git a/2DGAMELIB/_2DGAMELIB/Text.cs b/2DGAMELIB/_2DGAMELIB/Text.cs deleted file mode 100644 index 9d76508..0000000 --- a/2DGAMELIB/_2DGAMELIB/Text.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.IO; -using System.Text; - -namespace _2DGAMELIB -{ - public static class Text - { - public static void ToText(this string str, string Path, Encoding Encoding) - { - using StreamWriter streamWriter = new StreamWriter(Path, append: false, Encoding); - streamWriter.Write(str); - } - - public static string FromText(this string Path) - { - using FileStream fileStream = new FileStream(Path, FileMode.Open, FileAccess.Read); - byte[] array = new byte[fileStream.Length]; - fileStream.Read(array, 0, array.Length); - using StreamReader streamReader = new StreamReader(new MemoryStream(array), array.GetEncoding()); - return streamReader.ReadToEnd(); - } - - public static string[] ReadLines(this string Path) - { - return Path.FromText().Replace("\r", "").Split('\n'); - } - } -} diff --git a/2DGAMELIB/_2DGAMELIB/Vector2D.cs b/2DGAMELIB/_2DGAMELIB/Vector2D.cs index 44a380c..e689606 100644 --- a/2DGAMELIB/_2DGAMELIB/Vector2D.cs +++ b/2DGAMELIB/_2DGAMELIB/Vector2D.cs @@ -10,33 +10,6 @@ namespace _2DGAMELIB public double Y; - public double this[int index] - { - get - { - return index switch - { - 0 => X, - 1 => Y, - _ => throw new ArgumentOutOfRangeException("index", "Indices for Vector2D run from 0 to 1, inclusive."), - }; - } - set - { - switch (index) - { - case 0: - X = value; - break; - case 1: - Y = value; - break; - default: - throw new ArgumentOutOfRangeException("index", "Indices for Vector2D run from 0 to 1, inclusive."); - } - } - } - public Vector2D(int x, int y) { X = x; diff --git a/2DGAMELIB/_2DGAMELIB/WPFImage.cs b/2DGAMELIB/_2DGAMELIB/WPFImage.cs index 5ff75f7..f3f7e29 100644 --- a/2DGAMELIB/_2DGAMELIB/WPFImage.cs +++ b/2DGAMELIB/_2DGAMELIB/WPFImage.cs @@ -32,26 +32,14 @@ namespace _2DGAMELIB return __refvalue(destRef, GLFW.Window); } - public static unsafe IntPtr WindowToPtr(Window source) - { - var sourceRef = __makeref(source); - var dest = default(IntPtr); - var destRef = __makeref(dest); - *(IntPtr*)&destRef = *(IntPtr*)&sourceRef; - return __refvalue(destRef, IntPtr); - } - public GLFW.Window window; private uint shader_program; private uint texture; private uint vertex_buf; private uint vao; - public GlImage() { } - public void ImageSetting() { } - public System.Drawing.Point GetCursorPoint() { double x, y; Glfw.GetCursorPosition(window, out x, out y); diff --git a/2DGAMELIB/_2DGAMELIB/rewrite/Common.cs b/2DGAMELIB/_2DGAMELIB/rewrite/Common.cs index 540096e..a8528ea 100644 --- a/2DGAMELIB/_2DGAMELIB/rewrite/Common.cs +++ b/2DGAMELIB/_2DGAMELIB/rewrite/Common.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Text; namespace _2DGAMELIB @@ -21,6 +22,26 @@ namespace _2DGAMELIB { return new PointF((float)Vector.X, (float)Vector.Y); } + + public static void ToText(this string str, string Path, Encoding Encoding) + { + using StreamWriter streamWriter = new StreamWriter(Path, append: false, Encoding); + streamWriter.Write(str); + } + + public static string FromText(this string Path) + { + using FileStream fileStream = new FileStream(Path, FileMode.Open, FileAccess.Read); + byte[] array = new byte[fileStream.Length]; + fileStream.Read(array, 0, array.Length); + using StreamReader streamReader = new StreamReader(new MemoryStream(array), array.GetEncoding()); + return streamReader.ReadToEnd(); + } + + public static string[] ReadLines(this string Path) + { + return Path.FromText().Replace("\r", "").Split('\n'); + } } public static class Math @@ -115,5 +136,50 @@ namespace _2DGAMELIB return System.Math.Min(Les - 1, System.Math.Max(Sta, Value)); } + + public static MatrixD RotationZ(this double angle) + { + MatrixD result = default(MatrixD); + result.M11 = System.Math.Cos(angle); + result.M12 = System.Math.Sin(angle); + result.M13 = 0.0; + result.M14 = 0.0; + result.M21 = 0.0 - result.M12; + result.M22 = result.M11; + result.M23 = 0.0; + result.M24 = 0.0; + result.M31 = 0.0; + result.M32 = 0.0; + result.M33 = 1.0; + result.M34 = 0.0; + result.M41 = 0.0; + result.M42 = 0.0; + result.M43 = 0.0; + result.M44 = 1.0; + return result; + } + + public static void TransformCoordinate(ref Vector2D coord, ref MatrixD transform, out Vector2D result) + { + double num = 1.0 / (coord.X * transform.M14 + coord.Y * transform.M24 + transform.M44); + result.X = (coord.X * transform.M11 + coord.Y * transform.M21 + transform.M41) * num; + result.Y = (coord.X * transform.M12 + coord.Y * transform.M22 + transform.M42) * num; + } + + public static Vector2D TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, MatrixD transform) + { + Vec.Subtract(ref coord, ref BasePoint, out coord); + TransformCoordinate(ref coord, ref transform, out var result); + Vec.Add(ref result, ref BasePoint, out result); + return result; + } + + public static Vector2D TransformCoordinateBP(ref Vector2D coord, ref Vector2D BasePoint, ref MatrixD transform) + { + Vec.Subtract(ref coord, ref BasePoint, out var r); + TransformCoordinate(ref r, ref transform, out var result); + Vec.Add(ref result, ref BasePoint, out result); + return result; + } } } diff --git a/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs b/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs index 7cddd21..5b4089f 100644 --- a/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs +++ b/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs @@ -73,7 +73,7 @@ namespace SlaveMatrix public double 濃度 = 1.0; - //TODO figure out what this broke... + //TODO this broke loading saves [NonSerialized] public Type ThisType; diff --git a/SlaveMatrix/SlaveMatrix/GameClasses/Sta.cs b/SlaveMatrix/SlaveMatrix/GameClasses/Sta.cs index 8a7d49e..9499f8e 100644 --- a/SlaveMatrix/SlaveMatrix/GameClasses/Sta.cs +++ b/SlaveMatrix/SlaveMatrix/GameClasses/Sta.cs @@ -1430,10 +1430,10 @@ namespace SlaveMatrix Translate(path, 0); } } - + public static string[] JSDPaths() { - JsonSavePath = Path.Combine(CurrentDirectory, "save", "json"); + JsonSavePath = Path.Combine(CurrentDirectory, "save"); IEnumerable source = Directory.EnumerateFiles(JsonSavePath); return new string[10] {