REDCODE Class Renaming

This commit is contained in:
lewd_alt
2026-06-13 22:38:57 -05:00
1921 changed files with 129982 additions and 45137 deletions

View File

@@ -7,17 +7,17 @@ using System.IO;
namespace _2DGAMELIB
{
[Serializable]
public class Obj
public class BodyTemplate
{
public OrderedDictionary<string, Difs> Difss = new OrderedDictionary<string, Difs>();
public OrderedDictionary<string, VariantGrid> Difss = new OrderedDictionary<string, VariantGrid>();
private Difs r;
private VariantGrid r;
private JointsD jsd;
public IEnumerable<string> Keys => Difss.Keys;
public Difs this[string Name]
public VariantGrid this[string Name]
{
get
{
@@ -29,11 +29,23 @@ namespace _2DGAMELIB
}
}
public VariantGrid this[int Index]
{
get
{
return Difss[Index];
}
set
{
Difss[Index] = value;
}
}
public double AngleBase
{
set
{
foreach (Difs value2 in Difss.Values)
foreach (VariantGrid value2 in Difss.Values)
{
value2.SetAngleBase(value);
}
@@ -44,35 +56,35 @@ namespace _2DGAMELIB
{
set
{
foreach (Difs value2 in Difss.Values)
foreach (VariantGrid value2 in Difss.Values)
{
value2.SetSizeBase(value);
}
}
}
public Difs JoinRoot => r;
public IEnumerable<Par> EnumAllPar()
public VariantGrid JoinRoot => r;
public IEnumerable<ShapePart> EnumAllPar()
{
foreach (Difs value in Difss.Values)
foreach (VariantGrid value in Difss.Values)
{
foreach (Par item in value.EnumAllPar())
foreach (ShapePart item in value.EnumAllPar())
{
yield return item;
}
}
}
public Obj SetDefaultR()
public BodyTemplate SetDefaultR()
{
foreach (Difs value in Difss.Values)
foreach (VariantGrid value in Difss.Values)
{
value.SetDefault();
}
return this;
}
public Obj()
public BodyTemplate()
{
}
@@ -80,29 +92,29 @@ namespace _2DGAMELIB
public void Draw(RenderArea Are)
{
foreach (Difs value in Difss.Values)
foreach (VariantGrid value in Difss.Values)
{
value.Draw(Are);
}
}
private Difs GetJoinRootDifs()
private VariantGrid GetJoinRootDifs()
{
Difs[] array = Difss.Values.ToArray();
VariantGrid[] array = Difss.Values.ToArray();
if (array.Length <= 1)
{
return array.FirstOrDefault();
}
Par[] pa = EnumAllPar().ToArray();
Difs[] array2 = array;
ShapePart[] pa = EnumAllPar().ToArray();
VariantGrid[] array2 = array;
Vector2D p;
foreach (Difs difs in array2)
foreach (VariantGrid difs in array2)
{
if (difs.EnumJoinRoot.All(delegate(Par p0)
if (difs.EnumJoinRoot.All(delegate(ShapePart p0)
{
p = p0.GetPosition();
return pa.All((Par p1) => p0 == p1 || p1.GetJP().All((Joi j) => !(p1.ToGlobal(j.Joint).DistanceSquared(p) <= Join.IdentityDistance)));
return pa.All((ShapePart p1) => p0 == p1 || p1.GetJP().All((JointPoint j) => !(p1.ToGlobal(j.Joint).DistanceSquared(p) <= JointLink.IdentityDistance)));
}))
{
return difs;
@@ -113,8 +125,8 @@ namespace _2DGAMELIB
public void SetJoints()
{
Difs[] array = Difss.Values.ToArray();
Difs[] array2 = array;
VariantGrid[] array = Difss.Values.ToArray();
VariantGrid[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
array2[i].SetJoints();
@@ -139,7 +151,7 @@ namespace _2DGAMELIB
public void Dispose()
{
foreach (Difs value in Difss.Values)
foreach (VariantGrid value in Difss.Values)
{
value.Dispose();
}

View File

@@ -5,7 +5,7 @@ using System.Linq;
namespace _2DGAMELIB
{
public class But1 : But
public class Button : ButtonBase
{
public List<Color> BaseColors = new List<Color>();
@@ -15,15 +15,15 @@ namespace _2DGAMELIB
public List<Color> TextColors = new List<Color>();
public But1(ParT ParT, Action<But> Action)
: base(ParT, Action)
public Button(ShapePartT ShapePartT, Action<ButtonBase> Action)
: base(ShapePartT, Action)
{
Setting();
}
private void Setting()
{
foreach (Par item in pars.EnumAllPar())
foreach (ShapePart item in partGroup.EnumAllPar())
{
BaseColors.Add(item.GetBrushColor());
OverColors.Add(BaseColors.Last().FuncHSV(delegate(Hsv hsv)
@@ -45,7 +45,7 @@ namespace _2DGAMELIB
Over = delegate
{
int num4 = 0;
foreach (Par item2 in pars.EnumAllPar())
foreach (ShapePart item2 in partGroup.EnumAllPar())
{
item2.SetBrushColor(OverColors[num4]);
if (item2.IsParT())
@@ -58,7 +58,7 @@ namespace _2DGAMELIB
Push = delegate
{
int num3 = 0;
foreach (Par item3 in pars.EnumAllPar())
foreach (ShapePart item3 in partGroup.EnumAllPar())
{
item3.SetBrushColor(PushColors[num3]);
if (item3.IsParT())
@@ -71,7 +71,7 @@ namespace _2DGAMELIB
Release = delegate
{
int num2 = 0;
foreach (Par item4 in pars.EnumAllPar())
foreach (ShapePart item4 in partGroup.EnumAllPar())
{
item4.SetBrushColor(OverColors[num2]);
if (item4.IsParT())
@@ -84,7 +84,7 @@ namespace _2DGAMELIB
Out = delegate
{
int num = 0;
foreach (Par item5 in pars.EnumAllPar())
foreach (ShapePart item5 in partGroup.EnumAllPar())
{
item5.SetBrushColor(BaseColors[num]);
if (item5.IsParT())

View File

@@ -3,31 +3,31 @@ using System.Drawing;
namespace _2DGAMELIB
{
public class But
public class ButtonBase
{
private bool dra = true;
private Color hc = Color.Transparent;
protected Pars pars;
protected PartGroup partGroup;
protected Action<But> Over = delegate
protected Action<ButtonBase> Over = delegate
{
};
protected Action<But> Push = delegate
protected Action<ButtonBase> Push = delegate
{
};
protected Action<But> Release = delegate
protected Action<ButtonBase> Release = delegate
{
};
protected Action<But> Out = delegate
protected Action<ButtonBase> Out = delegate
{
};
public Action<But> Action = delegate
public Action<ButtonBase> Action = delegate
{
};
@@ -48,23 +48,23 @@ namespace _2DGAMELIB
}
}
public Pars Pars => pars;
public PartGroup PartGroup => partGroup;
public But(ParT ParT, Action<But> Action)
public ButtonBase(ShapePartT ShapePartT, Action<ButtonBase> Action)
{
pars = new Pars(ParT);
partGroup = new PartGroup(ShapePartT);
this.Action = Action;
}
public bool Move(ref Color HitColor)
{
if (Dra && !f2 && pars.IsHit(ref HitColor))
if (Dra && !f2 && partGroup.IsHit(ref HitColor))
{
f2 = true;
Over(this);
return true;
}
if (Dra && f2 && !pars.IsHit(ref HitColor))
if (Dra && f2 && !partGroup.IsHit(ref HitColor))
{
f1 = false;
f2 = false;
@@ -88,7 +88,7 @@ namespace _2DGAMELIB
public bool Down(ref Color HitColor)
{
if (Dra && !f1 && pars.IsHit(ref HitColor))
if (Dra && !f1 && partGroup.IsHit(ref HitColor))
{
f1 = true;
Push(this);
@@ -99,7 +99,7 @@ namespace _2DGAMELIB
public bool Up(ref Color HitColor)
{
if (Dra && f1 && pars.IsHit(ref HitColor))
if (Dra && f1 && partGroup.IsHit(ref HitColor))
{
f1 = false;
Release(this);
@@ -113,13 +113,13 @@ namespace _2DGAMELIB
{
if (dra)
{
Are.Draw(pars);
Are.Draw(partGroup);
}
}
public void SetHitColor(ModeEventDispatcher Med)
{
foreach (Par item in pars.EnumAllPar())
foreach (ShapePart item in partGroup.EnumAllPar())
{
if (item.GetHitColor() != Color.Transparent)
{
@@ -131,7 +131,7 @@ namespace _2DGAMELIB
public void Dispose()
{
pars.Dispose();
partGroup.Dispose();
}
}
}

View File

@@ -4,22 +4,22 @@ using System.Linq;
namespace _2DGAMELIB
{
public class Buts
public class ButtonMap
{
private OrderedDictionary<string, But> buts = new OrderedDictionary<string, But>();
private OrderedDictionary<string, ButtonBase> buts = new OrderedDictionary<string, ButtonBase>();
public But this[string Name] => buts[Name];
public ButtonBase this[string Name] => buts[Name];
public IEnumerable<But> EnumBut => buts.Values;
public IEnumerable<ButtonBase> EnumBut => buts.Values;
public void Add(string Name, But But)
public void Add(string Name, ButtonBase ButtonBase)
{
buts.Add(Name, But);
buts.Add(Name, ButtonBase);
}
public void Down(ref Color HitColor)
{
using IEnumerator<But> enumerator = buts.Values.GetEnumerator();
using IEnumerator<ButtonBase> enumerator = buts.Values.GetEnumerator();
while (enumerator.MoveNext() && !enumerator.Current.Down(ref HitColor))
{
}
@@ -27,7 +27,7 @@ namespace _2DGAMELIB
public void Up(ref Color HitColor)
{
using IEnumerator<But> enumerator = buts.Values.GetEnumerator();
using IEnumerator<ButtonBase> enumerator = buts.Values.GetEnumerator();
while (enumerator.MoveNext() && !enumerator.Current.Up(ref HitColor))
{
}
@@ -35,7 +35,7 @@ namespace _2DGAMELIB
public void Move(ref Color HitColor)
{
foreach (But value in buts.Values)
foreach (ButtonBase value in buts.Values)
{
value.Move(ref HitColor);
}
@@ -43,7 +43,7 @@ namespace _2DGAMELIB
public void Leave()
{
using IEnumerator<But> enumerator = buts.Values.GetEnumerator();
using IEnumerator<ButtonBase> enumerator = buts.Values.GetEnumerator();
while (enumerator.MoveNext() && !enumerator.Current.Leave())
{
}
@@ -51,7 +51,7 @@ namespace _2DGAMELIB
public void SetHitColor(ModeEventDispatcher Med)
{
foreach (But item in EnumBut)
foreach (ButtonBase item in EnumBut)
{
item.SetHitColor(Med);
}
@@ -59,7 +59,7 @@ namespace _2DGAMELIB
public void Draw(RenderArea Are)
{
foreach (But value in buts.Values)
foreach (ButtonBase value in buts.Values)
{
value.Draw(Are);
}
@@ -67,7 +67,7 @@ namespace _2DGAMELIB
public void Dispose()
{
foreach (But value in buts.Values)
foreach (ButtonBase value in buts.Values)
{
value.Dispose();
}

View File

@@ -6,22 +6,22 @@ namespace _2DGAMELIB
//outline/path/line basically represents a curve :3
[Serializable]
public class Out
public class CurveOutline
{
public List<Vector2D> ps = new List<Vector2D>();
public float Tension = 0.5f;
public bool Outline = true;
public Out()
public CurveOutline()
{
}
public Out(Out Out)
public CurveOutline(CurveOutline CurveOutline)
{
ps = new List<Vector2D>(Out.ps);
Tension = Out.Tension;
Outline = Out.Outline;
ps = new List<Vector2D>(CurveOutline.ps);
Tension = CurveOutline.Tension;
Outline = CurveOutline.Outline;
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Runtime.InteropServices;
namespace _2DGAMELIB
{
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct Dat
public struct DataConsts
{
public static MatrixD MatDZero = new MatrixD(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);

View File

@@ -1,132 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing;
namespace _2DGAMELIB
{
[Serializable]
public class Dif
{
public string Tag = "";
private List<Pars> parss = new List<Pars>();
public List<Pars> Parss => parss;
public int Count => parss.Count;
public Pars this[int Index]
{
get
{
return parss[Index];
}
set
{
parss[Index] = value;
}
}
public void SetAngleBase(double value)
{
foreach (Pars item in parss)
{
item.SetAngleBase(value);
}
}
public void SetSizeBase(double value)
{
foreach (Pars item in parss)
{
item.SetSizeBase(value);
}
}
public void SetSizeYCont(double value)
{
foreach (Pars item in parss)
{
item.SetSizeYCont(value);
}
}
public IEnumerable<Par> EnumAllPar()
{
foreach (Pars item in parss)
{
foreach (Par item2 in item.EnumAllPar())
{
yield return item2;
}
}
}
public void SetDefault()
{
foreach (Pars item in parss)
{
item.SetDefault();
}
}
public Dif()
{
}
public Dif(Dif Dif)
{
Copy(Dif);
}
private void Copy(Dif Dif)
{
Tag = Dif.Tag;
foreach (Pars item in Dif.parss)
{
parss.Add(new Pars(item));
}
}
public void Add(Pars Pars)
{
parss.Add(Pars);
}
public bool IsHit(ref Color HitColor)
{
foreach (Pars item in parss)
{
if (item.IsHit(ref HitColor))
{
return true;
}
}
return false;
}
public void ReverseX()
{
foreach (Pars item in parss)
{
item.ReverseX();
}
}
public void ReverseY()
{
foreach (Pars item in parss)
{
item.ReverseY();
}
}
public void Dispose()
{
foreach (Pars item in parss)
{
item.Dispose();
}
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Diagnostics;
namespace _2DGAMELIB
{
public class FPS
public class FpsCounter
{
public Stopwatch sw = new Stopwatch();
@@ -11,7 +11,7 @@ namespace _2DGAMELIB
public double Value;
private double ticks_per_frame;
public FPS(double FPS)
public FpsCounter(double FPS)
{
Value = FPS;
ticks_per_frame = (double)Stopwatch.Frequency / FPS;

View File

@@ -7,7 +7,7 @@ using System.Text;
namespace _2DGAMELIB
{
public static class Oth
public static class GeometryUtils
{
public static Color Reverse(this Color c)
{
@@ -16,7 +16,7 @@ namespace _2DGAMELIB
public static void GetRandomColor(out Color ret)
{
ret = Color.FromArgb(255, RNG.XS.Next(256), RNG.XS.Next(256), RNG.XS.Next(256));
ret = Color.FromArgb(255, Rng.XS.Next(256), Rng.XS.Next(256), Rng.XS.Next(256));
}
public static Color GetInter(ref Color c1, ref Color c2)
@@ -31,7 +31,7 @@ namespace _2DGAMELIB
public static Vector2D GetRandomVector()
{
return new Vector2D(RNG.XS.NextDouble() * (double)(RNG.XS.NextBool() ? 1 : (-1)), RNG.XS.NextDouble() * (double)(RNG.XS.NextBool() ? 1 : (-1)));
return new Vector2D(Rng.XS.NextDouble() * (double)(Rng.XS.NextBool() ? 1 : (-1)), Rng.XS.NextDouble() * (double)(Rng.XS.NextBool() ? 1 : (-1)));
}
public static Color FuncHSV(this Color Color, Func<Hsv, Hsv> Func)
@@ -60,13 +60,13 @@ namespace _2DGAMELIB
};
}
private static void GetMinMaxX(Par Par, ref double MinX, ref double MaxX)
private static void GetMinMaxX(ShapePart ShapePart, ref double MinX, ref double MaxX)
{
foreach (Out item in Par.GetOP())
foreach (CurveOutline item in ShapePart.GetOP())
{
foreach (Vector2D p in item.ps)
{
Vector2D vector2D = Par.ToGlobal(p);
Vector2D vector2D = ShapePart.ToGlobal(p);
if (MinX > vector2D.X)
{
MinX = vector2D.X;
@@ -79,13 +79,13 @@ namespace _2DGAMELIB
}
}
private static void GetMinMaxY(Par Par, ref double MinY, ref double MaxY)
private static void GetMinMaxY(ShapePart ShapePart, ref double MinY, ref double MaxY)
{
foreach (Out item in Par.GetOP())
foreach (CurveOutline item in ShapePart.GetOP())
{
foreach (Vector2D p in item.ps)
{
Vector2D vector2D = Par.ToGlobal(p);
Vector2D vector2D = ShapePart.ToGlobal(p);
if (MinY > vector2D.Y)
{
MinY = vector2D.Y;
@@ -98,7 +98,7 @@ namespace _2DGAMELIB
}
}
private static void GetMinMaxY(Par[] Pars, ref double MinY, ref double MaxY)
private static void GetMinMaxY(ShapePart[] Pars, ref double MinY, ref double MaxY)
{
for (int i = 0; i < Pars.Length; i++)
{
@@ -106,67 +106,79 @@ namespace _2DGAMELIB
}
}
public static void GetMiX_MaX(this Par Par, out Vector2D[] MM)
public static void GetMiX_MaX(this ShapePart ShapePart, out Vector2D[] MM)
{
Vector2D vector2D = Par.ToGlobal(Par.GetOP().First().ps.First());
Vector2D vector2D = ShapePart.ToGlobal(ShapePart.GetOP().First().ps.First());
MM = new Vector2D[2];
MM[0].X = vector2D.X;
MM[1].X = vector2D.X;
GetMinMaxX(Par, ref MM[0].X, ref MM[1].X);
GetMinMaxX(ShapePart, ref MM[0].X, ref MM[1].X);
}
public static void GetMaX_MiX(this Par Par, out Vector2D[] MM)
public static void GetMaX_MiX(this ShapePart ShapePart, out Vector2D[] MM)
{
Vector2D vector2D = Par.ToGlobal(Par.GetOP().First().ps.First());
Vector2D vector2D = ShapePart.ToGlobal(ShapePart.GetOP().First().ps.First());
MM = new Vector2D[2];
MM[0].X = vector2D.X;
MM[1].X = vector2D.X;
GetMinMaxX(Par, ref MM[1].X, ref MM[0].X);
GetMinMaxX(ShapePart, ref MM[1].X, ref MM[0].X);
}
public static void GetMiY_MaY(this Par Par, out Vector2D[] MM)
public static void GetMiY_MaY(this ShapePart ShapePart, out Vector2D[] MM)
{
Vector2D vector2D = Par.ToGlobal(Par.GetOP().First().ps.First());
Vector2D vector2D = ShapePart.ToGlobal(ShapePart.GetOP().First().ps.First());
MM = new Vector2D[2];
MM[0].Y = vector2D.Y;
MM[1].Y = vector2D.Y;
GetMinMaxY(Par, ref MM[0].Y, ref MM[1].Y);
GetMinMaxY(ShapePart, ref MM[0].Y, ref MM[1].Y);
}
public static void GetMiY_MaY(this Par[] Pars, out Vector2D[] MM)
public static void GetMiY_MaY(this ShapePart[] Pars, out Vector2D[] MM)
{
Par par = Pars.First();
Vector2D vector2D = par.ToGlobal(par.GetOP().First().ps.First());
ShapePart shapePart = Pars.First();
Vector2D vector2D = shapePart.ToGlobal(shapePart.GetOP().First().ps.First());
MM = new Vector2D[2];
MM[0].Y = vector2D.Y;
MM[1].Y = vector2D.Y;
GetMinMaxY(Pars, ref MM[0].Y, ref MM[1].Y);
}
public static void GetMaY_MiY(this Par Par, out Vector2D[] MM)
public static void GetMaY_MiY(this ShapePart ShapePart, out Vector2D[] MM)
{
Vector2D vector2D = Par.ToGlobal(Par.GetOP().First().ps.First());
Vector2D vector2D = ShapePart.ToGlobal(ShapePart.GetOP().First().ps.First());
MM = new Vector2D[2];
MM[0].Y = vector2D.Y;
MM[1].Y = vector2D.Y;
GetMinMaxY(Par, ref MM[1].Y, ref MM[0].Y);
GetMinMaxY(ShapePart, ref MM[1].Y, ref MM[0].Y);
}
public static Obj ObjLoad(this byte[] bd)
{
return bd.Load<byte[]>().ToDeserialObject<Obj>().SetDefaultR();
public static BodyTemplate ObjLoad(this byte[] bd)
{
return bd.Load<byte[]>().ToDeserialObject<BodyTemplate>().SetDefaultR();
}
public static BodyTemplate? ObjLoadRaw(this byte[] bd)
{
try
{
return bd.Load<byte[]>().ToDeserialObject<BodyTemplate>();
}
catch
{
return null;
}
}
public static bool Lot(this double p)
{
return RNG.XS.NextDouble() < p;
return Rng.XS.NextDouble() < p;
}
public static int GetRandomIndex(params double[] WeightTable)
{
double les = WeightTable.Sum();
double num = RNG.XS.NextDouble(les);
double num = Rng.XS.NextDouble(les);
int result = -1;
for (int i = 0; i < WeightTable.Length; i++)
{
@@ -333,7 +345,7 @@ namespace _2DGAMELIB
return string.Join(Separator, strs);
}
static Oth()
static GeometryUtils()
{
}

View File

@@ -1,24 +0,0 @@
using System;
using System.IO;
namespace _2DGAMELIB
{
//its the position of a joint
[Serializable]
public class Joi
{
public Vector2D Joint = Dat.Vec2DZero;
public Joi(Joi Joi)
{
Joint = Joi.Joint;
}
public Joi(Vector2D Joint)
{
this.Joint = Joint;
}
}
}

View File

@@ -5,13 +5,13 @@ namespace _2DGAMELIB
[Serializable]
public class Joint
{
public Par Par0;
public ShapePart Par0;
public int Index;
public Par Par1;
public ShapePart Par1;
public Joint(Par Par0, int Index, Par Par1)
public Joint(ShapePart Par0, int Index, ShapePart Par1)
{
this.Par0 = Par0;
this.Index = Index;

View File

@@ -6,15 +6,15 @@ namespace _2DGAMELIB
[Serializable]
public class JointD
{
public Difs Difs0;
public VariantGrid Difs0;
public List<int> Path0;
public int Index;
public Difs Difs1;
public VariantGrid Difs1;
public JointD(Difs Difs0, Par Par0, int Index, Difs Difs1)
public JointD(VariantGrid Difs0, ShapePart Par0, int Index, VariantGrid Difs1)
{
this.Difs0 = Difs0;
Path0 = Par0.GetPath();
@@ -22,7 +22,7 @@ namespace _2DGAMELIB
this.Difs1 = Difs1;
}
public JointD(Difs Difs1)
public JointD(VariantGrid Difs1)
{
this.Difs1 = Difs1;
}
@@ -41,7 +41,7 @@ namespace _2DGAMELIB
public void Set(JointS )
{
Difs0 = .Difs;
Difs0 = .VariantGrid;
Path0 = .Path;
Index = .Index;
}

View File

@@ -4,22 +4,22 @@ using System.Linq;
namespace _2DGAMELIB
{
public static class Join
public static class JointLink
{
public static double IdentityDistance = System.Math.Pow(5E-05, 2.0);
public static Joints GetJoints(this Par JoinRoot, IEnumerable<Par> EnumPar)
public static Joints GetJoints(this ShapePart JoinRoot, IEnumerable<ShapePart> EnumPar)
{
Joints joints = new Joints();
int num = 0;
List<int> list = new List<int>();
List<Par> list2 = EnumPar.ToList();
foreach (Joi item in JoinRoot.GetJP())
List<ShapePart> list2 = EnumPar.ToList();
foreach (JointPoint item in JoinRoot.GetJP())
{
Vector2D v = JoinRoot.ToGlobal(item.Joint);
int num2 = 0;
list.Clear();
foreach (Par item2 in list2)
foreach (ShapePart item2 in list2)
{
if (JoinRoot != item2)
{
@@ -48,7 +48,7 @@ namespace _2DGAMELIB
return joints;
}
private static void GetJoints(List<Par> pl, Joints js, List<int> del)
private static void GetJoints(List<ShapePart> pl, Joints js, List<int> del)
{
int num = -1;
int num2 = 0;
@@ -57,20 +57,20 @@ namespace _2DGAMELIB
num = js.Joins.Count;
for (int i = num2; i < num; i++)
{
Par par = js.Joins[i].Par1;
ShapePart shapePart = js.Joins[i].Par1;
int num3 = 0;
foreach (Joi item in par.GetJP())
foreach (JointPoint item in shapePart.GetJP())
{
Vector2D v = par.ToGlobal(item.Joint);
Vector2D v = shapePart.ToGlobal(item.Joint);
int num4 = 0;
del.Clear();
foreach (Par item2 in pl)
foreach (ShapePart item2 in pl)
{
if (par != item2)
if (shapePart != item2)
{
if (v.DistanceSquared(item2.GetPosition()) <= IdentityDistance)
{
js.Joins.Add(new Joint(par, num3, item2));
js.Joins.Add(new Joint(shapePart, num3, item2));
if (!del.Contains(num4))
{
del.Add(num4);
@@ -94,24 +94,24 @@ namespace _2DGAMELIB
}
}
public static JointsD GetJointsD(this Difs JoinRoot, IEnumerable<Difs> EnumDifs)
public static JointsD GetJointsD(this VariantGrid JoinRoot, IEnumerable<VariantGrid> EnumDifs)
{
JointsD jointsD = new JointsD();
List<int> list = new List<int>();
List<Difs> list2 = EnumDifs.ToList();
foreach (Par item in JoinRoot.EnumAllPar())
List<VariantGrid> list2 = EnumDifs.ToList();
foreach (ShapePart item in JoinRoot.EnumAllPar())
{
int num = 0;
list.Clear();
foreach (Difs item2 in list2)
foreach (VariantGrid item2 in list2)
{
if (JoinRoot != item2)
{
int num2 = 0;
foreach (Joi item3 in item.GetJP())
foreach (JointPoint item3 in item.GetJP())
{
Vector2D v = item.ToGlobal(item3.Joint);
foreach (Par item4 in item2.EnumJoinRoot)
foreach (ShapePart item4 in item2.EnumJoinRoot)
{
if (v.DistanceSquared(item4.GetPosition()) <= IdentityDistance)
{
@@ -141,7 +141,7 @@ namespace _2DGAMELIB
return jointsD;
}
private static void GetJointsD(List<Difs> dl, JointsD jsd, List<int> del)
private static void GetJointsD(List<VariantGrid> dl, JointsD jsd, List<int> del)
{
int num = -1;
int num2 = 0;
@@ -150,24 +150,24 @@ namespace _2DGAMELIB
num = jsd.Joins.Count;
for (int i = num2; i < num; i++)
{
Difs difs = jsd.Joins[i].Difs1;
foreach (Par item in difs.EnumAllPar())
VariantGrid variantGrid = jsd.Joins[i].Difs1;
foreach (ShapePart item in variantGrid.EnumAllPar())
{
int num3 = 0;
del.Clear();
foreach (Difs item2 in dl)
foreach (VariantGrid item2 in dl)
{
if (difs != item2)
if (variantGrid != item2)
{
int num4 = 0;
foreach (Joi item3 in item.GetJP())
foreach (JointPoint item3 in item.GetJP())
{
Vector2D v = item.ToGlobal(item3.Joint);
foreach (Par item4 in item2.EnumJoinRoot)
foreach (ShapePart item4 in item2.EnumJoinRoot)
{
if (v.DistanceSquared(item4.GetPosition()) <= IdentityDistance)
{
jsd.Joins.Add(new JointD(difs, item, num4, item2));
jsd.Joins.Add(new JointD(variantGrid, item, num4, item2));
if (!del.Contains(num3))
{
del.Add(num3);

View File

@@ -0,0 +1,24 @@
using System;
using System.IO;
namespace _2DGAMELIB
{
//its the position of a joint
[Serializable]
public class JointPoint
{
public Vector2D Joint = DataConsts.Vec2DZero;
public JointPoint(JointPoint JointPoint)
{
Joint = JointPoint.Joint;
}
public JointPoint(Vector2D Joint)
{
this.Joint = Joint;
}
}
}

View File

@@ -27,16 +27,16 @@ namespace _2DGAMELIB
[Serializable]
public class JointS
{
public Difs Difs;
public VariantGrid VariantGrid;
public List<int> Path;
public int Index;
public JointS(Difs Difs, Par Par, int Index)
public JointS(VariantGrid VariantGrid, ShapePart ShapePart, int Index)
{
this.Difs = Difs;
Path = Par.GetPath();
this.VariantGrid = VariantGrid;
Path = ShapePart.GetPath();
this.Index = Index;
}
}

View File

@@ -5,7 +5,7 @@ namespace _2DGAMELIB
{
public class Lab
{
private ParT parT;
private ShapePartT _shapePartT;
private RenderArea Are;
@@ -13,13 +13,13 @@ namespace _2DGAMELIB
private double Min;
public ParT ParT => parT;
public ShapePartT ShapePartT => _shapePartT;
public string Text
{
get
{
return parT.Text;
return _shapePartT.Text;
}
set
{
@@ -29,7 +29,7 @@ namespace _2DGAMELIB
private void SetText(string Text)
{
parT.Text = Text;
_shapePartT.Text = Text;
SetRect();
}
@@ -48,75 +48,75 @@ namespace _2DGAMELIB
this.Are = Are;
this.Width = Width;
Out[] array = new Out[1] { Shas.GetSquare() };
CurveOutline[] array = new CurveOutline[1] { ShapeHelper.GetSquare() };
if (FramColor == Color.Empty || FramColor == Color.Transparent)
{
array.OutlineFalse();
}
parT = new ParT
_shapePartT = new ShapePartT
{
Tag = Name,
Text = "A"
};
parT.SetFont(Font);
parT.SetFontSize(TextSize);
parT.SetTextColor(TextColor);
parT.SetInitializeOP(array);
parT.SetBasePointBase(array[0].ps[0]);
parT.SetPositionBase(Position);
parT.SetSizeBase(Size);
parT.SetClosed(true);
parT.SetBrushColor(BackColor);
parT.SetPenColor(FramColor);
_shapePartT.SetFont(Font);
_shapePartT.SetFontSize(TextSize);
_shapePartT.SetTextColor(TextColor);
_shapePartT.SetInitializeOP(array);
_shapePartT.SetBasePointBase(array[0].ps[0]);
_shapePartT.SetPositionBase(Position);
_shapePartT.SetSizeBase(Size);
_shapePartT.SetClosed(true);
_shapePartT.SetBrushColor(BackColor);
_shapePartT.SetPenColor(FramColor);
if (ShadColor != Color.Empty)
{
parT.SetShadBrush(new SolidBrush(ShadColor));
_shapePartT.SetShadBrush(new SolidBrush(ShadColor));
}
SetRect();
Min = parT.GetRectSize().Y;
Min = _shapePartT.GetRectSize().Y;
SetText(Text);
}
public void SetHitColor(ModeEventDispatcher Med)
{
if (parT.GetHitColor() != Color.Transparent)
if (_shapePartT.GetHitColor() != Color.Transparent)
{
Med.RemUniqueColor(parT.GetHitColor());
Med.RemUniqueColor(_shapePartT.GetHitColor());
}
parT.SetHitColor(Med.GetUniqueColor());
_shapePartT.SetHitColor(Med.GetUniqueColor());
}
private void SetRect()
{
if (!string.IsNullOrEmpty(parT.Text))
if (!string.IsNullOrEmpty(_shapePartT.Text))
{
parT.SetRectSize(new Vector2D(Width, 10.0));
Vector2D_2 stringRect = parT.GetStringRect(Are.DisplayUnitScale, Are.DisplayGraphics);
_shapePartT.SetRectSize(new Vector2D(Width, 10.0));
Vector2D_2 stringRect = _shapePartT.GetStringRect(Are.DisplayUnitScale, Are.DisplayGraphics);
double x = ((stringRect.v2.X > Min) ? stringRect.v2.X : Min) + 0.07;
parT.SetRectSize(new Vector2D(x, stringRect.v2.Y));
_shapePartT.SetRectSize(new Vector2D(x, stringRect.v2.Y));
}
else
{
double x2 = Min + 0.07;
parT.SetRectSize(new Vector2D(x2, Min));
_shapePartT.SetRectSize(new Vector2D(x2, Min));
}
parT.GetOP()[0].ps[0] = new Vector2D(0.0, 0.0);
parT.GetOP()[0].ps[1] = new Vector2D(parT.GetRectSize().X, 0.0);
parT.GetOP()[0].ps[2] = new Vector2D(parT.GetRectSize().X, parT.GetRectSize().Y);
parT.GetOP()[0].ps[3] = new Vector2D(0.0, parT.GetRectSize().Y);
_shapePartT.GetOP()[0].ps[0] = new Vector2D(0.0, 0.0);
_shapePartT.GetOP()[0].ps[1] = new Vector2D(_shapePartT.GetRectSize().X, 0.0);
_shapePartT.GetOP()[0].ps[2] = new Vector2D(_shapePartT.GetRectSize().X, _shapePartT.GetRectSize().Y);
_shapePartT.GetOP()[0].ps[3] = new Vector2D(0.0, _shapePartT.GetRectSize().Y);
}
public void Dispose()
{
parT.Dispose();
_shapePartT.Dispose();
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Drawing;
namespace _2DGAMELIB
{
public class Labs
public class LabelMap
{
private OrderedDictionary<string, Lab> labs = new OrderedDictionary<string, Lab>();
@@ -13,7 +13,7 @@ namespace _2DGAMELIB
public Lab this[string Name] => labs[Name];
public Labs(ModeEventDispatcher Med, RenderArea Are)
public LabelMap(ModeEventDispatcher Med, RenderArea Are)
{
this.Med = Med;
this.Are = Are;
@@ -28,7 +28,7 @@ namespace _2DGAMELIB
{
foreach (Lab value in labs.Values)
{
Are.Draw(value.ParT);
Are.Draw(value.ShapePartT);
}
}

View File

@@ -3,13 +3,14 @@ using System.Drawing.Drawing2D;
namespace _2DGAMELIB
{
public class AreM : RenderArea
//TODO: Find a better name...
public class ManagedArea : RenderArea
{
private double strength;
private double unitS;
public AreM(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength) :
public ManagedArea(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength) :
base(Unit, XRatio, YRatio, Size, DisMag, HitMag)
{
SetXYRatio(XRatio, YRatio);
@@ -40,12 +41,12 @@ namespace _2DGAMELIB
hitGraphics.PixelOffsetMode = PixelOffsetMode.None;
}
public new void Draw(Pars Pars)
public new void Draw(PartGroup PartGroup)
{
Pars.Draw(unitS, displayGraphics);
PartGroup.Draw(unitS, displayGraphics);
if (hitGraphics != null)
{
Pars.DrawH(hitUnitScale, hitGraphics);
PartGroup.DrawH(hitUnitScale, hitGraphics);
}
}
}

View File

@@ -29,11 +29,11 @@ namespace _2DGAMELIB
public Bitmap Hit;
public Graphics HitGraphics;
public Sce Sce;
public FPS FPSF = new FPS(60.0);
public SceneFader SceneFader;
public FpsCounter FPSF = new FpsCounter(60.0);
private Size BaseSize = Size.Empty;
private Vector2D resVector = Dat.Vec2DZero;
private Vector2D resVector = DataConsts.Vec2DZero;
public string UITitle;
@@ -60,11 +60,11 @@ namespace _2DGAMELIB
}
set
{
Modes[mode].Up(MouseButtons.None, Dat.Vec2DZero, Color.Empty);
Modes[mode].Move(MouseButtons.None, Dat.Vec2DZero, Color.Empty);
Modes[mode].Up(MouseButtons.None, DataConsts.Vec2DZero, Color.Empty);
Modes[mode].Move(MouseButtons.None, DataConsts.Vec2DZero, Color.Empty);
Modeb = mode;
mode = value;
Modes[mode].Move(MouseButtons.None, Dat.Vec2DZero, Color.Empty);
Modes[mode].Move(MouseButtons.None, DataConsts.Vec2DZero, Color.Empty);
Modes[mode].Setting();
}
}
@@ -84,12 +84,12 @@ namespace _2DGAMELIB
public void FadeIn(double Rate)
{
Sce.TransformAlpha(DisplayGraphics, Rate);
SceneFader.TransformAlpha(DisplayGraphics, Rate);
}
public void FadeOut(double Rate)
{
Sce.TransD(DisplayGraphics, Rate);
SceneFader.TransD(DisplayGraphics, Rate);
}
public void InitializeModes(string Mode, Func<ModeEventDispatcher, Dictionary<string, Module>> GetModes)
@@ -121,7 +121,7 @@ namespace _2DGAMELIB
WidthM = Hit.Width - 1;
HeightM = Hit.Height - 1;
Sce = new Sce(BaseSize.Width, BaseSize.Height);
SceneFader = new SceneFader(BaseSize.Width, BaseSize.Height);
Modes = GetModes(this);
@@ -347,10 +347,10 @@ namespace _2DGAMELIB
//hit color stuff
public Color GetUniqueColor()
{
Oth.GetRandomColor(out var ret);
GeometryUtils.GetRandomColor(out var ret);
while (HitColors.Contains(ret))
{
Oth.GetRandomColor(out ret);
GeometryUtils.GetRandomColor(out ret);
}
HitColors.Add(ret);
return ret;
@@ -358,17 +358,17 @@ namespace _2DGAMELIB
public void GetUniqueColor(out Color c)
{
Oth.GetRandomColor(out c);
GeometryUtils.GetRandomColor(out c);
while (HitColors.Contains(c))
{
Oth.GetRandomColor(out c);
GeometryUtils.GetRandomColor(out c);
}
HitColors.Add(c);
}
public void SetUniqueColor(IEnumerable<Par> ps)
public void SetUniqueColor(IEnumerable<ShapePart> ps)
{
foreach (Par p in ps)
foreach (ShapePart p in ps)
{
p.SetHitColor(GetUniqueColor());
}
@@ -379,9 +379,9 @@ namespace _2DGAMELIB
HitColors.Remove(Color);
}
public void RemUniqueColor(IEnumerable<Par> ps)
public void RemUniqueColor(IEnumerable<ShapePart> ps)
{
foreach (Par p in ps)
foreach (ShapePart p in ps)
{
HitColors.Remove(p.GetHitColor());
}

View File

@@ -3,6 +3,9 @@ using System.Drawing;
namespace _2DGAMELIB
{
/// <summary>
/// Represents a screen module/mode
/// </summary>
public class Module
{
public Action<MouseButtons, Vector2D, Color> Down = delegate
@@ -25,7 +28,7 @@ namespace _2DGAMELIB
{
};
public Action<FPS> Draw = delegate
public Action<FpsCounter> Draw = delegate
{
};

View File

@@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
using System.Drawing;
namespace _2DGAMELIB
{
[Serializable]
public class MorphVariant
{
public string Tag = "";
private List<PartGroup> parss = new List<PartGroup>();
public List<PartGroup> Parss => parss;
public int Count => parss.Count;
public PartGroup this[int Index]
{
get
{
return parss[Index];
}
set
{
parss[Index] = value;
}
}
public void SetAngleBase(double value)
{
foreach (PartGroup item in parss)
{
item.SetAngleBase(value);
}
}
public void SetSizeBase(double value)
{
foreach (PartGroup item in parss)
{
item.SetSizeBase(value);
}
}
public void SetSizeYCont(double value)
{
foreach (PartGroup item in parss)
{
item.SetSizeYCont(value);
}
}
public IEnumerable<ShapePart> EnumAllPar()
{
foreach (PartGroup item in parss)
{
foreach (ShapePart item2 in item.EnumAllPar())
{
yield return item2;
}
}
}
public void SetDefault()
{
foreach (PartGroup item in parss)
{
item.SetDefault();
}
}
public MorphVariant()
{
}
public MorphVariant(MorphVariant MorphVariant)
{
Copy(MorphVariant);
}
private void Copy(MorphVariant MorphVariant)
{
Tag = MorphVariant.Tag;
foreach (PartGroup item in MorphVariant.parss)
{
parss.Add(new PartGroup(item));
}
}
public void Add(PartGroup PartGroup)
{
parss.Add(PartGroup);
}
public List<string> GetHitTags(ref Color HitColor)
{
List<string> list = new List<string>();
foreach (PartGroup item in parss)
{
list.AddRange(item.GetHitTags(ref HitColor));
}
return list;
}
public List<ShapePart> GetHitPars(ref Color HitColor)
{
List<ShapePart> list = new List<ShapePart>();
foreach (PartGroup item in parss)
{
list.AddRange(item.GetHitPars(ref HitColor));
}
return list;
}
public bool IsHit(ref Color HitColor)
{
foreach (PartGroup item in parss)
{
if (item.IsHit(ref HitColor))
{
return true;
}
}
return false;
}
public void ReverseX()
{
foreach (PartGroup item in parss)
{
item.ReverseX();
}
}
public void ReverseY()
{
foreach (PartGroup item in parss)
{
item.ReverseY();
}
}
public void Dispose()
{
foreach (PartGroup item in parss)
{
item.Dispose();
}
}
}
}

View File

@@ -2,7 +2,7 @@ using System;
namespace _2DGAMELIB
{
public class Motion : MotV
public class Motion : MotionBase
{
public Action<Motion> OnStart;
@@ -25,7 +25,7 @@ namespace _2DGAMELIB
{
}
public new void GetValue(FPS FPS)
public new void GetValue(FpsCounter FPS)
{
if (!run)
{

View File

@@ -1,6 +1,6 @@
namespace _2DGAMELIB
{
public class MotV
public class MotionBase
{
public double Value;
@@ -58,7 +58,7 @@ namespace _2DGAMELIB
}
}
public MotV(double Min, double Max)
public MotionBase(double Min, double Max)
{
min = Min;
max = Max;
@@ -78,13 +78,13 @@ namespace _2DGAMELIB
Value = min;
}
private void Count(FPS FPS)
private void Count(FpsCounter FPS)
{
m = Frame / FPS.Value;
Value += (m * d + m * LowestIncrease) * BaseSpeed * ((s > 0) ? GotoSpeed : RetuSpeed) * (double)s;
}
public void GetValue(FPS FPS)
public void GetValue(FpsCounter FPS)
{
if (!((double)(FPS.sw.ElapsedMilliseconds - st) < Interval) && FPS.Value > 0.0)
{

View File

@@ -35,7 +35,7 @@ namespace _2DGAMELIB
ms.Remove(Name);
}
public void Drive(FPS FPS)
public void Drive(FpsCounter FPS)
{
foreach (Motion value in ms.Values)
{

View File

@@ -28,35 +28,22 @@ namespace _2DGAMELIB
["四足上腕"] = "四足UpperArm",
["鳥翼下腕"] = "鳥翼LowerArm",
["獣翼下腕"] = "獣翼LowerArm",
["四足下腕"] = "四足LowerArm"
//["乳房"] = "Breast",
//["腹"] = "Abdomen",
//["顔"] = "Face",
//["目"] = "Eye",
//["眉"] = "Eyebrow",
//["瞼"] = "Eyelid",
//["鼻"] = "Nose",
//["口"] = "Mouth",
//["耳"] = "Ear",
//["触覚"] = "Antenna",
//["髪"] = "Hair",
//["基髪"] = "BaseHair",
//["吹出し"] = "SpeechBubble",
["四足下腕"] = "四足LowerArm",
};
public static void MigrateKeys(this Obj obj)
public static void MigrateKeys(this BodyTemplate BodyTemplate)
{
var newDict = new OrderedDictionary<string, Difs>();
var newDict = new OrderedDictionary<string, VariantGrid>();
foreach (var key in obj.Keys)
foreach (var key in BodyTemplate.Keys)
{
var newKey = KeyMap.TryGetValue(key, out var mapped) ? mapped : key;
var difs = obj.Difss[key];
var difs = BodyTemplate.Difss[key];
newDict.Add(newKey, difs);
}
obj.Difss = newDict;
BodyTemplate.Difss = newDict;
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace _2DGAMELIB
{
public class OrderedDictionaryConverter<T1, T2> : JsonConverter<OrderedDictionary<T1, T2>>
where T1 : notnull
{
public override OrderedDictionary<T1, T2> ReadJson(JsonReader reader, Type objectType, OrderedDictionary<T1, T2> existingValue, bool hasExistingValue, JsonSerializer serializer)
{
var dict = new OrderedDictionary<T1, T2>();
if (reader.TokenType == JsonToken.Null)
return dict;
var array = JArray.Load(reader);
foreach (var item in array)
{
var key = item["Key"].ToObject<T1>(serializer);
var value = item["Value"].ToObject<T2>(serializer);
dict.Add(key, value);
}
return dict;
}
public override void WriteJson(JsonWriter writer, OrderedDictionary<T1, T2> value, JsonSerializer serializer)
{
writer.WriteStartArray();
foreach (var key in value.Keys)
{
writer.WriteStartObject();
writer.WritePropertyName("Key");
serializer.Serialize(writer, key);
writer.WritePropertyName("Value");
serializer.Serialize(writer, value[key]);
writer.WriteEndObject();
}
writer.WriteEndArray();
}
}
}

View File

@@ -1,340 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace _2DGAMELIB
{
[Serializable]
public class Pars
{
private Pars parent;
public string Tag = "";
public OrderedDictionary<string, object> pars = new OrderedDictionary<string, object>();
public Pars Parent => parent;
public IEnumerable<object> Values => pars.Values;
public void SetAngleBase(double value)
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).SetAngleBase(value);
}
else if (value2 is Par)
{
((Par)value2).SetAngleBase(value);
}
}
}
public void SetSizeBase(double value)
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).SetSizeBase(value);
}
else if (value2 is Par)
{
((Par)value2).SetSizeBase(value);
}
}
}
public void SetSizeYCont(double value)
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).SetSizeYCont(value);
}
else if (value2 is Par)
{
((Par)value2).SetSizeYCont(value);
}
}
}
public object this[string Name]
{
get
{
return pars[Name];
}
set
{
pars[Name] = value;
}
}
public void SetParent(Pars Parent)
{
parent = Parent;
}
public int IndexOf(object obj)
{
return pars.IndexOf(obj);
}
public void Add(string Name, Par Par)
{
Par.SetParent(this);
pars.Add(Name, Par);
}
public void Add(string Name, ParT ParT)
{
ParT.SetParent(this);
pars.Add(Name, ParT);
}
public void Add(string Name, Pars Pars)
{
Pars.SetParent(this);
pars.Add(Name, Pars);
}
public void Add(Pars Pars)
{
Pars.SetParent(this);
pars.Add(Pars.Tag, Pars);
}
public void Remove(string Name)
{
object obj = pars[Name];
if (obj is Pars)
{
((Pars)obj).SetParent(null);
}
else if (obj is ParT)
{
((ParT)obj).SetParent(null);
}
else if (obj is Par)
{
((Par)obj).SetParent(null);
}
pars.Remove(Name);
}
public IEnumerable<Par> EnumAllPar()
{
foreach (object value in pars.Values)
{
if (value is Pars)
{
foreach (Par item in ((Pars)value).EnumAllPar())
{
yield return item;
}
}
else if (value is Par)
{
yield return (Par)value;
}
}
}
public void SetDefault()
{
foreach (object value in pars.Values)
{
if (value is Pars)
{
((Pars)value).SetDefault();
}
else if (value is ParT)
{
((ParT)value).SetDefault();
}
else if (value is Par)
{
((Par)value).SetDefault();
}
}
}
public Pars()
{
}
public Pars(ParT ParT)
{
Tag = ParT.Tag;
Add(ParT.Tag, ParT);
}
public Pars(Pars Pars)
{
Copy(Pars);
}
private void Copy(Pars Pars)
{
Tag = Pars.Tag;
foreach (string key in Pars.pars.Keys)
{
object obj = Pars.pars[key];
if (obj is Pars)
{
Add(key, ((Pars)obj).Clone());
}
else if (obj is ParT)
{
Add(key, new ParT((ParT)obj));
}
else if (obj is Par)
{
Add(key, new Par((Par)obj));
}
}
}
private Pars Clone()
{
Pars pars2 = new Pars();
pars2.Tag = Tag;
foreach (string key in pars.Keys)
{
object obj = pars[key];
if (obj is Pars)
{
pars2.Add(key, ((Pars)obj).Clone());
}
else if (obj is ParT)
{
pars2.Add(key, new ParT((ParT)obj));
}
else if (obj is Par)
{
pars2.Add(key, new Par((Par)obj));
}
}
return pars2;
}
public void Draw(double Unit, Graphics Graphics)
{
foreach (object value in pars.Values)
{
if (value is Pars)
{
((Pars)value).Draw(Unit, Graphics);
}
else if (value is ParT)
{
((ParT)value).Draw(Unit, Graphics);
}
else if (value is Par)
{
((Par)value).Draw(Unit, Graphics);
}
}
}
public void DrawH(double Unit, Graphics Graphics)
{
foreach (object value in pars.Values)
{
if (value is Pars)
{
((Pars)value).DrawH(Unit, Graphics);
}
else if (value is Par)
{
((Par)value).DrawH(Unit, Graphics);
}
}
}
public bool IsHit(ref Color HitColor)
{
foreach (object value in pars.Values)
{
if (value is Pars && ((Pars)value).IsHit(ref HitColor))
{
return true;
}
if (value is Par && ((Par)value).GetHitColor() == HitColor)
{
return true;
}
}
return false;
}
public Par GetPar(List<int> Path)
{
return GetPar(0, Path);
}
private Par GetPar(int l, List<int> Path)
{
object obj = pars[Path[l]];
if (obj is Pars)
{
return ((Pars)obj).GetPar(l + 1, Path);
}
return (Par)obj;
}
public void ReverseX()
{
foreach (object value in pars.Values)
{
if (value is Pars)
{
((Pars)value).ReverseX();
}
else if (value is Par)
{
((Par)value).ReverseX();
}
}
}
public void ReverseY()
{
foreach (object value in pars.Values)
{
if (value is Pars)
{
((Pars)value).ReverseY();
}
else if (value is Par)
{
((Par)value).ReverseY();
}
}
}
public void Dispose()
{
foreach (object value in pars.Values)
{
if (value is Pars)
{
((Pars)value).Dispose();
}
else if (value is ParT)
{
((ParT)value).Dispose();
}
else if (value is Par)
{
((Par)value).Dispose();
}
}
}
}
}

View File

@@ -0,0 +1,481 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace _2DGAMELIB
{
[Serializable]
public class PartGroup
{
private PartGroup parent;
public string Tag = "";
public OrderedDictionary<string, object> pars = new OrderedDictionary<string, object>();
public PartGroup Parent => parent;
public IEnumerable<object> Values => pars.Values;
public void SetAngleBase(double value)
{
foreach (object value2 in pars.Values)
{
if (value2 is PartGroup)
{
((PartGroup)value2).SetAngleBase(value);
}
else if (value2 is ShapePart)
{
((ShapePart)value2).SetAngleBase(value);
}
}
}
public void SetSizeBase(double value)
{
foreach (object value2 in pars.Values)
{
if (value2 is PartGroup)
{
((PartGroup)value2).SetSizeBase(value);
}
else if (value2 is ShapePart)
{
((ShapePart)value2).SetSizeBase(value);
}
}
}
public void SetSizeYCont(double value)
{
foreach (object value2 in pars.Values)
{
if (value2 is PartGroup)
{
((PartGroup)value2).SetSizeYCont(value);
}
else if (value2 is ShapePart)
{
((ShapePart)value2).SetSizeYCont(value);
}
}
}
public object this[string Name]
{
get
{
return pars[Name];
}
set
{
pars[Name] = value;
}
}
public object this[int Index]
{
get
{
return pars[Index];
}
set
{
pars[Index] = value;
}
}
public void SetParent(PartGroup Parent)
{
parent = Parent;
}
public int IndexOf(object obj)
{
return pars.IndexOf(obj);
}
public void Add(string Name, ShapePart ShapePart)
{
ShapePart.SetParent(this);
pars.Add(Name, ShapePart);
}
public void Add(string Name, ShapePartT ShapePartT)
{
ShapePartT.SetParent(this);
pars.Add(Name, ShapePartT);
}
public void Add(string Name, PartGroup PartGroup)
{
PartGroup.SetParent(this);
pars.Add(Name, PartGroup);
}
public void Add(PartGroup PartGroup)
{
PartGroup.SetParent(this);
pars.Add(PartGroup.Tag, PartGroup);
}
public void Remove(string Name)
{
object obj = pars[Name];
if (obj is PartGroup)
{
((PartGroup)obj).SetParent(null);
}
else if (obj is ShapePartT)
{
((ShapePartT)obj).SetParent(null);
}
else if (obj is ShapePart)
{
((ShapePart)obj).SetParent(null);
}
pars.Remove(Name);
}
public IEnumerable<ShapePart> EnumAllPar()
{
foreach (object value in pars.Values)
{
if (value is PartGroup)
{
foreach (ShapePart item in ((PartGroup)value).EnumAllPar())
{
yield return item;
}
}
else if (value is ShapePart)
{
yield return (ShapePart)value;
}
}
}
public void SetDefault()
{
foreach (object value in pars.Values)
{
if (value is PartGroup)
{
((PartGroup)value).SetDefault();
}
else if (value is ShapePartT)
{
((ShapePartT)value).SetDefault();
}
else if (value is ShapePart)
{
((ShapePart)value).SetDefault();
}
}
}
public PartGroup()
{
}
public PartGroup(ShapePart ShapePart)
{
Tag = ShapePart.Tag;
Add(ShapePart.Tag, ShapePart);
}
public PartGroup(ShapePartT ShapePartT)
{
Tag = ShapePartT.Tag;
Add(ShapePartT.Tag, ShapePartT);
}
public PartGroup(PartGroup PartGroup)
{
Copy(PartGroup);
}
private void Copy(PartGroup PartGroup)
{
Tag = PartGroup.Tag;
foreach (string key in PartGroup.pars.Keys)
{
object obj = PartGroup.pars[key];
if (obj is PartGroup)
{
Add(key, ((PartGroup)obj).Clone());
}
else if (obj is ShapePartT)
{
Add(key, new ShapePartT((ShapePartT)obj));
}
else if (obj is ShapePart)
{
Add(key, new ShapePart((ShapePart)obj));
}
}
}
private PartGroup Clone()
{
PartGroup pars2 = new PartGroup();
pars2.Tag = Tag;
foreach (string key in pars.Keys)
{
object obj = pars[key];
if (obj is PartGroup)
{
pars2.Add(key, ((PartGroup)obj).Clone());
}
else if (obj is ShapePartT)
{
pars2.Add(key, new ShapePartT((ShapePartT)obj));
}
else if (obj is ShapePart)
{
pars2.Add(key, new ShapePart((ShapePart)obj));
}
}
return pars2;
}
public void Draw(double Unit, Graphics Graphics)
{
foreach (object value in pars.Values)
{
if (value is PartGroup)
{
((PartGroup)value).Draw(Unit, Graphics);
}
else if (value is ShapePartT)
{
((ShapePartT)value).Draw(Unit, Graphics);
}
else if (value is ShapePart)
{
((ShapePart)value).Draw(Unit, Graphics);
}
}
}
public void DrawH(double Unit, Graphics Graphics)
{
foreach (object value in pars.Values)
{
if (value is PartGroup)
{
((PartGroup)value).DrawH(Unit, Graphics);
}
else if (value is ShapePart)
{
((ShapePart)value).DrawH(Unit, Graphics);
}
}
}
public List<string> GetHitTags(ref Color HitColor)
{
List<string> list = new List<string>();
foreach (object value in pars.Values)
{
ShapePart shapePart;
if (value is PartGroup)
{
list.AddRange(((PartGroup)value).GetHitTags(ref HitColor));
}
else if (value is ShapePart && (shapePart = (ShapePart)value).GetHitColor() == HitColor)
{
list.Add(shapePart.Tag);
}
}
return list;
}
public List<ShapePart> GetHitPars(ref Color HitColor)
{
List<ShapePart> list = new List<ShapePart>();
foreach (object value in pars.Values)
{
ShapePart item;
if (value is PartGroup)
{
list.AddRange(((PartGroup)value).GetHitPars(ref HitColor));
}
else if (value is ShapePart && (item = (ShapePart)value).GetHitColor() == HitColor)
{
list.Add(item);
}
}
return list;
}
public bool IsHit(ref Color HitColor)
{
foreach (object value in pars.Values)
{
if (value is PartGroup && ((PartGroup)value).IsHit(ref HitColor))
{
return true;
}
if (value is ShapePart && ((ShapePart)value).GetHitColor() == HitColor)
{
return true;
}
}
return false;
}
public ShapePart GetPar(List<int> Path)
{
return GetPar(0, Path);
}
private ShapePart GetPar(int l, List<int> Path)
{
object obj = pars[Path[l]];
if (obj is PartGroup)
{
return ((PartGroup)obj).GetPar(l + 1, Path);
}
return (ShapePart)obj;
}
public void ReverseX()
{
foreach (object value in pars.Values)
{
if (value is PartGroup)
{
((PartGroup)value).ReverseX();
}
else if (value is ShapePart)
{
((ShapePart)value).ReverseX();
}
}
}
public void ReverseY()
{
foreach (object value in pars.Values)
{
if (value is PartGroup)
{
((PartGroup)value).ReverseY();
}
else if (value is ShapePart)
{
((ShapePart)value).ReverseY();
}
}
}
public void Dispose()
{
foreach (object value in pars.Values)
{
if (value is PartGroup)
{
((PartGroup)value).Dispose();
}
else if (value is ShapePartT)
{
((ShapePartT)value).Dispose();
}
else if (value is ShapePart)
{
((ShapePart)value).Dispose();
}
}
}
}
public static class PartGroupUtils
{
public static PartGroup ToPars(this object obj)
{
return (PartGroup)obj;
}
public static ShapePartT ToParT(this object obj)
{
return (ShapePartT)obj;
}
public static ShapePart ToPar(this object obj)
{
return (ShapePart)obj;
}
public static Pen Copy(this Pen Pen)
{
return new Pen(Pen.Color, Pen.Width)
{
EndCap = Pen.EndCap,
StartCap = Pen.StartCap
};
}
public static Brush Copy(this Brush Brush)
{
if (Brush is SolidBrush)
{
return new SolidBrush(((SolidBrush)Brush).Color);
}
if (Brush is LinearGradientBrush)
{
LinearGradientBrush linearGradientBrush = (LinearGradientBrush)Brush;
LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(linearGradientBrush.Rectangle, Color.Black, Color.White, 0f);
linearGradientBrush2.Blend = linearGradientBrush.Blend;
linearGradientBrush2.GammaCorrection = linearGradientBrush.GammaCorrection;
linearGradientBrush2.InterpolationColors = linearGradientBrush.InterpolationColors;
linearGradientBrush2.LinearColors = new Color[linearGradientBrush.LinearColors.Length];
linearGradientBrush.LinearColors.CopyTo(linearGradientBrush2.LinearColors, 0);
linearGradientBrush2.Transform = linearGradientBrush.Transform;
linearGradientBrush2.WrapMode = linearGradientBrush.WrapMode;
return linearGradientBrush2;
}
if (Brush is PathGradientBrush)
{
PathGradientBrush pathGradientBrush = (PathGradientBrush)Brush;
PathGradientBrush pathGradientBrush2 = new PathGradientBrush(new GraphicsPath());
pathGradientBrush2.Blend = pathGradientBrush.Blend;
pathGradientBrush2.CenterColor = pathGradientBrush.CenterColor;
pathGradientBrush2.CenterPoint = pathGradientBrush.CenterPoint;
pathGradientBrush2.FocusScales = pathGradientBrush.FocusScales;
pathGradientBrush2.InterpolationColors = pathGradientBrush.InterpolationColors;
pathGradientBrush2.SurroundColors = new Color[pathGradientBrush.SurroundColors.Length];
pathGradientBrush.SurroundColors.CopyTo(pathGradientBrush2.SurroundColors, 0);
pathGradientBrush2.Transform = pathGradientBrush.Transform;
pathGradientBrush2.WrapMode = pathGradientBrush.WrapMode;
return pathGradientBrush2;
}
if (Brush is TextureBrush)
{
TextureBrush textureBrush = (TextureBrush)Brush;
return new TextureBrush(textureBrush.Image)
{
Transform = textureBrush.Transform,
WrapMode = textureBrush.WrapMode
};
}
if (Brush is HatchBrush)
{
HatchBrush hatchBrush = (HatchBrush)Brush;
return new HatchBrush(hatchBrush.HatchStyle, hatchBrush.ForegroundColor, hatchBrush.BackgroundColor);
}
return null;
}
public static Font Copy(this Font Font)
{
return new Font(Font.FontFamily, Font.Size, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont);
}
public static StringFormat Copy(this StringFormat StringFormat)
{
return new StringFormat(StringFormat);
}
}
}

View File

@@ -16,19 +16,19 @@ namespace _2DGAMELIB
Rig
}
public class Gau
public class ProgressBar
{
private Pars pars;
private PartGroup _partGroup;
private Par base_;
private ShapePart base_;
private Par frame1;
private ShapePart frame1;
private Par frame2;
private ShapePart frame2;
private Par gauge;
private ShapePart gauge;
private Par knob;
private ShapePart knob;
private double val;
@@ -56,15 +56,15 @@ namespace _2DGAMELIB
private Color MinusColor2;
public Pars Pars => pars;
public PartGroup PartGroup => _partGroup;
public Par Base => base_;
public ShapePart Base => base_;
public Par Frame1 => frame1;
public ShapePart Frame1 => frame1;
public Par Gauge => gauge;
public ShapePart Gauge => gauge;
public Par Knob => knob;
public ShapePart Knob => knob;
public double Value
{
@@ -264,7 +264,7 @@ namespace _2DGAMELIB
Open.Bot => frame1.ToGlobal((TL1 + TR1) * 0.5),
Open.Rig => frame1.ToGlobal((TL1 + BL1) * 0.5),
Open.Lef => frame1.ToGlobal((TR1 + BR1) * 0.5),
_ => Dat.Vec2DZero,
_ => DataConsts.Vec2DZero,
};
}
@@ -276,19 +276,19 @@ namespace _2DGAMELIB
Open.Bot => gauge.ToGlobal((BLG + BRG) * 0.5),
Open.Rig => gauge.ToGlobal((TRG + BRG) * 0.5),
Open.Lef => gauge.ToGlobal((TLG + BLG) * 0.5),
_ => Dat.Vec2DZero,
_ => DataConsts.Vec2DZero,
};
}
private void ParSetting(string Name, ref Vector2D Position, double Size, double Width, double Height, double Margin, ref Color BackColor, bool knob)
{
pars = new Pars();
base_ = new Par
_partGroup = new PartGroup();
base_ = new ShapePart
{
Tag = Name + "_ベース",
};
base_.SetInitializeOP(new Out[1] { Shas.GetSquare() });
base_.SetInitializeOP(new CurveOutline[1] { ShapeHelper.GetSquare() });
base_.SetPositionBase(Position);
base_.SetSizeBase(Size);
base_.SetSizeXBase(Width);
@@ -299,13 +299,13 @@ namespace _2DGAMELIB
base_.SetBasePointBase(base_.GetOP().GetCenter());
pars.Add(base_.Tag, base_);
frame1 = new Par
_partGroup.Add(base_.Tag, base_);
frame1 = new ShapePart
{
Tag = Name + "_フレーム1",
};
frame1.SetInitializeOP(new Out[1] { Shas.GetSquare() });
frame1.SetInitializeOP(new CurveOutline[1] { ShapeHelper.GetSquare() });
frame1.SetPositionBase(Position);
frame1.SetSizeBase(Size);
frame1.SetSizeXBase(Width * GetWidthMag());
@@ -316,15 +316,15 @@ namespace _2DGAMELIB
frame1.SetBasePointBase(GetBasePoint1());
pars.Add(frame1.Tag, frame1);
_partGroup.Add(frame1.Tag, frame1);
if (Range == Range.MinusPlus)
{
frame2 = new Par
frame2 = new ShapePart
{
Tag = Name + "_フレーム2",
};
frame2.SetInitializeOP(new Out[1] { Shas.GetSquare() });
frame2.SetInitializeOP(new CurveOutline[1] { ShapeHelper.GetSquare() });
frame2.SetPositionBase(Position);
frame2.SetSizeBase(Size);
frame2.SetSizeXBase(Width * GetWidthMag());
@@ -332,13 +332,13 @@ namespace _2DGAMELIB
frame2.SetClosed(true);
frame2.SetBrush(null);
frame2.SetBasePointBase(GetBasePoint2());
pars.Add(frame2.Tag, frame2);
_partGroup.Add(frame2.Tag, frame2);
}
gauge = new Par
gauge = new ShapePart
{
Tag = Name + "_ゲージ",
};
gauge.SetInitializeOP(new Out[1] { Shas.GetSquare() });
gauge.SetInitializeOP(new CurveOutline[1] { ShapeHelper.GetSquare() });
gauge.SetPositionBase(GetGaugePosition());
gauge.SetSizeBase(Size);
gauge.SetSizeXBase(Width * GetWidthMag() * GetGaugeWidthMag(Margin));
@@ -347,22 +347,22 @@ namespace _2DGAMELIB
gauge.SetBasePointBase(GetBasePoint());
pars.Add(gauge.Tag, gauge);
_partGroup.Add(gauge.Tag, gauge);
if (knob)
{
this.knob = new Par
this.knob = new ShapePart
{
Tag = Name + "_ブ",
};
this.knob.SetInitializeOP(new Out[1] { Shas.GetSquare() });
this.knob.SetInitializeOP(new CurveOutline[1] { ShapeHelper.GetSquare() });
this.knob.SetSizeBase(Size);
this.knob.SetSizeXBase(GetKnobWidthMag(Width));
this.knob.SetSizeYBase(GetKnobHeightMag(Height));
this.knob.SetClosed(true);
this.knob.SetBrushColor(Color.FromArgb(128, Color.White));
this.knob.SetBasePointBase(this.knob.GetOP().GetCenter());
pars.Add(this.knob.Tag, this.knob);
_partGroup.Add(this.knob.Tag, this.knob);
}
}
@@ -378,44 +378,44 @@ namespace _2DGAMELIB
case Open.Top:
{
frame1.GetMiY_MaY(out var MM7);
PlusBrush = Oth.GetLGB(Unit, MM7, ref PlusColor2, ref PlusColor1);
PlusBrush = GeometryUtils.GetLGB(Unit, MM7, ref PlusColor2, ref PlusColor1);
if (Range == Range.MinusPlus)
{
frame2.GetMiY_MaY(out var MM8);
MinusBrush = Oth.GetLGB(Unit, MM8, ref MinusColor1, ref MinusColor2);
MinusBrush = GeometryUtils.GetLGB(Unit, MM8, ref MinusColor1, ref MinusColor2);
}
break;
}
case Open.Bot:
{
frame1.GetMaY_MiY(out var MM3);
PlusBrush = Oth.GetLGB(Unit, MM3, ref PlusColor2, ref PlusColor1);
PlusBrush = GeometryUtils.GetLGB(Unit, MM3, ref PlusColor2, ref PlusColor1);
if (Range == Range.MinusPlus)
{
frame2.GetMaY_MiY(out var MM4);
MinusBrush = Oth.GetLGB(Unit, MM4, ref MinusColor1, ref MinusColor2);
MinusBrush = GeometryUtils.GetLGB(Unit, MM4, ref MinusColor1, ref MinusColor2);
}
break;
}
case Open.Rig:
{
frame1.GetMaX_MiX(out var MM5);
PlusBrush = Oth.GetLGB(Unit, MM5, ref PlusColor2, ref PlusColor1);
PlusBrush = GeometryUtils.GetLGB(Unit, MM5, ref PlusColor2, ref PlusColor1);
if (Range == Range.MinusPlus)
{
frame2.GetMaX_MiX(out var MM6);
MinusBrush = Oth.GetLGB(Unit, MM6, ref MinusColor1, ref MinusColor2);
MinusBrush = GeometryUtils.GetLGB(Unit, MM6, ref MinusColor1, ref MinusColor2);
}
break;
}
case Open.Lef:
{
frame1.GetMiX_MaX(out var MM);
PlusBrush = Oth.GetLGB(Unit, MM, ref PlusColor2, ref PlusColor1);
PlusBrush = GeometryUtils.GetLGB(Unit, MM, ref PlusColor2, ref PlusColor1);
if (Range == Range.MinusPlus)
{
frame2.GetMiX_MaX(out var MM2);
MinusBrush = Oth.GetLGB(Unit, MM2, ref MinusColor1, ref MinusColor2);
MinusBrush = GeometryUtils.GetLGB(Unit, MM2, ref MinusColor1, ref MinusColor2);
}
break;
}
@@ -430,12 +430,12 @@ namespace _2DGAMELIB
{
PlusBrush.Dispose();
frame1.GetMiY_MaY(out var MM7);
PlusBrush = Oth.GetLGB(Unit, MM7, Color.FromArgb((int)(255.0 * Alpha), PlusColor2), Color.FromArgb((int)(255.0 * Alpha), PlusColor1));
PlusBrush = GeometryUtils.GetLGB(Unit, MM7, Color.FromArgb((int)(255.0 * Alpha), PlusColor2), Color.FromArgb((int)(255.0 * Alpha), PlusColor1));
if (Range == Range.MinusPlus)
{
MinusBrush.Dispose();
frame2.GetMiY_MaY(out var MM8);
MinusBrush = Oth.GetLGB(Unit, MM8, Color.FromArgb((int)(255.0 * Alpha), MinusColor1), Color.FromArgb((int)(255.0 * Alpha), MinusColor2));
MinusBrush = GeometryUtils.GetLGB(Unit, MM8, Color.FromArgb((int)(255.0 * Alpha), MinusColor1), Color.FromArgb((int)(255.0 * Alpha), MinusColor2));
}
break;
}
@@ -443,12 +443,12 @@ namespace _2DGAMELIB
{
PlusBrush.Dispose();
frame1.GetMaY_MiY(out var MM3);
PlusBrush = Oth.GetLGB(Unit, MM3, Color.FromArgb((int)(255.0 * Alpha), PlusColor2), Color.FromArgb((int)(255.0 * Alpha), PlusColor1));
PlusBrush = GeometryUtils.GetLGB(Unit, MM3, Color.FromArgb((int)(255.0 * Alpha), PlusColor2), Color.FromArgb((int)(255.0 * Alpha), PlusColor1));
if (Range == Range.MinusPlus)
{
MinusBrush.Dispose();
frame2.GetMaY_MiY(out var MM4);
MinusBrush = Oth.GetLGB(Unit, MM4, Color.FromArgb((int)(255.0 * Alpha), MinusColor1), Color.FromArgb((int)(255.0 * Alpha), MinusColor2));
MinusBrush = GeometryUtils.GetLGB(Unit, MM4, Color.FromArgb((int)(255.0 * Alpha), MinusColor1), Color.FromArgb((int)(255.0 * Alpha), MinusColor2));
}
break;
}
@@ -456,12 +456,12 @@ namespace _2DGAMELIB
{
PlusBrush.Dispose();
frame1.GetMaX_MiX(out var MM5);
PlusBrush = Oth.GetLGB(Unit, MM5, Color.FromArgb((int)(255.0 * Alpha), PlusColor2), Color.FromArgb((int)(255.0 * Alpha), PlusColor1));
PlusBrush = GeometryUtils.GetLGB(Unit, MM5, Color.FromArgb((int)(255.0 * Alpha), PlusColor2), Color.FromArgb((int)(255.0 * Alpha), PlusColor1));
if (Range == Range.MinusPlus)
{
MinusBrush.Dispose();
frame2.GetMaX_MiX(out var MM6);
MinusBrush = Oth.GetLGB(Unit, MM6, Color.FromArgb((int)(255.0 * Alpha), MinusColor1), Color.FromArgb((int)(255.0 * Alpha), MinusColor2));
MinusBrush = GeometryUtils.GetLGB(Unit, MM6, Color.FromArgb((int)(255.0 * Alpha), MinusColor1), Color.FromArgb((int)(255.0 * Alpha), MinusColor2));
}
break;
}
@@ -469,12 +469,12 @@ namespace _2DGAMELIB
{
PlusBrush.Dispose();
frame1.GetMiX_MaX(out var MM);
PlusBrush = Oth.GetLGB(Unit, MM, Color.FromArgb((int)(255.0 * Alpha), PlusColor2), Color.FromArgb((int)(255.0 * Alpha), PlusColor1));
PlusBrush = GeometryUtils.GetLGB(Unit, MM, Color.FromArgb((int)(255.0 * Alpha), PlusColor2), Color.FromArgb((int)(255.0 * Alpha), PlusColor1));
if (Range == Range.MinusPlus)
{
MinusBrush.Dispose();
frame2.GetMiX_MaX(out var MM2);
MinusBrush = Oth.GetLGB(Unit, MM2, Color.FromArgb((int)(255.0 * Alpha), MinusColor1), Color.FromArgb((int)(255.0 * Alpha), MinusColor2));
MinusBrush = GeometryUtils.GetLGB(Unit, MM2, Color.FromArgb((int)(255.0 * Alpha), MinusColor1), Color.FromArgb((int)(255.0 * Alpha), MinusColor2));
}
break;
}
@@ -506,7 +506,7 @@ namespace _2DGAMELIB
return 0.0;
}
public Gau(string Name, Vector2D Position, double Size, double Width, double Height, double Margin, Open Open, Range Range, double DisUnit, Color PlusColor1, Color PlusColor2, Color MinusColor1, Color MinusColor2, Color BackColor, bool Knob)
public ProgressBar(string Name, Vector2D Position, double Size, double Width, double Height, double Margin, Open Open, Range Range, double DisUnit, Color PlusColor1, Color PlusColor2, Color MinusColor1, Color MinusColor2, Color BackColor, bool Knob)
{
this.Open = Open;
this.Range = Range;
@@ -560,7 +560,7 @@ namespace _2DGAMELIB
public void Dispose()
{
pars.Dispose();
_partGroup.Dispose();
PlusBrush.Dispose();
if (MinusBrush != null)
{

View File

@@ -3,7 +3,7 @@ using System.Globalization;
namespace _2DGAMELIB
{
public static class Qua
public static class Quaternion
{
public static QuaternionD RotationZQ(this double angle)
{
@@ -29,14 +29,13 @@ namespace _2DGAMELIB
public static Vector2D TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, QuaternionD rotation)
{
Vec.Subtract(ref coord, ref BasePoint, out coord);
VectorMath.Subtract(ref coord, ref BasePoint, out coord);
TransformCoordinate(ref coord, ref rotation, out var result);
Vec.Add(ref result, ref BasePoint, out result);
VectorMath.Add(ref result, ref BasePoint, out result);
return result;
}
}
//used in a total of 1 places
[Serializable]
public struct QuaternionD

View File

@@ -0,0 +1,119 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace _2DGAMELIB
{
public sealed class RemappedTypeBinder : SerializationBinder
{
private readonly Dictionary<string, Type> _typeOnlyMap = new();
private readonly Dictionary<string, (string AssemblyName, Type Type)> _fullMap = new();
private static readonly ConcurrentDictionary<string, Type> _additionalMappings = new();
public static void RegisterMapping(string oldTypeName, Type newType)
{
_additionalMappings[oldTypeName] = newType;
}
public RemappedTypeBinder Add(string oldTypeName, Type newType)
{
_typeOnlyMap[oldTypeName] = newType;
return this;
}
public RemappedTypeBinder Add(string oldTypeName, string oldAssemblyName, Type newType)
{
_fullMap[oldTypeName] = (oldAssemblyName, newType);
return this;
}
public override Type BindToType(string assemblyName, string typeName)
{
if (_fullMap.TryGetValue(typeName, out var entry))
{
if (assemblyName != null && assemblyName.StartsWith(entry.AssemblyName))
return entry.Type;
}
if (_typeOnlyMap.TryGetValue(typeName, out var type))
return type;
if (_additionalMappings.TryGetValue(typeName, out var extra))
return extra;
var fullName = typeName;
if (!string.IsNullOrEmpty(assemblyName))
fullName += ", " + assemblyName;
var result = Type.GetType(fullName, throwOnError: false);
if (result != null)
return result;
// Generic types like List<Pars> embed type args in the name.
// Remap any old type names within the type arg list.
if (typeName.Contains("[["))
{
var mangled = RemapTypeArgs(typeName);
if (mangled != typeName)
{
fullName = mangled;
if (!string.IsNullOrEmpty(assemblyName))
fullName += ", " + assemblyName;
result = Type.GetType(fullName, throwOnError: false);
if (result != null)
return result;
}
}
return null;
}
private string RemapTypeArgs(string typeName)
{
// Find the generic arguments section: the outermost [...] containing [args]
int outerStart = typeName.LastIndexOf('`');
if (outerStart < 0) return typeName;
int bracketStart = -1;
for (int i = outerStart + 1; i < typeName.Length; i++)
{
if (typeName[i] == '[')
{
bracketStart = i;
break;
}
}
if (bracketStart < 0) return typeName;
int depth = 0;
int bracketEnd = -1;
for (int i = bracketStart; i < typeName.Length; i++)
{
if (typeName[i] == '[') depth++;
else if (typeName[i] == ']') depth--;
if (depth == 0) { bracketEnd = i; break; }
}
if (bracketEnd < 0) return typeName;
var inner = typeName.Substring(bracketStart, bracketEnd - bracketStart + 1);
// Replace mapped old type names (longest first to avoid partial prefix matches)
var allKeys = new List<string>(_typeOnlyMap.Keys);
allKeys.AddRange(_additionalMappings.Keys);
allKeys.Sort((a, b) => b.Length.CompareTo(a.Length));
foreach (var old in allKeys)
{
Type repType;
if (!_typeOnlyMap.TryGetValue(old, out repType))
_additionalMappings.TryGetValue(old, out repType);
if (repType == null) continue;
var rep = repType.FullName;
inner = inner.Replace(old + ",", rep + ",");
inner = inner.Replace(old + "]", rep + "]");
}
return typeName.Substring(0, bracketStart) + inner + typeName.Substring(bracketEnd + 1);
}
}
}

View File

@@ -23,8 +23,8 @@ namespace _2DGAMELIB
protected Size hitBufferSize = System.Drawing.Size.Empty;
protected Size displayBufferSize = System.Drawing.Size.Empty;
public Vector2D BasePoint = Dat.Vec2DZero;
public Vector2D Position = Dat.Vec2DZero;
public Vector2D BasePoint = DataConsts.Vec2DZero;
public Vector2D Position = DataConsts.Vec2DZero;
public Graphics DisplayGraphics => displayGraphics;
public Graphics HitGraphics => hitGraphics;
@@ -92,30 +92,30 @@ namespace _2DGAMELIB
return new Vector2D(Position.X - BasePoint.X * XRatio * Size, Position.Y - BasePoint.Y * YRatio * Size);
}
public void Draw(Par Par)
public void Draw(ShapePart ShapePart)
{
Par.Draw(displayUnitScale, displayGraphics);
ShapePart.Draw(displayUnitScale, displayGraphics);
if (hitGraphics != null)
{
Par.DrawH(hitUnitScale, hitGraphics);
ShapePart.DrawH(hitUnitScale, hitGraphics);
}
}
public void Draw(ParT ParT)
public void Draw(ShapePartT ShapePartT)
{
ParT.Draw(displayUnitScale, displayGraphics);
ShapePartT.Draw(displayUnitScale, displayGraphics);
if (hitGraphics != null)
{
ParT.DrawH(hitUnitScale, hitGraphics);
ShapePartT.DrawH(hitUnitScale, hitGraphics);
}
}
public void Draw(Pars Pars)
public void Draw(PartGroup PartGroup)
{
Pars.Draw(displayUnitScale, displayGraphics);
PartGroup.Draw(displayUnitScale, displayGraphics);
if (hitGraphics != null)
{
Pars.DrawH(hitUnitScale, hitGraphics);
PartGroup.DrawH(hitUnitScale, hitGraphics);
}

View File

@@ -3,7 +3,7 @@ using System.Globalization;
namespace _2DGAMELIB
{
public static class RNG
public static class Rng
{
public static MyRandom XS = new MyRandom((uint)(Environment.TickCount + DateTime.Now.ToBinary()));
}

View File

@@ -5,7 +5,7 @@ namespace _2DGAMELIB
{
//Basically used to animate switching between two static images
public class Sce
public class SceneFader
{
private Bitmap Start;
private Graphics GS;
@@ -23,7 +23,7 @@ namespace _2DGAMELIB
private ImageAttributes ia = new ImageAttributes();
public Sce(int Width, int Height)
public SceneFader(int Width, int Height)
{
w = Width;
h = Height;

View File

@@ -3,7 +3,7 @@ using System.Drawing;
namespace _2DGAMELIB
{
public class Swi
public class ScreenSwitch
{
private bool flag;
@@ -13,14 +13,14 @@ namespace _2DGAMELIB
public bool Flag => flag;
public Swi(Color OnColor)
public ScreenSwitch(Color OnColor)
{
this.OnColor = OnColor;
}
public void OnOff(But But)
public void OnOff(ButtonBase ButtonBase)
{
But1 but = (But1)But;
Button but = (Button)ButtonBase;
if (!flag)
{
flag = true;
@@ -49,7 +49,7 @@ namespace _2DGAMELIB
}
i = 0;
{
foreach (Par item in but.Pars.EnumAllPar())
foreach (ShapePart item in but.PartGroup.EnumAllPar())
{
item.SetBrushColor(but.OverColors[i]);
i++;
@@ -82,16 +82,16 @@ namespace _2DGAMELIB
});
}
j = 0;
foreach (Par item2 in but.Pars.EnumAllPar())
foreach (ShapePart item2 in but.PartGroup.EnumAllPar())
{
item2.SetBrushColor(but.OverColors[j]);
j++;
}
}
public void SetFlag(But But, bool On)
public void SetFlag(ButtonBase ButtonBase, bool On)
{
But1 but = (But1)But;
Button but = (Button)ButtonBase;
if (On)
{
flag = true;
@@ -120,7 +120,7 @@ namespace _2DGAMELIB
}
i = 0;
{
foreach (Par item in but.Pars.EnumAllPar())
foreach (ShapePart item in but.PartGroup.EnumAllPar())
{
item.SetBrushColor(but.BaseColors[i]);
i++;
@@ -153,7 +153,7 @@ namespace _2DGAMELIB
});
}
j = 0;
foreach (Par item2 in but.Pars.EnumAllPar())
foreach (ShapePart item2 in but.PartGroup.EnumAllPar())
{
item2.SetBrushColor(but.BaseColors[j]);
j++;

View File

@@ -1,155 +0,0 @@
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Cryptography;
using System.Text;
using Newtonsoft.Json;
namespace _2DGAMELIB
{
//serialization stuff
public static class Ser
{
private static SerializableAttribute s = new SerializableAttribute();
public static T DeepCopy<T>(this T Object)
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
using MemoryStream memoryStream = new MemoryStream();
binaryFormatter.Serialize(memoryStream, Object);
memoryStream.Position = 0L;
return (T)binaryFormatter.Deserialize(memoryStream);
}
public static byte[] ToSerialBytes<T>(this T Object)
{
using MemoryStream memoryStream = new MemoryStream();
new BinaryFormatter().Serialize(memoryStream, Object);
return memoryStream.ToArray();
}
public static T ToDeserialObject<T>(this byte[] Bytes)
{
using MemoryStream serializationStream = new MemoryStream(Bytes);
return (T)new BinaryFormatter().Deserialize(serializationStream);
}
public static void Save<T>(this T Object, string Path)
{
using FileStream serializationStream = new FileStream(Path, FileMode.Create, FileAccess.Write);
new BinaryFormatter().Serialize(serializationStream, Object);
}
public static T Load<T>(this string Path)
{
using FileStream serializationStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
return (T)new BinaryFormatter().Deserialize(serializationStream);
}
public static T Load<T>(this byte[] bd)
{
using MemoryStream serializationStream = new MemoryStream(bd);
return (T)new BinaryFormatter().Deserialize(serializationStream);
}
/*
public static void ToXml<T>(this T Object, string Path)
{
using FileStream output = new FileStream(Path, FileMode.Create, FileAccess.Write);
using XmlWriter writer = XmlWriter.Create(output, new XmlWriterSettings
{
Indent = true
});
new DataContractSerializer(typeof(T)).WriteObject(writer, Object);
}
public static T FromXml<T>(this string Path)
{
using FileStream input = new FileStream(Path, FileMode.Open, FileAccess.Read);
using XmlReader reader = XmlReader.Create(input);
return (T)new DataContractSerializer(typeof(T)).ReadObject(reader);
}
*/
static Ser(){}
public static T JsonDeepCopy<T>(this T Object)
{
using MemoryStream memoryStream = new MemoryStream();
JsonSerializer jsonSerializer = new JsonSerializer
{
PreserveReferencesHandling = PreserveReferencesHandling.All,
TypeNameHandling = TypeNameHandling.All,
Formatting = Newtonsoft.Json.Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore
};
jsonSerializer.Serialize(new StreamWriter(memoryStream, Encoding.UTF8), Object);
return (T)new JsonSerializer
{
PreserveReferencesHandling = PreserveReferencesHandling.All,
TypeNameHandling = TypeNameHandling.All,
Formatting = Newtonsoft.Json.Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore
}.Deserialize(new StreamReader(memoryStream), typeof(T));
}
public static byte[] ToJsonBytes<T>(this T Object)
{
MemoryStream textWriter = new MemoryStream();
JsonSerializer jsonSerializer = new JsonSerializer
{
PreserveReferencesHandling = PreserveReferencesHandling.Objects,
TypeNameHandling = TypeNameHandling.All,
Formatting = Newtonsoft.Json.Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore
};
jsonSerializer.Serialize(new StreamWriter(textWriter, Encoding.UTF8), Object);
return textWriter.ToArray();
}
public static T ToUnJsonObject<T>(this byte[] Bytes)
{
using StreamReader reader = new StreamReader(new MemoryStream(Bytes), Encoding.UTF8);
return (T)new JsonSerializer
{
PreserveReferencesHandling = PreserveReferencesHandling.All,
TypeNameHandling = TypeNameHandling.All,
Formatting = Newtonsoft.Json.Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore
}.Deserialize(reader, typeof(T));
}
public static void ToJson<T>(this T Object, string Path)
{
using StreamWriter textWriter = File.CreateText(Path);
JsonSerializer jsonSerializer = new JsonSerializer
{
PreserveReferencesHandling = PreserveReferencesHandling.All,
TypeNameHandling = TypeNameHandling.All,
Formatting = Newtonsoft.Json.Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore
};
jsonSerializer.Serialize(textWriter, Object);
}
public static T UnJson<T>(string Path)
{
using StreamReader reader = File.OpenText(Path);
return (T)new JsonSerializer
{
PreserveReferencesHandling = PreserveReferencesHandling.All,
TypeNameHandling = TypeNameHandling.All,
Formatting = Newtonsoft.Json.Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore
}.Deserialize(reader, typeof(T));
}
}
}

View File

@@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace _2DGAMELIB
{
public static class Serializer
{
private static SerializableAttribute s = new SerializableAttribute();
private static readonly RemappedTypeBinder Binder = new RemappedTypeBinder()
.Add("_2DGAMELIB.Par", typeof(ShapePart))
.Add("_2DGAMELIB.ParT", typeof(ShapePartT))
.Add("_2DGAMELIB.Pars", typeof(PartGroup))
.Add("_2DGAMELIB.Out", typeof(CurveOutline))
.Add("_2DGAMELIB.Joi", typeof(JointPoint))
.Add("_2DGAMELIB.Dif", typeof(MorphVariant))
.Add("_2DGAMELIB.Difs", typeof(VariantGrid))
.Add("_2DGAMELIB.Obj", typeof(BodyTemplate))
.Add("_2DGAMELIB.Sce", typeof(SceneFader));
private static BinaryFormatter NewFormatter()
{
return new BinaryFormatter { Binder = Binder };
}
private static JsonSerializerSettings CreateSettings()
{
var settings = new JsonSerializerSettings
{
PreserveReferencesHandling = PreserveReferencesHandling.All,
TypeNameHandling = TypeNameHandling.All,
Formatting = Newtonsoft.Json.Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore
};
settings.Converters.Add(new OrderedDictionaryConverter<string, VariantGrid>());
settings.Converters.Add(new OrderedDictionaryConverter<string, object>());
settings.Converters.Add(new OrderedDictionaryConverter<string, ButtonBase>());
settings.Converters.Add(new OrderedDictionaryConverter<string, Lab>());
return settings;
}
public static T DeepCopy<T>(this T Object)
{
BinaryFormatter binaryFormatter = NewFormatter();
using MemoryStream memoryStream = new MemoryStream();
binaryFormatter.Serialize(memoryStream, Object);
memoryStream.Position = 0L;
return (T)binaryFormatter.Deserialize(memoryStream);
}
public static byte[] ToSerialBytes<T>(this T Object)
{
using MemoryStream memoryStream = new MemoryStream();
NewFormatter().Serialize(memoryStream, Object);
return memoryStream.ToArray();
}
public static T ToDeserialObject<T>(this byte[] Bytes)
{
using MemoryStream serializationStream = new MemoryStream(Bytes);
return (T)NewFormatter().Deserialize(serializationStream);
}
public static void Save<T>(this T Object, string Path)
{
using FileStream serializationStream = new FileStream(Path, FileMode.Create, FileAccess.Write);
NewFormatter().Serialize(serializationStream, Object);
}
public static T Load<T>(this string Path)
{
using FileStream serializationStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
return (T)NewFormatter().Deserialize(serializationStream);
}
public static T Load<T>(this byte[] bd)
{
using MemoryStream serializationStream = new MemoryStream(bd);
return (T)NewFormatter().Deserialize(serializationStream);
}
static Serializer() { }
public static T JsonDeepCopy<T>(this T Object)
{
var json = JsonConvert.SerializeObject(Object, CreateSettings());
return JsonConvert.DeserializeObject<T>(json, CreateSettings());
}
public static byte[] ToJsonBytes<T>(this T Object)
{
var json = JsonConvert.SerializeObject(Object, CreateSettings());
return Encoding.UTF8.GetBytes(json);
}
public static T ToUnJsonObject<T>(this byte[] Bytes)
{
var json = Encoding.UTF8.GetString(Bytes);
return JsonConvert.DeserializeObject<T>(json, CreateSettings());
}
public static void ToJson<T>(this T Object, string Path)
{
var json = JsonConvert.SerializeObject(Object, CreateSettings());
File.WriteAllText(Path, json);
}
public static T UnJson<T>(string Path)
{
var json = File.ReadAllText(Path);
return JsonConvert.DeserializeObject<T>(json, CreateSettings());
}
public static JsonSerializerSettings GetSettings() => CreateSettings();
}
}

View File

@@ -3,7 +3,7 @@ using System.Linq;
namespace _2DGAMELIB
{
public static class Shas
public static class ShapeHelper
{
//rectangle coords
@@ -38,27 +38,27 @@ namespace _2DGAMELIB
return Point;
}
public static void SetTension(this IEnumerable<Out> Out, float Tension)
public static void SetTension(this IEnumerable<CurveOutline> Out, float Tension)
{
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
item.Tension = Tension;
}
}
public static void OutlineFalse(this IEnumerable<Out> Out)
public static void OutlineFalse(this IEnumerable<CurveOutline> Out)
{
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
item.Outline = false;
}
}
public static Vector2D GetCenter(this IEnumerable<Out> Out)
public static Vector2D GetCenter(this IEnumerable<CurveOutline> Out)
{
double num = 0.0;
Vector2D vec2DZero = Dat.Vec2DZero;
foreach (Out item in Out)
Vector2D vec2DZero = DataConsts.Vec2DZero;
foreach (CurveOutline item in Out)
{
foreach (Vector2D p in item.ps)
{
@@ -69,11 +69,11 @@ namespace _2DGAMELIB
return vec2DZero / num;
}
public static Vector2D GetCenter(this IEnumerable<Joi> Joi)
public static Vector2D GetCenter(this IEnumerable<JointPoint> Joi)
{
double num = 0.0;
Vector2D vec2DZero = Dat.Vec2DZero;
foreach (Joi item in Joi)
Vector2D vec2DZero = DataConsts.Vec2DZero;
foreach (JointPoint item in Joi)
{
vec2DZero += item.Joint;
num += 1.0;
@@ -81,10 +81,10 @@ namespace _2DGAMELIB
return vec2DZero / num;
}
public static void Rotation(this IEnumerable<Out> Out, Vector2D BP, double Angle)
public static void Rotation(this IEnumerable<CurveOutline> Out, Vector2D BP, double Angle)
{
MatrixD transform = Angle.ToRadian().RotationZ();
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -93,10 +93,10 @@ namespace _2DGAMELIB
}
}
public static void ScalingX(this IEnumerable<Out> Out, Vector2D BP, double Rate)
public static void ScalingX(this IEnumerable<CurveOutline> Out, Vector2D BP, double Rate)
{
double num = BP.X - BP.X * Rate;
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -107,10 +107,10 @@ namespace _2DGAMELIB
}
}
public static void ScalingX(this IEnumerable<Out> Out, ref Vector2D BP, double Rate)
public static void ScalingX(this IEnumerable<CurveOutline> Out, ref Vector2D BP, double Rate)
{
double num = BP.X - BP.X * Rate;
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -121,10 +121,10 @@ namespace _2DGAMELIB
}
}
public static void ScalingY(this IEnumerable<Out> Out, Vector2D BP, double Rate)
public static void ScalingY(this IEnumerable<CurveOutline> Out, Vector2D BP, double Rate)
{
double num = BP.Y - BP.Y * Rate;
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -135,10 +135,10 @@ namespace _2DGAMELIB
}
}
public static void ScalingY(this IEnumerable<Out> Out, ref Vector2D BP, double Rate)
public static void ScalingY(this IEnumerable<CurveOutline> Out, ref Vector2D BP, double Rate)
{
double num = BP.Y - BP.Y * Rate;
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -149,12 +149,12 @@ namespace _2DGAMELIB
}
}
public static void ScalingXY(this IEnumerable<Out> Out, Vector2D BP, double Rate)
public static void ScalingXY(this IEnumerable<CurveOutline> Out, Vector2D BP, double Rate)
{
Vector2D vector2D = default(Vector2D);
vector2D.X = BP.X - BP.X * Rate;
vector2D.Y = BP.Y - BP.Y * Rate;
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -166,12 +166,12 @@ namespace _2DGAMELIB
}
}
public static void ScalingXY(this IEnumerable<Out> Out, ref Vector2D BP, double Rate)
public static void ScalingXY(this IEnumerable<CurveOutline> Out, ref Vector2D BP, double Rate)
{
Vector2D vector2D = default(Vector2D);
vector2D.X = BP.X - BP.X * Rate;
vector2D.Y = BP.Y - BP.Y * Rate;
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -183,12 +183,12 @@ namespace _2DGAMELIB
}
}
public static void ScalingXY(this IEnumerable<Out> Out, Vector2D BP, double X, double Y)
public static void ScalingXY(this IEnumerable<CurveOutline> Out, Vector2D BP, double X, double Y)
{
Vector2D vector2D = default(Vector2D);
vector2D.X = BP.X - BP.X * X;
vector2D.Y = BP.Y - BP.Y * Y;
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -200,70 +200,70 @@ namespace _2DGAMELIB
}
}
public static void ScalingX(this IEnumerable<Joi> Joi, Vector2D BP, double Rate)
public static void ScalingX(this IEnumerable<JointPoint> Joi, Vector2D BP, double Rate)
{
double num = BP.X - BP.X * Rate;
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
item.Joint.X = item.Joint.X * Rate + num;
}
}
public static void ScalingX(this IEnumerable<Joi> Joi, ref Vector2D BP, double Rate)
public static void ScalingX(this IEnumerable<JointPoint> Joi, ref Vector2D BP, double Rate)
{
double num = BP.X - BP.X * Rate;
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
item.Joint.X = item.Joint.X * Rate + num;
}
}
public static void ScalingY(this IEnumerable<Joi> Joi, Vector2D BP, double Rate)
public static void ScalingY(this IEnumerable<JointPoint> Joi, Vector2D BP, double Rate)
{
double num = BP.Y - BP.Y * Rate;
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
item.Joint.Y = item.Joint.Y * Rate + num;
}
}
public static void ScalingY(this IEnumerable<Joi> Joi, ref Vector2D BP, double Rate)
public static void ScalingY(this IEnumerable<JointPoint> Joi, ref Vector2D BP, double Rate)
{
double num = BP.Y - BP.Y * Rate;
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
item.Joint.Y = item.Joint.Y * Rate + num;
}
}
public static void ScalingXY(this IEnumerable<Joi> Joi, Vector2D BP, double Rate)
public static void ScalingXY(this IEnumerable<JointPoint> Joi, Vector2D BP, double Rate)
{
Vector2D vector2D = default(Vector2D);
vector2D.X = BP.X - BP.X * Rate;
vector2D.Y = BP.Y - BP.Y * Rate;
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
item.Joint.X = item.Joint.X * Rate + vector2D.X;
item.Joint.Y = item.Joint.Y * Rate + vector2D.Y;
}
}
public static void ScalingXY(this IEnumerable<Joi> Joi, ref Vector2D BP, double Rate)
public static void ScalingXY(this IEnumerable<JointPoint> Joi, ref Vector2D BP, double Rate)
{
Vector2D vector2D = default(Vector2D);
vector2D.X = BP.X - BP.X * Rate;
vector2D.Y = BP.Y - BP.Y * Rate;
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
item.Joint.X = item.Joint.X * Rate + vector2D.X;
item.Joint.Y = item.Joint.Y * Rate + vector2D.Y;
}
}
public static void ReverseX(this List<Out> Out, ref Vector2D BP)
public static void ReverseX(this List<CurveOutline> Out, ref Vector2D BP)
{
double num = BP.X - (1.0 - BP.X);
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -276,10 +276,10 @@ namespace _2DGAMELIB
Out.Reverse();
}
public static void ReverseY(this List<Out> Out, Vector2D BP)
public static void ReverseY(this List<CurveOutline> Out, Vector2D BP)
{
double num = BP.Y - (1.0 - BP.Y);
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -292,10 +292,10 @@ namespace _2DGAMELIB
Out.Reverse();
}
public static void ReverseY(this List<Out> Out, ref Vector2D BP)
public static void ReverseY(this List<CurveOutline> Out, ref Vector2D BP)
{
double num = BP.Y - (1.0 - BP.Y);
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -308,27 +308,27 @@ namespace _2DGAMELIB
Out.Reverse();
}
public static void ReverseX(this List<Joi> Joi, ref Vector2D BP)
public static void ReverseX(this List<JointPoint> Joi, ref Vector2D BP)
{
double num = BP.X - (1.0 - BP.X);
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
item.Joint.X = 1.0 - item.Joint.X + num;
}
}
public static void ReverseY(this List<Joi> Joi, ref Vector2D BP)
public static void ReverseY(this List<JointPoint> Joi, ref Vector2D BP)
{
double num = BP.Y - (1.0 - BP.Y);
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
item.Joint.Y = 1.0 - item.Joint.Y + num;
}
}
public static void ExpansionX(this List<Out> Out, Vector2D BP, double Rate)
public static void ExpansionX(this List<CurveOutline> Out, Vector2D BP, double Rate)
{
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -339,9 +339,9 @@ namespace _2DGAMELIB
}
}
public static void ExpansionX(this List<Out> Out, ref Vector2D BP, double Rate)
public static void ExpansionX(this List<CurveOutline> Out, ref Vector2D BP, double Rate)
{
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -352,9 +352,9 @@ namespace _2DGAMELIB
}
}
public static void ExpansionY(this List<Out> Out, Vector2D BP, double Rate)
public static void ExpansionY(this List<CurveOutline> Out, Vector2D BP, double Rate)
{
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -365,9 +365,9 @@ namespace _2DGAMELIB
}
}
public static void ExpansionY(this List<Out> Out, ref Vector2D BP, double Rate)
public static void ExpansionY(this List<CurveOutline> Out, ref Vector2D BP, double Rate)
{
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -378,9 +378,9 @@ namespace _2DGAMELIB
}
}
public static void ExpansionXY(this List<Out> Out, Vector2D BP, double Rate)
public static void ExpansionXY(this List<CurveOutline> Out, Vector2D BP, double Rate)
{
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -389,9 +389,9 @@ namespace _2DGAMELIB
}
}
public static void ExpansionXY(this List<Out> Out, ref Vector2D BP, double Rate)
public static void ExpansionXY(this List<CurveOutline> Out, ref Vector2D BP, double Rate)
{
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
@@ -400,9 +400,9 @@ namespace _2DGAMELIB
}
}
public static void ExpansionX(this List<Joi> Joi, ref Vector2D BP, double Rate)
public static void ExpansionX(this List<JointPoint> Joi, ref Vector2D BP, double Rate)
{
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
Vector2D vector2D = (item.Joint - BP).newNormalize();
vector2D.Y = 0.0;
@@ -410,9 +410,9 @@ namespace _2DGAMELIB
}
}
public static void ExpansionY(this List<Joi> Joi, ref Vector2D BP, double Rate)
public static void ExpansionY(this List<JointPoint> Joi, ref Vector2D BP, double Rate)
{
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
Vector2D vector2D = (item.Joint - BP).newNormalize();
vector2D.X = 0.0;
@@ -420,26 +420,26 @@ namespace _2DGAMELIB
}
}
public static void ExpansionXY(this List<Joi> Joi, Vector2D BP, double Rate)
public static void ExpansionXY(this List<JointPoint> Joi, Vector2D BP, double Rate)
{
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
item.Joint += (item.Joint - BP).newNormalize() * Rate;
}
}
public static void ExpansionXY(this List<Joi> Joi, ref Vector2D BP, double Rate)
public static void ExpansionXY(this List<JointPoint> Joi, ref Vector2D BP, double Rate)
{
foreach (Joi item in Joi)
foreach (JointPoint item in Joi)
{
item.Joint += (item.Joint - BP).newNormalize() * Rate;
}
}
public static IEnumerable<Vector2D> EnumPoints(this IEnumerable<Out> Out)
public static IEnumerable<Vector2D> EnumPoints(this IEnumerable<CurveOutline> Out)
{
HashSet<Vector2D> hs = new HashSet<Vector2D>();
foreach (Out item in Out)
foreach (CurveOutline item in Out)
{
foreach (Vector2D p in item.ps)
{
@@ -452,7 +452,7 @@ namespace _2DGAMELIB
}
}
public static Out GetTriangle()
public static CurveOutline GetTriangle()
{
MatrixD m120 = 120.0.ToRadian().RotationZ();
@@ -464,16 +464,16 @@ namespace _2DGAMELIB
Vector2D TP3 = Math.TransformCoordinateBP(TP1, new Vector2D(0.5, 0.5), m240);
return new Out
return new CurveOutline
{
Tension = 0f,
ps = { TP1, TP2, TP3 }
};
}
public static Out GetSquare()
public static CurveOutline GetSquare()
{
return new Out
return new CurveOutline
{
Tension = 0f,
ps = {

View File

@@ -11,23 +11,29 @@ namespace _2DGAMELIB
{
//represents a whole or part of a body part :3
[Serializable]
public class Par
public class ShapePart
{
private Pars parent;
private PartGroup parent;
public string Tag = "";
protected List<Out> op = new List<Out>();
protected List<CurveOutline> op = new List<CurveOutline>();
protected List<Joi> jp = new List<Joi>();
protected List<JointPoint> jp = new List<JointPoint>();
protected Vector2D basePointBase = Dat.Vec2DZero;
protected Vector2D basePointBase = DataConsts.Vec2DZero;
protected Vector2D basePointCont = Dat.Vec2DZero;
protected Vector2D basePointCont = DataConsts.Vec2DZero;
protected Vector2D positionBase = Dat.Vec2DZero;
protected Vector2D positionBase = DataConsts.Vec2DZero;
protected Vector2D positionCont = Dat.Vec2DZero;
protected Vector2D positionContO = DataConsts.Vec2DZero;
protected Vector2D positionCont = DataConsts.Vec2DZero;
protected double positionSize = 1.0;
protected Vector2D positionVector = DataConsts.Vec2DZero;
protected double anglePare;
@@ -47,8 +53,6 @@ namespace _2DGAMELIB
protected double ySizeCont = 1.0;
protected double positionSize = 1.0;
protected double penWidth;
@@ -75,23 +79,23 @@ namespace _2DGAMELIB
public bool Hit = true;
private bool closed;
public Pars GetParent()
public PartGroup GetParent()
{
return parent;
}
public List<Out> GetOP()
public List<CurveOutline> GetOP()
{
return op;
}
public void SetInitializeOP(IEnumerable<Out> value)
public void SetInitializeOP(IEnumerable<CurveOutline> value)
{
op.Clear();
op.AddRange(value);
}
public List<Joi> GetJP()
public List<JointPoint> GetJP()
{
return jp;
}
@@ -334,7 +338,7 @@ namespace _2DGAMELIB
{
HitBrush.Color = value;
}
public void SetParent(Pars Parent)
public void SetParent(PartGroup Parent)
{
parent = Parent;
}
@@ -357,59 +361,60 @@ namespace _2DGAMELIB
gph = new GraphicsPath();
}
public Par()
public ShapePart()
{
pen.StartCap = LineCap.Round;
pen.EndCap = LineCap.Round;
}
public Par(Par Par)
public ShapePart(ShapePart ShapePart)
{
Copy(Par);
Copy(ShapePart);
}
protected void Copy(Par Par)
protected void Copy(ShapePart ShapePart)
{
Tag = Par.Tag;
op = new List<Out>(Par.op.Count);
for (int i = 0; i < Par.op.Count; i++)
Tag = ShapePart.Tag;
op = new List<CurveOutline>(ShapePart.op.Count);
for (int i = 0; i < ShapePart.op.Count; i++)
{
op.Add(new Out(Par.op[i]));
op.Add(new CurveOutline(ShapePart.op[i]));
}
jp = new List<Joi>(Par.jp.Count);
for (int j = 0; j < Par.jp.Count; j++)
jp = new List<JointPoint>(ShapePart.jp.Count);
for (int j = 0; j < ShapePart.jp.Count; j++)
{
jp.Add(new Joi(Par.jp[j]));
jp.Add(new JointPoint(ShapePart.jp[j]));
}
basePointBase = Par.basePointBase;
basePointCont = Par.basePointCont;
positionBase = Par.positionBase;
positionCont = Par.positionCont;
positionSize = Par.positionSize;
anglePare = Par.anglePare;
angleBase = Par.angleBase;
angleCont = Par.angleCont;
sizeBase = Par.sizeBase;
sizeCont = Par.sizeCont;
xSizeBase = Par.xSizeBase;
xSizeCont = Par.xSizeCont;
ySizeBase = Par.ySizeBase;
ySizeCont = Par.ySizeCont;
penWidth = Par.penWidth;
Dra = Par.Dra;
closed = Par.closed;
if (Par.pen != null)
basePointBase = ShapePart.basePointBase;
basePointCont = ShapePart.basePointCont;
positionBase = ShapePart.positionBase;
positionContO = ShapePart.positionContO;
positionCont = ShapePart.positionCont;
positionVector = ShapePart.positionVector;
anglePare = ShapePart.anglePare;
angleBase = ShapePart.angleBase;
angleCont = ShapePart.angleCont;
sizeBase = ShapePart.sizeBase;
sizeCont = ShapePart.sizeCont;
xSizeBase = ShapePart.xSizeBase;
xSizeCont = ShapePart.xSizeCont;
ySizeBase = ShapePart.ySizeBase;
ySizeCont = ShapePart.ySizeCont;
penWidth = ShapePart.penWidth;
Dra = ShapePart.Dra;
closed = ShapePart.closed;
if (ShapePart.pen != null)
{
SetPen(Par.pen.Copy());
SetPen(ShapePart.pen.Copy());
}
if (Par.brush != null)
if (ShapePart.brush != null)
{
SetBrush1(Par.brush.Copy());
SetBrush1(ShapePart.brush.Copy());
}
Hit = Par.Hit;
if (Par.HitBrush != null)
Hit = ShapePart.Hit;
if (ShapePart.HitBrush != null)
{
HitBrush = (SolidBrush)Par.HitBrush.Copy();
HitBrush = (SolidBrush)ShapePart.HitBrush.Copy();
}
}
@@ -429,7 +434,7 @@ namespace _2DGAMELIB
Path.Reset();
OutlinePath.Reset();
foreach (Out item in op)
foreach (CurveOutline item in op)
{
PointF[] points = new PointF[item.ps.Count];
for (int i = 0; i < item.ps.Count; i++)
@@ -513,7 +518,7 @@ namespace _2DGAMELIB
gph.Reset();
if (closed)
{
foreach (Out item in op)
foreach (CurveOutline item in op)
{
PointF[] psh = new PointF[item.ps.Count];
for (int i = 0; i < item.ps.Count; i++)
@@ -532,7 +537,7 @@ namespace _2DGAMELIB
return;
}
foreach (Out item2 in op)
foreach (CurveOutline item2 in op)
{
PointF[] psh = new PointF[item2.ps.Count];
for (int j = 0; j < item2.ps.Count; j++)
@@ -575,21 +580,21 @@ namespace _2DGAMELIB
}
}
public void SetJointP(int Index, Par Par)
public void SetJointP(int Index, ShapePart ShapePart)
{
if (Index < jp.Count)
{
Par.SetPositionBase(ToGlobal(jp[Index].Joint));
ShapePart.SetPositionBase(ToGlobal(jp[Index].Joint));
}
}
public void SetJointPA(int Index, Par Par)
public void SetJointPA(int Index, ShapePart ShapePart)
{
if (Index < jp.Count)
{
Par.SetPositionBase(ToGlobal(jp[Index].Joint));
ShapePart.SetPositionBase(ToGlobal(jp[Index].Joint));
}
Par.SetAngleParent(anglePare + angleBase + angleCont);
ShapePart.SetAngleParent(anglePare + angleBase + angleCont);
}
public Vector2D ToGlobal(Vector2D Local)
@@ -692,19 +697,19 @@ namespace _2DGAMELIB
public bool IsParT()
{
return this is ParT;
return this is ShapePartT;
}
public ParT ToParT()
public ShapePartT ToParT()
{
return (ParT)this;
return (ShapePartT)this;
}
public List<int> GetPath()
{
List<int> list = new List<int> { parent.IndexOf(this) };
Pars pars2 = parent;
for (Pars pars3 = pars2.Parent; pars3 != null; pars3 = pars2.Parent)
PartGroup pars2 = parent;
for (PartGroup pars3 = pars2.Parent; pars3 != null; pars3 = pars2.Parent)
{
list.Insert(0, pars3.IndexOf(pars2));
pars2 = pars3;

View File

@@ -7,7 +7,7 @@ namespace _2DGAMELIB
{
// renders text
[Serializable]
public class ParT : Par
public class ShapePartT : ShapePart
{
private double fontSize = 1.0;
@@ -24,9 +24,9 @@ namespace _2DGAMELIB
[NonSerialized, JsonIgnore]
private StringFormat stringformat = new StringFormat();
private Vector2D positionT = Dat.Vec2DZero;
private Vector2D positionT = DataConsts.Vec2DZero;
private Vector2D rectSize = Dat.Vec2DOne;
private Vector2D rectSize = DataConsts.Vec2DOne;
public string Text = "";
@@ -135,36 +135,36 @@ namespace _2DGAMELIB
EditTS = true;
}
public ParT()
public ShapePartT()
{
}
public ParT(ParT ParT)
public ShapePartT(ShapePartT ShapePartT)
{
CopyT(ParT);
CopyT(ShapePartT);
}
private void CopyT(ParT ParT)
private void CopyT(ShapePartT ShapePartT)
{
Copy(ParT);
Copy(ShapePartT);
fontSize = ParT.fontSize;
fontSize = ShapePartT.fontSize;
if (ParT.font != null)
SetFont(ParT.font.Copy());
if (ShapePartT.font != null)
SetFont(ShapePartT.font.Copy());
if (ParT.brusht != null)
SetTextBrush(ParT.brusht.Copy());
if (ShapePartT.brusht != null)
SetTextBrush(ShapePartT.brusht.Copy());
if (ParT.brushs != null)
SetShadBrush(ParT.brushs.Copy());
if (ShapePartT.brushs != null)
SetShadBrush(ShapePartT.brushs.Copy());
if (ParT.stringformat != null)
SetStringFormat(ParT.stringformat.Copy());
if (ShapePartT.stringformat != null)
SetStringFormat(ShapePartT.stringformat.Copy());
positionT = ParT.positionT;
rectSize = ParT.rectSize;
Text = ParT.Text;
positionT = ShapePartT.positionT;
rectSize = ShapePartT.rectSize;
Text = ShapePartT.Text;
}
public new void Draw(double Unit, Graphics Graphics)
@@ -307,18 +307,18 @@ namespace _2DGAMELIB
{
Vector2D[] stringRectPoints = GetStringRectPoints(Unit, Graphics);
Out @out = new Out { Tension = 0f };
Vector2D vector2D = Dat.Vec2DZero - stringRectPoints[0];
CurveOutline curveOutline = new CurveOutline { Tension = 0f };
Vector2D vector2D = DataConsts.Vec2DZero - stringRectPoints[0];
double x = 0.05;
double num = 0.025;
@out.ps.Add(stringRectPoints[0].AddY(-num) + vector2D);
@out.ps.Add(stringRectPoints[1].AddXY(x, -num) + vector2D);
@out.ps.Add(stringRectPoints[2].AddXY(x, num) + vector2D);
@out.ps.Add(stringRectPoints[3].AddY(num) + vector2D);
curveOutline.ps.Add(stringRectPoints[0].AddY(-num) + vector2D);
curveOutline.ps.Add(stringRectPoints[1].AddXY(x, -num) + vector2D);
curveOutline.ps.Add(stringRectPoints[2].AddXY(x, num) + vector2D);
curveOutline.ps.Add(stringRectPoints[3].AddY(num) + vector2D);
base.GetOP().Add(@out);
base.GetOP().Add(curveOutline);
}
public new void Dispose()

View File

@@ -5,13 +5,13 @@ using System.Linq;
namespace _2DGAMELIB
{
public class Tex
public class TextBlock
{
private Pars pars;
private PartGroup _partGroup;
private ParT parT;
private ShapePartT _shapePartT;
private Par feed;
private ShapePart feed;
public int Space;
@@ -19,11 +19,11 @@ namespace _2DGAMELIB
private double speed = 1.0;
private Action<Tex> Action = delegate
private Action<TextBlock> Action = delegate
{
};
private MotV mv;
private MotionBase mv;
private bool f1;
@@ -33,7 +33,7 @@ namespace _2DGAMELIB
private int Max;
public Action<Tex> Done;
public Action<TextBlock> Done;
private byte a0;
@@ -43,11 +43,11 @@ namespace _2DGAMELIB
private bool FastText;
public Pars Pars => pars;
public PartGroup PartGroup => _partGroup;
public ParT ParT => parT;
public ShapePartT ShapePartT => _shapePartT;
public Par Feed => feed;
public ShapePart Feed => feed;
public string TextIm
{
@@ -68,9 +68,9 @@ namespace _2DGAMELIB
Max = text.Length;
Count = Max;
f1 = false;
if (parT != null)
if (_shapePartT != null)
{
parT.Text = text;
_shapePartT.Text = text;
}
}
}
@@ -113,21 +113,21 @@ namespace _2DGAMELIB
{
get
{
return parT.GetPositionBase();
return _shapePartT.GetPositionBase();
}
set
{
parT.SetPositionBase(value);
_shapePartT.SetPositionBase(value);
if (feed != null)
{
feed.SetPositionBase(parT.ToGlobal(parT.GetOP()[0].ps[2] * 0.95));
feed.SetPositionBase(_shapePartT.ToGlobal(_shapePartT.GetOP()[0].ps[2] * 0.95));
}
}
}
public bool IsPlaying => !f1;
public Tex(string Name, Vector2D Position, double Size, double Width, double Height, Font Font, double TextSize, int Space, string Text, Color TextColor, Color ShadColor, Color BackColor, double Speed, Color FeedColor, Action<Tex> Action)
public TextBlock(string Name, Vector2D Position, double Size, double Width, double Height, Font Font, double TextSize, int Space, string Text, Color TextColor, Color ShadColor, Color BackColor, double Speed, Color FeedColor, Action<TextBlock> Action)
{
try
{
@@ -162,11 +162,11 @@ namespace _2DGAMELIB
this.Action = Action;
SetParT(Name, ref Position, Size, Width, Height, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor);
SetFeed(Name, Size, ref FeedColor);
mv = new MotV(0.0, 255.0);
mv = new MotionBase(0.0, 255.0);
mv.BaseSpeed = 2.0;
}
public Tex(string Name, Vector2D Position, double Size, double Width, double Height, Font Font, double TextSize, int Space, string Text, Color TextColor, Color ShadColor, Color BackColor, double Speed)
public TextBlock(string Name, Vector2D Position, double Size, double Width, double Height, Font Font, double TextSize, int Space, string Text, Color TextColor, Color ShadColor, Color BackColor, double Speed)
{
try
{
@@ -203,44 +203,44 @@ namespace _2DGAMELIB
private void SetParT(string Name, ref Vector2D Position, double Size, double Width, double Height, Font Font, double TextSize, string Text, ref Color TextColor, ref Color ShadColor, ref Color BackColor)
{
pars = new Pars();
Out[] array = new Out[1] { Shas.GetSquare() };
_partGroup = new PartGroup();
CurveOutline[] array = new CurveOutline[1] { ShapeHelper.GetSquare() };
array.OutlineFalse();
parT = new ParT
_shapePartT = new ShapePartT
{
Tag = Name,
Text = Text
};
parT.SetFont(Font);
parT.SetFontSize(TextSize);
parT.SetTextColor(TextColor);
parT.SetRectSize(new Vector2D(Width, Height));
parT.SetInitializeOP(array);
parT.SetPositionBase(Position);
parT.SetSizeBase(Size);
parT.SetClosed(true);
parT.SetBrushColor(BackColor);
ParT.GetOP().ScalingX(ParT.GetBasePointBase(), Width);
ParT.GetOP().ScalingY(ParT.GetBasePointBase(), Height);
_shapePartT.SetFont(Font);
_shapePartT.SetFontSize(TextSize);
_shapePartT.SetTextColor(TextColor);
_shapePartT.SetRectSize(new Vector2D(Width, Height));
_shapePartT.SetInitializeOP(array);
_shapePartT.SetPositionBase(Position);
_shapePartT.SetSizeBase(Size);
_shapePartT.SetClosed(true);
_shapePartT.SetBrushColor(BackColor);
_shapePartT.GetOP().ScalingX(_shapePartT.GetBasePointBase(), Width);
_shapePartT.GetOP().ScalingY(_shapePartT.GetBasePointBase(), Height);
if (ShadColor != Color.Empty)
{
parT.SetShadBrush(new SolidBrush(ShadColor));
_shapePartT.SetShadBrush(new SolidBrush(ShadColor));
}
pars.Add(parT.Tag, parT);
_partGroup.Add(_shapePartT.Tag, _shapePartT);
}
private void SetFeed(string Name, double Size, ref Color FeedColor)
{
Out[] array = new Out[1] { Shas.GetTriangle() };
feed = new Par
CurveOutline[] array = new CurveOutline[1] { ShapeHelper.GetTriangle() };
feed = new ShapePart
{
Tag = Name + "_Feed",
Hit = false
};
feed.SetInitializeOP(array);
feed.SetBasePointBase(array.GetCenter());
feed.SetPositionBase(parT.ToGlobal(parT.GetOP()[0].ps[2] * 0.96));
feed.SetPositionBase(feed.ToGlobal(feed.GetOP()[0].ps[2] * 0.96));
feed.SetSizeBase(Size * 0.07);
feed.SetSizeYBase(0.9);
feed.SetClosed(true);
@@ -248,19 +248,19 @@ namespace _2DGAMELIB
feed.SetBrushColor(Color.FromArgb(0, FeedColor));
feed.GetOP().ReverseY(feed.GetBasePointBase());
pars.Add(feed.Tag, feed);
_partGroup.Add(feed.Tag, feed);
}
public void SetHitColor(ModeEventDispatcher Med)
{
if (parT.GetHitColor() != Color.Transparent)
if (_shapePartT.GetHitColor() != Color.Transparent)
{
Med.RemUniqueColor(parT.GetHitColor());
Med.RemUniqueColor(_shapePartT.GetHitColor());
}
parT.SetHitColor(Med.GetUniqueColor());
_shapePartT.SetHitColor(Med.GetUniqueColor());
}
public void Progression(FPS FPS)
public void Progression(FpsCounter FPS)
{
if (!f1)
{
@@ -268,10 +268,10 @@ namespace _2DGAMELIB
int num = (int)Count;
if (num <= Max)
{
parT.Text = text.Substring(0, num);
_shapePartT.Text = text.Substring(0, num);
return;
}
parT.Text = text;
_shapePartT.Text = text;
f1 = true;
if (feed != null)
{
@@ -294,7 +294,7 @@ namespace _2DGAMELIB
public bool Down(ref Color HitColor)
{
if (parT.GetHitColor() == HitColor)
if (_shapePartT.GetHitColor() == HitColor)
{
f2 = true;
if (!f1 && Speed == speed)
@@ -308,7 +308,7 @@ namespace _2DGAMELIB
public bool Up(ref Color HitColor)
{
if (f1 && f2 && parT.GetHitColor() == HitColor && Speed == speed)
if (f1 && f2 && _shapePartT.GetHitColor() == HitColor && Speed == speed)
{
f1 = false;
f2 = false;
@@ -328,7 +328,7 @@ namespace _2DGAMELIB
public void Dispose()
{
pars.Dispose();
_partGroup.Dispose();
}
}
}

View File

@@ -7,7 +7,7 @@ using Newtonsoft.Json;
namespace _2DGAMELIB
{
[Serializable]
public class Difs
public class VariantGrid
{
public string Tag = "";
@@ -15,11 +15,11 @@ namespace _2DGAMELIB
public double ValueY;
private List<Dif> difs = new List<Dif>();
private List<MorphVariant> difs = new List<MorphVariant>();
public Dictionary<Pars, Joints> pj;
public Dictionary<PartGroup, Joints> pj;
public Dictionary<Pars, Par> pr;
public Dictionary<PartGroup, ShapePart> pr;
public int GetCountX()
{
@@ -63,7 +63,7 @@ namespace _2DGAMELIB
ValueY = (double)value / (double)GetCountY();
}
public Dif this[int Index]
public MorphVariant this[int Index]
{
get
{
@@ -75,14 +75,14 @@ namespace _2DGAMELIB
}
}
public Pars GetCurrent()
public PartGroup GetCurrent()
{
return difs[GetIndexX()][GetIndexY()];
}
public void SetAngleBase(double value)
{
foreach (Dif dif in difs)
foreach (MorphVariant dif in difs)
{
dif.SetAngleBase(value);
}
@@ -90,7 +90,7 @@ namespace _2DGAMELIB
public void SetSizeBase(double value)
{
foreach (Dif dif in difs)
foreach (MorphVariant dif in difs)
{
dif.SetSizeBase(value);
}
@@ -98,15 +98,15 @@ namespace _2DGAMELIB
public void SetSizeYCont(double value)
{
foreach (Dif dif in difs)
foreach (MorphVariant dif in difs)
{
dif.SetSizeYCont(value);
}
}
public Par GetCurJoinRoot()
public ShapePart GetCurJoinRoot()
{
Pars current = GetCurrent();
PartGroup current = GetCurrent();
if (pr.ContainsKey(current))
{
return pr[current];
@@ -115,23 +115,23 @@ namespace _2DGAMELIB
}
[JsonIgnore]
public IEnumerable<Par> EnumJoinRoot => pr.Values;
public IEnumerable<Par> EnumAllPar()
public IEnumerable<ShapePart> EnumJoinRoot => pr.Values;
public IEnumerable<ShapePart> EnumAllPar()
{
foreach (Dif dif in difs)
foreach (MorphVariant dif in difs)
{
foreach (Par item in dif.EnumAllPar())
foreach (ShapePart item in dif.EnumAllPar())
{
yield return item;
}
}
}
public IEnumerable<Pars> EnumAllPars()
public IEnumerable<PartGroup> EnumAllPars()
{
foreach (Dif dif in difs)
foreach (MorphVariant dif in difs)
{
foreach (Pars item in dif.Parss)
foreach (PartGroup item in dif.Parss)
{
yield return item;
}
@@ -140,35 +140,35 @@ namespace _2DGAMELIB
public void SetDefault()
{
foreach (Dif dif in difs)
foreach (MorphVariant dif in difs)
{
dif.SetDefault();
}
}
public Difs()
public VariantGrid()
{
}
public Difs(Difs Difs)
public VariantGrid(VariantGrid VariantGrid)
{
Copy(Difs);
Copy(VariantGrid);
}
private void Copy(Difs Difs)
private void Copy(VariantGrid VariantGrid)
{
Tag = Difs.Tag;
ValueX = Difs.ValueX;
ValueY = Difs.ValueY;
foreach (Dif dif in Difs.difs)
Tag = VariantGrid.Tag;
ValueX = VariantGrid.ValueX;
ValueY = VariantGrid.ValueY;
foreach (MorphVariant dif in VariantGrid.difs)
{
difs.Add(new Dif(dif));
difs.Add(new MorphVariant(dif));
}
}
public void Add(Dif Dif)
public void Add(MorphVariant MorphVariant)
{
difs.Add(Dif);
difs.Add(MorphVariant);
}
@@ -176,28 +176,28 @@ namespace _2DGAMELIB
{
Are.Draw(GetCurrent());
}
public void Draw(AreM AreM)
public void Draw(ManagedArea ManagedArea)
{
AreM.Draw(GetCurrent());
ManagedArea.Draw(GetCurrent());
}
private Par GetJoinRoot(Pars ps)
private ShapePart GetJoinRoot(PartGroup ps)
{
Par[] array = ps.EnumAllPar().ToArray();
ShapePart[] array = ps.EnumAllPar().ToArray();
if (array.Length <= 1)
{
return array.FirstOrDefault();
}
Par[] array2 = array;
foreach (Par p0 in array2)
ShapePart[] array2 = array;
foreach (ShapePart p0 in array2)
{
Vector2D p = p0.GetPosition();
if (array.All((Par p1) => p0 == p1 || p1.GetJP().All((Joi j) => !(p1.ToGlobal(j.Joint).DistanceSquared(p) <= Join.IdentityDistance))))
if (array.All((ShapePart p1) => p0 == p1 || p1.GetJP().All((JointPoint j) => !(p1.ToGlobal(j.Joint).DistanceSquared(p) <= JointLink.IdentityDistance))))
{
return p0;
}
}
Par par = array.FirstOrDefault((Par e) => e.GetJP().Count > 0);
ShapePart par = array.FirstOrDefault((ShapePart e) => e.GetJP().Count > 0);
if (par != null)
{
return par;
@@ -207,11 +207,11 @@ namespace _2DGAMELIB
public void SetJoints()
{
pj = new Dictionary<Pars, Joints>();
pr = new Dictionary<Pars, Par>();
foreach (Pars item in EnumAllPars())
pj = new Dictionary<PartGroup, Joints>();
pr = new Dictionary<PartGroup, ShapePart>();
foreach (PartGroup item in EnumAllPars())
{
Par joinRoot = GetJoinRoot(item);
ShapePart joinRoot = GetJoinRoot(item);
if (joinRoot != null)
{
pj.Add(item, joinRoot.GetJoints(item.EnumAllPar()));
@@ -238,14 +238,14 @@ namespace _2DGAMELIB
}
}
public Par GetHitPar_(Color HitColor)
public ShapePart GetHitPar_(Color HitColor)
{
return difs.FirstOrDefault((Dif d) => d.IsHit(ref HitColor)).Parss.FirstOrDefault((Pars ps) => ps.IsHit(ref HitColor)).EnumAllPar().FirstOrDefault((Par e) => e.GetHitColor() == HitColor);
return difs.FirstOrDefault((MorphVariant d) => d.IsHit(ref HitColor)).Parss.FirstOrDefault((PartGroup ps) => ps.IsHit(ref HitColor)).EnumAllPar().FirstOrDefault((ShapePart e) => e.GetHitColor() == HitColor);
}
public bool IsHit(ref Color HitColor)
{
foreach (Dif dif in difs)
foreach (MorphVariant dif in difs)
{
if (dif.IsHit(ref HitColor))
{
@@ -258,7 +258,7 @@ namespace _2DGAMELIB
public void ReverseX()
{
SetJoints();
foreach (Dif dif in difs)
foreach (MorphVariant dif in difs)
{
dif.ReverseX();
}
@@ -268,7 +268,7 @@ namespace _2DGAMELIB
public void ReverseY()
{
SetJoints();
foreach (Dif dif in difs)
foreach (MorphVariant dif in difs)
{
dif.ReverseY();
}
@@ -277,7 +277,7 @@ namespace _2DGAMELIB
public void Dispose()
{
foreach (Dif dif in difs)
foreach (MorphVariant dif in difs)
{
dif.Dispose();
}

View File

@@ -1,68 +0,0 @@
using System;
namespace _2DGAMELIB
{
public static class Vec
{
public static void Add(ref Vector2D v1, ref Vector2D v2, out Vector2D r)
{
r.X = v1.X + v2.X;
r.Y = v1.Y + v2.Y;
}
public static void Subtract(ref Vector2D v1, ref Vector2D v2, out Vector2D r)
{
r.X = v1.X - v2.X;
r.Y = v1.Y - v2.Y;
}
public static double DistanceSquared(this Vector2D v1, Vector2D v2)
{
double num = v1.X - v2.X;
double num2 = v1.Y - v2.Y;
return num * num + num2 * num2;
}
public static void Dot(ref Vector2D v1, ref Vector2D v2, out double r)
{
r = v1.X * v2.X + v1.Y * v2.Y;
}
public static double Cross(ref Vector2D v1, ref Vector2D v2)
{
return v1.X * v2.Y - v1.Y * v2.X;
}
public static Vector2D newNormalize(this Vector2D vector)
{
vector.Normalize();
return vector;
}
public static double Angle(ref Vector2D v1, ref Vector2D v2)
{
Dot(ref v1, ref v2, out var r);
r /= v1.Length() * v2.Length();
if (r > 1.0)
{
r = 1.0;
}
else if (r < -1.0)
{
r = -1.0;
}
return System.Math.Acos(r);
}
public static double Angle02π(this Vector2D v1, Vector2D v2)
{
double num = Angle(ref v1, ref v2);
if (Cross(ref v1, ref v2) < 0.0)
{
num = System.Math.PI * 2.0 - num;
}
return num;
}
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using System.Runtime.CompilerServices;
namespace _2DGAMELIB
{
@@ -21,17 +22,19 @@ namespace _2DGAMELIB
X = x;
Y = y;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public double Length()
{
return System.Math.Sqrt(X * X + Y * Y);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public double LengthSquared()
{
return X * X + Y * Y;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Normalize()
{
double num = Length();

View File

@@ -0,0 +1,76 @@
using System;
using System.Runtime.CompilerServices;
namespace _2DGAMELIB
{
public static class VectorMath
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Add(ref Vector2D a, ref Vector2D b, out Vector2D result)
{
result.X = a.X + b.X;
result.Y = a.Y + b.Y;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Subtract(ref Vector2D a, ref Vector2D b, out Vector2D result)
{
result.X = a.X - b.X;
result.Y = a.Y - b.Y;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double DistanceSquared(this Vector2D a, Vector2D b)
{
double num = a.X - b.X;
double num2 = a.Y - b.Y;
return num * num + num2 * num2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Dot(ref Vector2D a, ref Vector2D b, out double result)
{
result = a.X * b.X + a.Y * b.Y;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double Cross(ref Vector2D a, ref Vector2D b)
{
return a.X * b.Y - a.Y * b.X;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2D newNormalize(this Vector2D vector)
{
vector.Normalize();
return vector;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double Angle(ref Vector2D a, ref Vector2D b)
{
Dot(ref a, ref b, out var r);
r /= a.Length() * b.Length();
if (r > 1.0)
{
r = 1.0;
}
else if (r < -1.0)
{
r = -1.0;
}
return System.Math.Acos(r);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double Angle02π(this Vector2D a, Vector2D b)
{
double num = Angle(ref a, ref b);
if (Cross(ref a, ref b) < 0.0)
{
num = System.Math.PI * 2.0 - num;
}
return num;
}
}
}

View File

@@ -196,17 +196,17 @@ namespace _2DGAMELIB
public static Vector2D TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, MatrixD transform)
{
Vec.Subtract(ref coord, ref BasePoint, out coord);
VectorMath.Subtract(ref coord, ref BasePoint, out coord);
TransformCoordinate(ref coord, ref transform, out var result);
Vec.Add(ref result, ref BasePoint, out result);
VectorMath.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);
VectorMath.Subtract(ref coord, ref BasePoint, out var r);
TransformCoordinate(ref r, ref transform, out var result);
Vec.Add(ref result, ref BasePoint, out result);
VectorMath.Add(ref result, ref BasePoint, out result);
return result;
}
@@ -214,20 +214,20 @@ namespace _2DGAMELIB
public static Pars ToPars(this object obj)
/*
public static PartGroup ToPars(this object obj)
{
return (Pars)obj;
return (PartGroup)obj;
}
public static ParT ToParT(this object obj)
public static ShapePartT ToParT(this object obj)
{
return (ParT)obj;
return (ShapePartT)obj;
}
public static Par ToPar(this object obj)
public static ShapePart ToPar(this object obj)
{
return (Par)obj;
return (ShapePart)obj;
}
public static Pen Copy(this Pen Pen)
@@ -299,5 +299,7 @@ namespace _2DGAMELIB
{
return new StringFormat(StringFormat);
}
*/
}
}