Initial Commit

This commit is contained in:
lewd-alt
2025-05-05 19:40:03 -07:00
parent b8812f4d8d
commit 2e6d5ccc6d
1025 changed files with 540249 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<AssemblyName>2DGAMELIB</AssemblyName>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<UseWindowsForms>True</UseWindowsForms>
<TargetFramework>net45</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<LangVersion>10.0</LangVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="PresentationFramework">
<HintPath>..\..\..\..\..\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationFramework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="PresentationCore" />
<Reference Include="WindowsFormsIntegration" />
<Reference Include="WindowsBase" />
<Reference Include="System.Windows.Forms" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<PropertyGroup>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<Compile Update="_2DGAMELIB\UI.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,14 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("2DGAMELIB")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("2DGAMELIB")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9ef0bc72-d089-4f3b-80df-ab86b8839efb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]

View File

@@ -0,0 +1,6 @@
namespace System.Diagnostics.CodeAnalysis;
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
internal sealed class AllowNullAttribute : Attribute
{
}

View File

@@ -0,0 +1,12 @@
namespace System.Diagnostics.CodeAnalysis;
[AttributeUsage(AttributeTargets.Parameter)]
internal class DoesNotReturnIfAttribute : Attribute
{
public DoesNotReturnIfAttribute(bool parameterValue)
{
ParameterValue = parameterValue;
}
public bool ParameterValue { get; }
}

View File

@@ -0,0 +1,7 @@
namespace System.Diagnostics.CodeAnalysis;
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter |
AttributeTargets.ReturnValue)]
internal sealed class MaybeNullAttribute : Attribute
{
}

View File

@@ -0,0 +1,8 @@
namespace System.Diagnostics.CodeAnalysis;
[AttributeUsage(
AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter |
AttributeTargets.ReturnValue, AllowMultiple = true)]
internal sealed class NotNullAttribute : Attribute
{
}

View File

@@ -0,0 +1,12 @@
namespace System.Diagnostics.CodeAnalysis;
[AttributeUsage(AttributeTargets.Parameter)]
internal sealed class NotNullWhenAttribute : Attribute
{
public NotNullWhenAttribute(bool returnValue)
{
ReturnValue = returnValue;
}
public bool ReturnValue { get; }
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

201
2DGAMELIB/_2DGAMELIB/Are.cs Normal file
View File

@@ -0,0 +1,201 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace _2DGAMELIB;
public class Are : Rect
{
public Bitmap Dis;
protected Graphics gd;
protected Bitmap Hit;
protected Graphics gh;
protected double unit;
protected double disUnit;
protected double hitUnit;
protected Size WH = System.Drawing.Size.Empty;
protected Size WHH = System.Drawing.Size.Empty;
protected Size WHA = System.Drawing.Size.Empty;
private Color ClearColor = Color.Transparent;
public Vector2D BasePoint = Dat.Vec2DZero;
public Vector2D Position = Dat.Vec2DZero;
protected Vector2D p;
protected Rectangle r;
protected ColorMatrix cm = new ColorMatrix();
protected ImageAttributes ia = new ImageAttributes();
protected InterpolationMode im;
public Graphics GD => gd;
public Graphics GH => gh;
public double Unit => unit;
public double DisUnit => disUnit;
public Are() { }
public Are(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag)
{
Setting(Unit, XRatio, YRatio, Size, DisMag, HitMag);
}
public Are(Med Med, bool Hit)
{
if (Hit)
{
Setting(Med.Unit, Med.Base.XRatio, Med.Base.YRatio, Med.Base.Size, Med.DisQuality, Med.HitAccuracy);
}
else
{
Setting(Med.Unit, Med.Base.XRatio, Med.Base.YRatio, Med.Base.Size, Med.DisQuality);
}
}
private void Setting(double Unit, double XRatio, double YRatio, double Size, double DisMag)
{
SetXYRatio(XRatio, YRatio);
base.Size = Size;
unit = Unit;
disUnit = Unit * DisMag;
WH.Width = (int)(base.LocalWidth * Unit);
WH.Height = (int)(base.LocalHeight * Unit);
WHA.Width = (int)(base.LocalWidth * disUnit);
WHA.Height = (int)(base.LocalHeight * disUnit);
Dis = new Bitmap((int)((double)WH.Width * DisMag), (int)((double)WH.Height * DisMag));
gd = Graphics.FromImage(Dis);
gd.SmoothingMode = SmoothingMode.None;
gd.PixelOffsetMode = PixelOffsetMode.HighSpeed;
gd.InterpolationMode = InterpolationMode.NearestNeighbor;
//needed for text or smthn
gd.CompositingMode = CompositingMode.SourceOver;
}
private void Setting(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag)
{
Setting(Unit, XRatio, YRatio, Size, DisMag);
hitUnit = Unit * HitMag;
WHH.Width = (int)(base.LocalWidth * hitUnit);
WHH.Height = (int)(base.LocalHeight * hitUnit);
Hit = new Bitmap(WHH.Width, WHH.Height);
gh = Graphics.FromImage(Hit);
gh.SmoothingMode = SmoothingMode.None;
gh.PixelOffsetMode = PixelOffsetMode.HighSpeed;
gh.InterpolationMode = InterpolationMode.NearestNeighbor;
gh.CompositingMode = CompositingMode.SourceCopy;
}
public Vector2D GetPosition()
{
return new Vector2D(Position.X - BasePoint.X * XRatio * Size, Position.Y - BasePoint.Y * YRatio * Size);
}
public void Draw(Par Par)
{
Par.Draw(disUnit, gd);
if (gh != null)
{
Par.DrawH(hitUnit, gh);
}
}
public void Draw(ParT ParT)
{
ParT.Draw(disUnit, gd);
if (gh != null)
{
ParT.DrawH(hitUnit, gh);
}
}
public void Draw(Pars Pars)
{
Pars.Draw(disUnit, gd);
if (gh != null)
{
Pars.DrawH(hitUnit, gh);
}
}
public void Draw(Graphics GD)
{
p = GetPosition();
GD.DrawImage(Dis, (int)(p.X * unit), (int)(p.Y * unit), WH.Width, WH.Height);
}
public void Draw(Graphics GD, Graphics GH)
{
p = GetPosition();
GD.DrawImage(Dis, (int)(p.X * unit), (int)(p.Y * unit), WH.Width, WH.Height);
if (gh != null)
{
GH.DrawImage(Hit, (int)(p.X * hitUnit), (int)(p.Y * hitUnit), WHH.Width, WHH.Height);
}
}
public void Draw(Are Are)
{
p = Are.GetPosition();
GD.DrawImage(Are.Dis, (float)(p.X * Are.disUnit), (float)(p.Y * Are.disUnit), Are.WHA.Width, Are.WHA.Height);
if (Are.gh != null && GH != null)
{
GH.DrawImage(Are.Hit, (int)(p.X * Are.hitUnit), (int)(p.Y * Are.hitUnit), Are.WHH.Width, Are.WHH.Height);
}
}
public void Clear()
{
gd.Clear(ClearColor);
if (gh != null)
{
gh.Clear(ClearColor);
}
}
public void Clear(Color Color)
{
gd.Clear(Color);
if (gh != null)
{
gh.Clear(ClearColor);
}
}
public void Dispose()
{
Dis.Dispose();
gd.Dispose();
if (Hit != null)
{
Hit.Dispose();
gh.Dispose();
}
}
}

View File

@@ -0,0 +1,84 @@
using System.Drawing;
using System.Drawing.Drawing2D;
namespace _2DGAMELIB;
public class AreM : Are
{
private double strength;
private double unitS;
public AreM(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength)
{
Setting(Unit, XRatio, YRatio, Size, DisMag, HitMag, Strength);
}
private void Setting(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength)
{
SetXYRatio(XRatio, YRatio);
base.Size = Size;
unit = Unit;
strength = Strength;
disUnit = Unit * DisMag;
double num = 1.0 - Strength;
unitS = disUnit * num;
WH.Width = (int)(base.LocalWidth * Unit);
WH.Height = (int)(base.LocalHeight * Unit);
WHA.Width = (int)(base.LocalWidth * disUnit);
WHA.Height = (int)(base.LocalHeight * disUnit);
Dis = new Bitmap((int)((double)WH.Width * DisMag * num), (int)((double)WH.Height * DisMag * num));
gd = Graphics.FromImage(Dis);
gd.SmoothingMode = SmoothingMode.None;
gd.PixelOffsetMode = PixelOffsetMode.None;
hitUnit = Unit * HitMag;
WHH.Width = (int)(base.LocalWidth * hitUnit);
WHH.Height = (int)(base.LocalHeight * hitUnit);
Hit = new Bitmap(WHH.Width, WHH.Height);
gh = Graphics.FromImage(Hit);
gh.SmoothingMode = SmoothingMode.None;
gh.PixelOffsetMode = PixelOffsetMode.None;
}
public new void Draw(ParT ParT)
{
ParT.Draw(unitS, gd);
if (gh != null)
{
ParT.DrawH(hitUnit, gh);
}
}
public new void Draw(Pars Pars)
{
Pars.Draw(unitS, gd);
if (gh != null)
{
Pars.DrawH(hitUnit, gh);
}
}
public new void Draw(Graphics GD)
{
im = GD.InterpolationMode;
GD.InterpolationMode = InterpolationMode.NearestNeighbor;
p = GetPosition();
GD.DrawImage(Dis, (int)(p.X * unit), (int)(p.Y * unit), WH.Width, WH.Height);
GD.InterpolationMode = im;
}
public new void Draw(Graphics GD, double Opacity)
{
im = GD.InterpolationMode;
GD.InterpolationMode = InterpolationMode.NearestNeighbor;
cm.Matrix33 = (float)Opacity;
ia.SetColorMatrix(cm);
p = GetPosition();
r.X = (int)(p.X * unit);
r.Y = (int)(p.Y * unit);
r.Width = WH.Width;
r.Height = WH.Height;
GD.DrawImage(Dis, r, 0, 0, Dis.Width, Dis.Height, GraphicsUnit.Pixel, ia);
GD.InterpolationMode = im;
}
}

166
2DGAMELIB/_2DGAMELIB/But.cs Normal file
View File

@@ -0,0 +1,166 @@
using System;
using System.Drawing;
namespace _2DGAMELIB;
public class But
{
private bool dra = true;
private Color hc = Color.Transparent;
protected Pars pars;
protected Action<But> Over = delegate
{
};
protected Action<But> Push = delegate
{
};
protected Action<But> Release = delegate
{
};
protected Action<But> Out = delegate
{
};
public Action<But> Action = delegate
{
};
private bool f1;
private bool f2;
public bool Dra
{
get
{
return dra;
}
set
{
Move(ref hc);
dra = value;
}
}
public Pars Pars => pars;
public But(Par Par, Action<But> Action)
{
pars = new Pars(Par);
this.Action = Action;
}
public But(ParT ParT, Action<But> Action)
{
pars = new Pars(ParT);
this.Action = Action;
}
public But(Pars Pars, Action<But> Action)
{
pars = Pars;
this.Action = Action;
}
public bool Move(ref Color HitColor)
{
if (Dra && !f2 && pars.IsHit(ref HitColor))
{
f2 = true;
Over(this);
return true;
}
if (Dra && f2 && !pars.IsHit(ref HitColor))
{
f1 = false;
f2 = false;
Out(this);
return true;
}
return false;
}
public bool Leave()
{
if (Dra && f2)
{
f1 = false;
f2 = false;
Out(this);
return true;
}
return false;
}
public bool Down(ref Color HitColor)
{
if (Dra && !f1 && pars.IsHit(ref HitColor))
{
f1 = true;
Push(this);
return true;
}
return false;
}
public bool Up(ref Color HitColor)
{
if (Dra && f1 && pars.IsHit(ref HitColor))
{
f1 = false;
Release(this);
Action(this);
return true;
}
return false;
}
public void Draw(Are Are)
{
if (dra)
{
Are.Draw(pars);
}
}
public void Draw(AreM AreM)
{
if (dra)
{
AreM.Draw(pars);
}
}
public void SetHitColor(Med Med)
{
foreach (Par item in pars.EnumAllPar())
{
if (item.HitColor != Color.Transparent)
{
Med.RemUniqueColor(item.HitColor);
}
item.HitColor = Med.GetUniqueColor();
}
}
public void Dispose()
{
pars.Dispose();
}
public bool IsBut1()
{
return this is But1;
}
public But1 ToBut1()
{
return (But1)this;
}
}

View File

@@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace _2DGAMELIB;
public class But1 : But
{
public List<Color> BaseColors = new List<Color>();
public List<Color> OverColors = new List<Color>();
public List<Color> PushColors = new List<Color>();
public List<Color> TextColors = new List<Color>();
public But1(Par Par, Action<But> Action)
: base(Par, Action)
{
Setting();
}
public But1(ParT ParT, Action<But> Action)
: base(ParT, Action)
{
Setting();
}
public But1(Pars Pars, Action<But> Action)
: base(Pars, Action)
{
Setting();
}
private void Setting()
{
foreach (Par item in pars.EnumAllPar())
{
BaseColors.Add(item.BrushColor);
OverColors.Add(BaseColors.Last().FuncHSV(delegate(Hsv hsv)
{
hsv.Hue += 30;
hsv.Sat -= 30;
hsv.Val += 100;
return hsv;
}));
PushColors.Add(OverColors.Last().FuncHSV(delegate(Hsv hsv)
{
hsv.Hue += 30;
hsv.Sat -= 30;
hsv.Val += 100;
return hsv;
}));
TextColors.Add(item.IsParT() ? item.ToParT().TextColor : Color.Empty);
}
Over = delegate
{
int num4 = 0;
foreach (Par item2 in pars.EnumAllPar())
{
item2.BrushColor = OverColors[num4];
if (item2.IsParT())
{
item2.ToParT().TextColor = TextColors[num4].Reverse();
}
num4++;
}
};
Push = delegate
{
int num3 = 0;
foreach (Par item3 in pars.EnumAllPar())
{
item3.BrushColor = PushColors[num3];
if (item3.IsParT())
{
item3.ToParT().TextColor = TextColors[num3].Reverse();
}
num3++;
}
};
Release = delegate
{
int num2 = 0;
foreach (Par item4 in pars.EnumAllPar())
{
item4.BrushColor = OverColors[num2];
if (item4.IsParT())
{
item4.ToParT().TextColor = TextColors[num2].Reverse();
}
num2++;
}
};
Out = delegate
{
int num = 0;
foreach (Par item5 in pars.EnumAllPar())
{
item5.BrushColor = BaseColors[num];
if (item5.IsParT())
{
item5.ToParT().TextColor = TextColors[num];
}
num++;
}
};
}
}

View File

@@ -0,0 +1,88 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace _2DGAMELIB;
public class Buts
{
private OrderedDictionary<string, But> buts = new OrderedDictionary<string, But>();
public But this[string Name] => buts[Name];
public IEnumerable<But> EnumBut => buts.Values;
public void Add(string Name, But But)
{
buts.Add(Name, But);
}
public void Down(ref Color HitColor)
{
using IEnumerator<But> enumerator = buts.Values.GetEnumerator();
while (enumerator.MoveNext() && !enumerator.Current.Down(ref HitColor))
{
}
}
public void Up(ref Color HitColor)
{
using IEnumerator<But> enumerator = buts.Values.GetEnumerator();
while (enumerator.MoveNext() && !enumerator.Current.Up(ref HitColor))
{
}
}
public void Move(ref Color HitColor)
{
foreach (But value in buts.Values)
{
value.Move(ref HitColor);
}
}
public void Leave()
{
using IEnumerator<But> enumerator = buts.Values.GetEnumerator();
while (enumerator.MoveNext() && !enumerator.Current.Leave())
{
}
}
public void SetHitColor(Med Med)
{
foreach (But item in EnumBut)
{
item.SetHitColor(Med);
}
}
public void Draw(Are Are)
{
foreach (But value in buts.Values)
{
value.Draw(Are);
}
}
public void Draw(AreM AreM)
{
foreach (But value in buts.Values)
{
value.Draw(AreM);
}
}
public void Dispose()
{
foreach (But value in buts.Values)
{
value.Dispose();
}
}
public bool IsHit(Color hc)
{
return EnumBut.Any((But e) => e.Pars.Values.First().ToPar().HitColor == hc);
}
}

View File

@@ -0,0 +1,17 @@
namespace _2DGAMELIB;
public class ConstProp
{
private int c = -1;
public bool GetFlag(double Proportion)
{
c++;
return c % (int)(1.0 / Proportion) == 0;
}
public void Reset()
{
c = -1;
}
}

View File

@@ -0,0 +1,19 @@
using System.Runtime.InteropServices;
namespace _2DGAMELIB;
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct Dat
{
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);
public static MatrixD MatDIdentity = new MatrixD(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
public static Vector2D Vec2DZero = new Vector2D(0.0, 0.0);
public static Vector2D Vec2DOne = new Vector2D(1.0, 1.0);
public static Vector2D Vec2DUnitX = new Vector2D(1.0, 0.0);
public static Vector2D Vec2DUnitY = new Vector2D(0.0, 1.0);
}

292
2DGAMELIB/_2DGAMELIB/Dif.cs Normal file
View File

@@ -0,0 +1,292 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Documents;
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 double PositionSize
{
set
{
foreach (Pars item in parss)
{
item.PositionSize = value;
}
}
}
public Vector2D PositionVector
{
set
{
foreach (Pars item in parss)
{
item.PositionVector = value;
}
}
}
public double AngleBase
{
set
{
foreach (Pars item in parss)
{
item.AngleBase = value;
}
}
}
public double AngleCont
{
set
{
foreach (Pars item in parss)
{
item.AngleCont = value;
}
}
}
public double SizeBase
{
set
{
foreach (Pars item in parss)
{
item.SizeBase = value;
}
}
}
public double SizeCont
{
set
{
foreach (Pars item in parss)
{
item.SizeCont = value;
}
}
}
public double SizeXBase
{
set
{
foreach (Pars item in parss)
{
item.SizeXBase = value;
}
}
}
public double SizeXCont
{
set
{
foreach (Pars item in parss)
{
item.SizeXCont = value;
}
}
}
public double SizeYBase
{
set
{
foreach (Pars item in parss)
{
item.SizeYBase = value;
}
}
}
public double SizeYCont
{
set
{
foreach (Pars item in parss)
{
item.SizeYCont = value;
}
}
}
public bool Dra
{
set
{
foreach (Pars item in parss)
{
item.Dra = value;
}
}
}
public bool Hit
{
set
{
foreach (Pars item in parss)
{
item.Hit = 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 void Insert(int Index, Pars Pars)
{
parss.Insert(Index, Pars);
}
public void Remove(Pars Pars)
{
parss.Remove(Pars);
}
public void RemoveAt(int Index)
{
parss.RemoveAt(Index);
}
public void Draws(Are Are)
{
foreach (Pars item in parss)
{
Are.Draw(item);
}
}
public void Draws(AreM AreM)
{
foreach (Pars item in parss)
{
AreM.Draw(item);
}
}
public List<string> GetHitTags(ref Color HitColor)
{
List<string> list = new List<string>();
foreach (Pars item in parss)
{
list.AddRange(item.GetHitTags(ref HitColor));
}
return list;
}
public List<Par> GetHitPars(ref Color HitColor)
{
List<Par> list = new List<Par>();
foreach (Pars item in parss)
{
list.AddRange(item.GetHitPars(ref HitColor));
}
return list;
}
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

@@ -0,0 +1,477 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net.NetworkInformation;
using System.IO;
using System.Windows.Documents;
using Newtonsoft.Json;
namespace _2DGAMELIB;
[Serializable]
public class Difs
{
public string Tag = "";
public double ValueX;
public double ValueY;
private List<Dif> difs = new List<Dif>();
public Dictionary<Pars, Joints> pj;
public Dictionary<Pars, Par> pr;
public List<Dif> Difss => difs;
public int CountX => difs.Count;
public int CountY
{
get
{
if (difs.Count > 0)
{
return difs[IndexX].Count;
}
return 0;
}
}
public int IndexX
{
get
{
if (!(ValueX >= 1.0))
{
return (int)((double)CountX * ValueX);
}
return CountX - 1;
}
set
{
ValueX = (double)value / (double)CountX;
}
}
public int IndexY
{
get
{
if (!(ValueY >= 1.0))
{
return (int)((double)CountY * ValueY);
}
return CountY - 1;
}
set
{
ValueY = (double)value / (double)CountY;
}
}
public Dif this[int Index]
{
get
{
return difs[Index];
}
set
{
difs[Index] = value;
}
}
public Pars Current => difs[IndexX][IndexY];
public double PositionSize
{
set
{
foreach (Dif dif in difs)
{
dif.PositionSize = value;
}
}
}
public Vector2D PositionVector
{
set
{
foreach (Dif dif in difs)
{
dif.PositionVector = value;
}
}
}
public double AngleBase
{
set
{
foreach (Dif dif in difs)
{
dif.AngleBase = value;
}
}
}
public double AngleCont
{
set
{
foreach (Dif dif in difs)
{
dif.AngleCont = value;
}
}
}
public double SizeBase
{
set
{
foreach (Dif dif in difs)
{
dif.SizeBase = value;
}
}
}
public double SizeCont
{
set
{
foreach (Dif dif in difs)
{
dif.SizeCont = value;
}
}
}
public double SizeXBase
{
set
{
foreach (Dif dif in difs)
{
dif.SizeXBase = value;
}
}
}
public double SizeXCont
{
set
{
foreach (Dif dif in difs)
{
dif.SizeXCont = value;
}
}
}
public double SizeYBase
{
set
{
foreach (Dif dif in difs)
{
dif.SizeYBase = value;
}
}
}
public double SizeYCont
{
set
{
foreach (Dif dif in difs)
{
dif.SizeYCont = value;
}
}
}
public bool Dra
{
set
{
foreach (Dif dif in difs)
{
dif.Dra = value;
}
}
}
public bool Hit
{
set
{
foreach (Dif dif in difs)
{
dif.Hit = value;
}
}
}
[JsonIgnore]
public Par CurJoinRoot
{
get
{
Pars current = Current;
if (pr.ContainsKey(current))
{
return pr[current];
}
return null;
}
}
[JsonIgnore]
public IEnumerable<Par> EnumJoinRoot => pr.Values;
public IEnumerable<Par> EnumAllPar()
{
foreach (Dif dif in difs)
{
foreach (Par item in dif.EnumAllPar())
{
yield return item;
}
}
}
public IEnumerable<Pars> EnumAllPars()
{
foreach (Dif dif in difs)
{
foreach (Pars item in dif.Parss)
{
yield return item;
}
}
}
public void SetDefault()
{
foreach (Dif dif in difs)
{
dif.SetDefault();
}
}
public Difs()
{
}
public Difs(Difs Difs)
{
Copy(Difs);
}
private void Copy(Difs Difs)
{
Tag = Difs.Tag;
ValueX = Difs.ValueX;
ValueY = Difs.ValueY;
foreach (Dif dif in Difs.difs)
{
difs.Add(new Dif(dif));
}
}
public void Add(Dif Dif)
{
difs.Add(Dif);
}
public void Insert(int Index, Dif Dif)
{
difs.Insert(Index, Dif);
}
public void Remove(Dif Dif)
{
difs.Remove(Dif);
}
public void RemoveAt(int Index)
{
difs.RemoveAt(Index);
}
public void Draw(Are Are)
{
Are.Draw(Current);
}
public void Draws(Are Are)
{
foreach (Dif dif in difs)
{
dif.Draws(Are);
}
}
public void Draw(AreM AreM)
{
AreM.Draw(Current);
}
public void Draws(AreM AreM)
{
foreach (Dif dif in difs)
{
dif.Draws(AreM);
}
}
private Par GetJoinRoot(Pars ps)
{
Par[] array = ps.EnumAllPar().ToArray();
if (array.Length <= 1)
{
return array.FirstOrDefault();
}
Par[] array2 = array;
foreach (Par p0 in array2)
{
Vector2D p = p0.Position;
if (array.All((Par p1) => p0 == p1 || p1.JP.All((Joi j) => !(p1.ToGlobal(j.Joint).DistanceSquared(p) <= Join.IdentityDistance))))
{
return p0;
}
}
Par par = array.FirstOrDefault((Par e) => e.JP.Count > 0);
if (par != null)
{
return par;
}
return array.First();
}
public void SetJoints()
{
pj = new Dictionary<Pars, Joints>();
pr = new Dictionary<Pars, Par>();
foreach (Pars item in EnumAllPars())
{
Par joinRoot = GetJoinRoot(item);
if (joinRoot != null)
{
pj.Add(item, joinRoot.GetJoints(item.EnumAllPar()));
pr.Add(item, joinRoot);
}
}
}
public void JoinP()
{
pj[Current].JoinP();
}
public void JoinPA()
{
pj[Current].JoinPA();
}
public void JoinPall()
{
foreach (Joints value in pj.Values)
{
value.JoinP();
}
}
public void JoinPAall()
{
foreach (Joints value in pj.Values)
{
value.JoinPA();
}
}
public void JoinP(Pars ps)
{
if (pj.ContainsKey(ps))
{
pj[ps].JoinP();
}
}
public void JoinPA(Pars ps)
{
if (pj.ContainsKey(ps))
{
pj[ps].JoinPA();
}
}
public Par 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.HitColor == HitColor);
}
public List<string> GetHitTags(ref Color HitColor)
{
List<string> list = new List<string>();
foreach (Dif dif in difs)
{
list.AddRange(dif.GetHitTags(ref HitColor));
}
return list;
}
public List<Par> GetHitPars(ref Color HitColor)
{
List<Par> list = new List<Par>();
foreach (Dif dif in difs)
{
list.AddRange(dif.GetHitPars(ref HitColor));
}
return list;
}
public bool IsHit(ref Color HitColor)
{
foreach (Dif dif in difs)
{
if (dif.IsHit(ref HitColor))
{
return true;
}
}
return false;
}
public void ReverseX()
{
SetJoints();
foreach (Dif dif in difs)
{
dif.ReverseX();
}
JoinP();
}
public void ReverseY()
{
SetJoints();
foreach (Dif dif in difs)
{
dif.ReverseY();
}
JoinP();
}
public void Dispose()
{
foreach (Dif dif in difs)
{
dif.Dispose();
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Diagnostics;
namespace _2DGAMELIB;
public class FPS
{
public Stopwatch sw = new Stopwatch();
private long last_frame;
public double Value;
private int count;
private double ticks_per_frame;
public FPS(double FPS)
{
Value = FPS;
ticks_per_frame = (double)Stopwatch.Frequency / FPS;
sw.Start();
last_frame = sw.ElapsedTicks;
}
public void FPSFixed(Action Action)
{
long current_time = sw.ElapsedTicks;
if (current_time - last_frame >= ticks_per_frame)
{
Action();
Value = (9 * Value + ((double)Stopwatch.Frequency / (sw.ElapsedTicks - last_frame)))/10;
last_frame = current_time;
}
}
}

628
2DGAMELIB/_2DGAMELIB/Gau.cs Normal file
View File

@@ -0,0 +1,628 @@
using System.Drawing;
namespace _2DGAMELIB;
public enum Range
{
ZeroOne = 1,
MinusPlus
}
public enum Open
{
Top = 1,
Bot,
Lef,
Rig
}
public class Gau
{
private Pars pars;
private Par base_;
private Par frame1;
private Par frame2;
private Par gauge;
private Par knob;
private double val;
private Brush PlusBrush;
private Brush MinusBrush;
private Open Open;
private Range Range;
private double Max;
private bool Grip;
private Vector2D op;
private double Unit;
private Color PlusColor1;
private Color PlusColor2;
private Color MinusColor1;
private Color MinusColor2;
public Pars Pars => pars;
public Par Base => base_;
public Par Frame1 => frame1;
public Par Frame2 => frame2;
public Par Gauge => gauge;
public Par Knob => knob;
public double Value
{
get
{
return val;
}
set
{
val = value;
SetLimit();
SetColor();
SetValue();
}
}
private Vector2D TL1 => frame1.OP[0].ps[0];
private Vector2D TR1 => frame1.OP[0].ps[1];
private Vector2D BR1 => frame1.OP[0].ps[2];
private Vector2D BL1 => frame1.OP[0].ps[3];
private Vector2D TL2 => frame2.OP[0].ps[0];
private Vector2D TR2 => frame2.OP[0].ps[1];
private Vector2D BR2 => frame2.OP[0].ps[2];
private Vector2D BL2 => frame2.OP[0].ps[3];
private Vector2D TLG => gauge.OP[0].ps[0];
private Vector2D TRG => gauge.OP[0].ps[1];
private Vector2D BRG => gauge.OP[0].ps[2];
private Vector2D BLG => gauge.OP[0].ps[3];
private void SetLimit()
{
if (Range == Range.ZeroOne)
{
val = val.Clamp(0.0, 1.0);
}
else
{
val = val.Clamp(-1.0, 1.0);
}
}
private void SetColor()
{
if (val > 0.0)
{
gauge.SetBrush(PlusBrush);
}
else
{
gauge.SetBrush(MinusBrush);
}
}
private void SetValue()
{
if (Open == Open.Top || Open == Open.Bot)
{
gauge.SizeYCont = val;
}
else if (Open == Open.Lef || Open == Open.Rig)
{
gauge.SizeXCont = val;
}
if (knob != null)
{
knob.PositionBase = GetKnobPosition();
}
}
private Vector2D GetBasePoint1()
{
if (Range == Range.MinusPlus)
{
switch (Open)
{
case Open.Top:
return (BL1 + BR1) * 0.5;
case Open.Bot:
return (TL1 + TR1) * 0.5;
case Open.Rig:
return (TL1 + BL1) * 0.5;
case Open.Lef:
return (TR1 + BR1) * 0.5;
}
}
return frame1.OP.GetCenter();
}
private Vector2D GetBasePoint2()
{
if (Range == Range.MinusPlus)
{
switch (Open)
{
case Open.Top:
return (TL2 + TR2) * 0.5;
case Open.Bot:
return (BL2 + BR2) * 0.5;
case Open.Rig:
return (TR2 + BR2) * 0.5;
case Open.Lef:
return (TL2 + BL2) * 0.5;
}
}
return frame2.OP.GetCenter();
}
private Vector2D GetBasePoint()
{
if (Range == Range.ZeroOne)
{
switch (Open)
{
case Open.Top:
return (BLG + BRG) * 0.5;
case Open.Bot:
return (TLG + TRG) * 0.5;
case Open.Rig:
return (TLG + BLG) * 0.5;
case Open.Lef:
return (TRG + BRG) * 0.5;
}
}
return frame1.BasePoint;
}
private double GetWidthMag()
{
if (Range == Range.MinusPlus && (Open == Open.Lef || Open == Open.Rig))
{
return 0.5;
}
return 1.0;
}
private double GetHeightMag()
{
if (Range == Range.MinusPlus && (Open == Open.Top || Open == Open.Bot))
{
return 0.5;
}
return 1.0;
}
private double GetGaugeWidthMag(double Margin)
{
if (Open == Open.Top || Open == Open.Bot)
{
return (Margin * 2.0).Inverse();
}
return 1.0;
}
private double GetGaugeHeightMag(double Margin)
{
if (Open == Open.Lef || Open == Open.Rig)
{
return (Margin * 2.0).Inverse();
}
return 1.0;
}
private double GetKnobWidthMag(double Width)
{
if (Open == Open.Top || Open == Open.Bot)
{
return Width;
}
return 0.1;
}
private double GetKnobHeightMag(double Height)
{
if (Open == Open.Lef || Open == Open.Rig)
{
return Height;
}
return 0.1;
}
private Vector2D GetGaugePosition()
{
return Open switch
{
Open.Top => frame1.ToGlobal((BL1 + BR1) * 0.5),
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,
};
}
private Vector2D GetKnobPosition()
{
return Open switch
{
Open.Top => gauge.ToGlobal((TLG + TRG) * 0.5),
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,
};
}
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
{
Tag = Name + "_ベース",
InitializeOP = new Out[1] { Shas.Get正方形() },
PositionBase = Position,
SizeBase = Size,
SizeXBase = Width,
SizeYBase = Height,
Closed = true,
Pen = null,
BrushColor = BackColor
};
base_.BasePointBase = base_.OP.GetCenter();
pars.Add(base_.Tag, base_);
frame1 = new Par
{
Tag = Name + "_フレーム1",
InitializeOP = new Out[1] { Shas.Get正方形() },
PositionBase = Position,
SizeBase = Size,
SizeXBase = Width * GetWidthMag(),
SizeYBase = Height * GetHeightMag(),
Closed = true,
Brush = null
};
frame1.BasePointBase = GetBasePoint1();
pars.Add(frame1.Tag, frame1);
if (Range == Range.MinusPlus)
{
frame2 = new Par
{
Tag = Name + "_フレーム2",
InitializeOP = new Out[1] { Shas.Get正方形() },
PositionBase = Position,
SizeBase = Size,
SizeXBase = Width * GetWidthMag(),
SizeYBase = Height * GetHeightMag(),
Closed = true,
Brush = null
};
frame2.BasePointBase = GetBasePoint2();
pars.Add(frame2.Tag, frame2);
}
gauge = new Par
{
Tag = Name + "_ゲージ",
InitializeOP = new Out[1] { Shas.Get正方形() },
PositionBase = GetGaugePosition(),
SizeBase = Size,
SizeXBase = Width * GetWidthMag() * GetGaugeWidthMag(Margin),
SizeYBase = Height * GetHeightMag() * GetGaugeHeightMag(Margin),
Closed = true
};
gauge.BasePointBase = GetBasePoint();
pars.Add(gauge.Tag, gauge);
if (knob)
{
this.knob = new Par
{
Tag = Name + "_ブ",
InitializeOP = new Out[1] { Shas.Get正方形() },
SizeBase = Size,
SizeXBase = GetKnobWidthMag(Width),
SizeYBase = GetKnobHeightMag(Height),
Closed = true,
BrushColor = Color.FromArgb(128, Color.White)
};
this.knob.BasePointBase = this.knob.OP.GetCenter();
pars.Add(this.knob.Tag, this.knob);
}
}
public void SetHitColor(Med Med)
{
if (base_.HitColor != Color.Transparent)
{
Med.RemUniqueColor(base_.HitColor);
}
base_.HitColor = Med.GetUniqueColor();
if (frame1.HitColor != Color.Transparent)
{
Med.RemUniqueColor(frame1.HitColor);
}
frame1.HitColor = Med.GetUniqueColor();
if (Range == Range.MinusPlus)
{
if (frame2.HitColor != Color.Transparent)
{
Med.RemUniqueColor(frame2.HitColor);
}
frame2.HitColor = Med.GetUniqueColor();
}
if (gauge.HitColor != Color.Transparent)
{
Med.RemUniqueColor(gauge.HitColor);
}
gauge.HitColor = Med.GetUniqueColor();
if (knob != null)
{
if (knob.HitColor != Color.Transparent)
{
Med.RemUniqueColor(knob.HitColor);
}
knob.HitColor = Med.GetUniqueColor();
}
}
private void SetBrush(double Unit, ref Color PlusColor1, ref Color PlusColor2, ref Color MinusColor1, ref Color MinusColor2)
{
this.Unit = Unit;
this.PlusColor1 = PlusColor1;
this.PlusColor2 = PlusColor2;
this.MinusColor1 = MinusColor1;
this.MinusColor2 = MinusColor2;
switch (Open)
{
case Open.Top:
{
frame1.GetMiY_MaY(out var MM7);
PlusBrush = Oth.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);
}
break;
}
case Open.Bot:
{
frame1.GetMaY_MiY(out var MM3);
PlusBrush = Oth.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);
}
break;
}
case Open.Rig:
{
frame1.GetMaX_MiX(out var MM5);
PlusBrush = Oth.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);
}
break;
}
case Open.Lef:
{
frame1.GetMiX_MaX(out var MM);
PlusBrush = Oth.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);
}
break;
}
}
}
public void SetAlphaG(double Alpha)
{
switch (Open)
{
case Open.Top:
{
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));
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));
}
break;
}
case Open.Bot:
{
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));
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));
}
break;
}
case Open.Rig:
{
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));
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));
}
break;
}
case Open.Lef:
{
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));
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));
}
break;
}
}
}
private double GetMax()
{
return Open switch
{
Open.Top => (0.0 - gauge.SizeY) * gauge.Size,
Open.Bot => gauge.SizeY * gauge.Size,
Open.Rig => gauge.SizeX * gauge.Size,
Open.Lef => (0.0 - gauge.SizeX) * gauge.Size,
_ => 0.0,
};
}
private double GetDifference(ref Vector2D CursorPosition)
{
if (Open == Open.Top || Open == Open.Bot)
{
return CursorPosition.Y - op.Y;
}
if (Open == Open.Lef || Open == Open.Rig)
{
return CursorPosition.X - op.X;
}
return 0.0;
}
public Gau(string Name, ref Vector2D Position, double Size, double Width, double Height, double Margin, Open Open, Range Range, ref Color PlusColor, ref Color MinusColor, ref Color BackColor, bool Knob)
{
this.Open = Open;
this.Range = Range;
PlusBrush = new SolidBrush(PlusColor);
MinusBrush = new SolidBrush(MinusColor);
ParSetting(Name, ref Position, Size, Width, Height, Margin, ref BackColor, Knob);
Max = GetMax();
Value = 0.0;
}
public Gau(string Name, Vector2D Position, double Size, double Width, double Height, double Margin, Open Open, Range Range, Color PlusColor, Color MinusColor, Color BackColor, bool Knob)
{
this.Open = Open;
this.Range = Range;
PlusBrush = new SolidBrush(PlusColor);
MinusBrush = new SolidBrush(MinusColor);
ParSetting(Name, ref Position, Size, Width, Height, Margin, ref BackColor, Knob);
Max = GetMax();
Value = 0.0;
}
public Gau(string Name, ref Vector2D Position, double Size, double Width, double Height, double Margin, Open Open, Range Range, double DisUnit, ref Color PlusColor1, ref Color PlusColor2, ref Color MinusColor1, ref Color MinusColor2, ref Color BackColor, bool Knob)
{
this.Open = Open;
this.Range = Range;
ParSetting(Name, ref Position, Size, Width, Height, Margin, ref BackColor, Knob);
SetBrush(DisUnit, ref PlusColor1, ref PlusColor2, ref MinusColor1, ref MinusColor2);
Max = GetMax();
Value = 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)
{
this.Open = Open;
this.Range = Range;
ParSetting(Name, ref Position, Size, Width, Height, Margin, ref BackColor, Knob);
SetBrush(DisUnit, ref PlusColor1, ref PlusColor2, ref MinusColor1, ref MinusColor2);
Max = GetMax();
Value = 0.0;
}
public bool Down(ref Color HitColor, ref Vector2D CursorPosition)
{
if (knob != null && knob.HitColor == HitColor)
{
Grip = true;
op = CursorPosition;
return true;
}
return false;
}
public bool Up()
{
if (Grip)
{
Grip = false;
return true;
}
return false;
}
public bool Move(ref Vector2D CursorPosition)
{
if (Grip)
{
Value += GetDifference(ref CursorPosition) / Max;
op = CursorPosition;
return true;
}
return false;
}
public bool Leave()
{
if (Grip)
{
Grip = false;
return true;
}
return false;
}
public void Dispose()
{
pars.Dispose();
PlusBrush.Dispose();
if (MinusBrush != null)
{
MinusBrush.Dispose();
}
}
}

306
2DGAMELIB/_2DGAMELIB/HSV.cs Normal file
View File

@@ -0,0 +1,306 @@
using System.Drawing;
namespace _2DGAMELIB;
public static class HSV
{
public static void ToHSV(int r, int g, int b, out int h, out int s, out int v)
{
v = GetMax(r, g, b);
int num = v - GetMin(r, g, b);
if (num == 0)
{
s = 0;
}
else
{
s = (int)((double)(num * 255) / (double)v);
}
if (s == 0)
{
h = 0;
return;
}
double num2 = num;
if (r == v)
{
h = v - (int)((double)(b * 60) / num2) - (v - (int)((double)(g * 60) / num2));
}
else if (g == v)
{
h = 120 + (v - (int)((double)(r * 60) / num2)) - (v - (int)((double)(b * 60) / num2));
}
else
{
h = 240 + (v - (int)((double)(g * 60) / num2)) - (v - (int)((double)(r * 60) / num2));
}
if (h < 0)
{
h += 360;
}
}
public static void ToRGB(int h, int s, int v, out int r, out int g, out int b)
{
if (s == 0)
{
r = (g = (b = v));
return;
}
int num = h * 6;
switch (num / 360)
{
case 0:
r = v;
g = (int)((double)(v * (255 - (int)((double)(s * (360 - num % 360)) / 360.0))) / 255.0);
b = (int)((double)(v * (255 - s)) / 255.0);
break;
case 1:
r = (int)((double)(v * (255 - (int)((double)(s * (num % 360)) / 360.0))) / 255.0);
g = v;
b = (int)((double)(v * (255 - s)) / 255.0);
break;
case 2:
r = (int)((double)(v * (255 - s)) / 255.0);
g = v;
b = (int)((double)(v * (255 - (int)((double)(s * (360 - num % 360)) / 360.0))) / 255.0);
break;
case 3:
r = (int)((double)(v * (255 - s)) / 255.0);
g = (int)((double)(v * (255 - (int)((double)(s * (num % 360)) / 360.0))) / 255.0);
b = v;
break;
case 4:
r = (int)((double)(v * (255 - (int)((double)(s * (360 - num % 360)) / 360.0))) / 255.0);
g = (int)((double)(v * (255 - s)) / 255.0);
b = v;
break;
default:
r = v;
g = (int)((double)(v * (255 - s)) / 255.0);
b = (int)((double)(v * (255 - (int)((double)(s * (num % 360)) / 360.0))) / 255.0);
break;
}
}
public static void ToHSV(this Color col, out int h, out int s, out int v)
{
ToHSV(col.R, col.G, col.B, out h, out s, out v);
}
public static void ToHSV(ref Color col, out int h, out int s, out int v)
{
ToHSV(col.R, col.G, col.B, out h, out s, out v);
}
public static void ToRGB(int h, int s, int v, out Color ret)
{
ToRGB(h, s, v, out var r, out var g, out var b);
ret = Color.FromArgb(r, g, b);
}
public static void ToRGB(int h, int s, int v, int a, out Color ret)
{
ToRGB(h, s, v, out var r, out var g, out var b);
ret = Color.FromArgb(a, r, g, b);
}
public static void ToRGB(this Hsv hsv, out int r, out int g, out int b)
{
ToRGB(hsv.H, hsv.S, hsv.V, out r, out g, out b);
}
public static void ToRGB(ref Hsv hsv, out int r, out int g, out int b)
{
ToRGB(hsv.H, hsv.S, hsv.V, out r, out g, out b);
}
public static Hsv ToHSV(int r, int g, int b)
{
Hsv result = default(Hsv);
ToHSV(r, g, b, out result.H, out result.S, out result.V);
return result;
}
public static Hsv ToHSV(this Color col)
{
Hsv result = default(Hsv);
ToHSV(col.R, col.G, col.B, out result.H, out result.S, out result.V);
return result;
}
public static Hsv ToHSV(ref Color col)
{
Hsv result = default(Hsv);
ToHSV(col.R, col.G, col.B, out result.H, out result.S, out result.V);
return result;
}
public static Color ToRGB(this Hsv hsv)
{
ToRGB(hsv.H, hsv.S, hsv.V, out var r, out var g, out var b);
return Color.FromArgb(r, g, b);
}
public static Color ToRGB(ref Hsv hsv)
{
ToRGB(hsv.H, hsv.S, hsv.V, out var r, out var g, out var b);
return Color.FromArgb(r, g, b);
}
private static int GetMax(int x, int y, int z)
{
if (x < y)
{
if (z >= y)
{
return z;
}
return y;
}
if (z < x)
{
return x;
}
return z;
}
private static int GetMin(int x, int y, int z)
{
if (x > y)
{
if (z <= y)
{
return z;
}
return y;
}
if (z > x)
{
return x;
}
return z;
}
}
public struct Hsv
{
public int H;
public int S;
public int V;
public int Hue
{
get
{
return H;
}
set
{
H = value;
HueLimit();
}
}
public int Sat
{
get
{
return S;
}
set
{
S = value;
SatLimit();
}
}
public int Val
{
get
{
return V;
}
set
{
V = value;
ValLimit();
}
}
public Hsv(Color Color)
{
HSV.ToHSV(Color.R, Color.G, Color.B, out H, out S, out V);
}
public Hsv(ref Color Color)
{
HSV.ToHSV(Color.R, Color.G, Color.B, out H, out S, out V);
}
public Hsv(int Hue, int Sat, int Val)
{
H = Hue;
S = Sat;
V = Val;
}
private void HueLimit()
{
H %= 360;
}
private void SatLimit()
{
if (S > 255)
{
S = 255;
}
else if (S < 0)
{
S = 0;
}
}
private void ValLimit()
{
if (V > 255)
{
V = 255;
}
else if (V < 0)
{
V = 0;
}
}
public Color GetColor()
{
HSV.ToRGB(H, S, V, out var r, out var g, out var b);
return Color.FromArgb(r, g, b);
}
public Color GetColor(int a)
{
HSV.ToRGB(H, S, V, out var r, out var g, out var b);
return Color.FromArgb(a, r, g, b);
}
public void GetColor(out Color ret)
{
HSV.ToRGB(H, S, V, out var r, out var g, out var b);
ret = Color.FromArgb(r, g, b);
}
public void GetColor(int a, out Color ret)
{
HSV.ToRGB(H, S, V, out var r, out var g, out var b);
ret = Color.FromArgb(a, r, g, b);
}
public override string ToString()
{
return "H : " + H + " S : " + S + " V : " + V;
}
}

View File

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

View File

@@ -0,0 +1,196 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace _2DGAMELIB;
public static class Join
{
public static double IdentityDistance = System.Math.Pow(5E-05, 2.0);
public static Joints GetJoints(this Par JoinRoot, IEnumerable<Par> EnumPar)
{
Joints joints = new Joints();
int num = 0;
List<int> list = new List<int>();
List<Par> list2 = EnumPar.ToList();
foreach (Joi item in JoinRoot.JP)
{
Vector2D v = JoinRoot.ToGlobal(item.Joint);
int num2 = 0;
list.Clear();
foreach (Par item2 in list2)
{
if (JoinRoot != item2)
{
if (v.DistanceSquared(item2.Position) <= IdentityDistance)
{
joints.Joins.Add(new Joint(JoinRoot, num, item2));
if (!list.Contains(num2))
{
list.Add(num2);
}
}
}
else if (!list.Contains(num2))
{
list.Add(num2);
}
num2++;
}
for (int num3 = list.Count - 1; num3 > -1; num3--)
{
list2.RemoveAt(list[num3]);
}
num++;
}
GetJoints(list2, joints, list);
return joints;
}
private static void GetJoints(List<Par> pl, Joints js, List<int> del)
{
int num = -1;
int num2 = 0;
while (num != js.Joins.Count)
{
num = js.Joins.Count;
for (int i = num2; i < num; i++)
{
Par par = js.Joins[i].Par1;
int num3 = 0;
foreach (Joi item in par.JP)
{
Vector2D v = par.ToGlobal(item.Joint);
int num4 = 0;
del.Clear();
foreach (Par item2 in pl)
{
if (par != item2)
{
if (v.DistanceSquared(item2.Position) <= IdentityDistance)
{
js.Joins.Add(new Joint(par, num3, item2));
if (!del.Contains(num4))
{
del.Add(num4);
}
}
}
else if (!del.Contains(num4))
{
del.Add(num4);
}
num4++;
}
for (int num5 = del.Count - 1; num5 > -1; num5--)
{
pl.RemoveAt(del[num5]);
}
num3++;
}
}
num2 = num;
}
}
public static JointsD GetJointsD(this Difs JoinRoot, IEnumerable<Difs> EnumDifs)
{
JointsD jointsD = new JointsD();
List<int> list = new List<int>();
List<Difs> list2 = EnumDifs.ToList();
foreach (Par item in JoinRoot.EnumAllPar())
{
int num = 0;
list.Clear();
foreach (Difs item2 in list2)
{
if (JoinRoot != item2)
{
int num2 = 0;
foreach (Joi item3 in item.JP)
{
Vector2D v = item.ToGlobal(item3.Joint);
foreach (Par item4 in item2.EnumJoinRoot)
{
if (v.DistanceSquared(item4.Position) <= IdentityDistance)
{
jointsD.Joins.Add(new JointD(JoinRoot, item, num2, item2));
if (!list.Contains(num))
{
list.Add(num);
}
break;
}
}
num2++;
}
}
else if (!list.Contains(num))
{
list.Add(num);
}
num++;
}
for (int num3 = list.Count - 1; num3 > -1; num3--)
{
list2.RemoveAt(list[num3]);
}
}
GetJointsD(list2, jointsD, list);
return jointsD;
}
private static void GetJointsD(List<Difs> dl, JointsD jsd, List<int> del)
{
int num = -1;
int num2 = 0;
while (num != jsd.Joins.Count)
{
num = jsd.Joins.Count;
for (int i = num2; i < num; i++)
{
Difs difs = jsd.Joins[i].Difs1;
foreach (Par item in difs.EnumAllPar())
{
int num3 = 0;
del.Clear();
foreach (Difs item2 in dl)
{
if (difs != item2)
{
int num4 = 0;
foreach (Joi item3 in item.JP)
{
Vector2D v = item.ToGlobal(item3.Joint);
foreach (Par item4 in item2.EnumJoinRoot)
{
if (v.DistanceSquared(item4.Position) <= IdentityDistance)
{
jsd.Joins.Add(new JointD(difs, item, num4, item2));
if (!del.Contains(num3))
{
del.Add(num3);
}
break;
}
}
num4++;
}
}
else if (!del.Contains(num3))
{
del.Add(num3);
}
num3++;
}
for (int num5 = del.Count - 1; num5 > -1; num5--)
{
dl.RemoveAt(del[num5]);
}
}
}
num2 = num;
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
namespace _2DGAMELIB;
[Serializable]
public class Joint
{
public Par Par0;
public int Index;
public Par Par1;
public Joint(Par Par0, int Index, Par Par1)
{
this.Par0 = Par0;
this.Index = Index;
this.Par1 = Par1;
}
public void JoinP()
{
Par0.SetJointP(Index, Par1);
}
public void JoinPA()
{
Par0.SetJointPA(Index, Par1);
}
}

View File

@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
namespace _2DGAMELIB;
[Serializable]
public class JointD
{
public Difs Difs0;
public List<int> Path0;
public int Index;
public Difs Difs1;
public JointD(Difs Difs0, Par Par0, int Index, Difs Difs1)
{
this.Difs0 = Difs0;
Path0 = Par0.GetPath();
this.Index = Index;
this.Difs1 = Difs1;
}
public JointD(Difs Difs1)
{
this.Difs1 = Difs1;
}
public void JoinP()
{
Difs0.Current.GetPar(Path0).SetJointP(Index, Difs1.CurJoinRoot);
Difs1.JoinPA();
}
public void JoinPA()
{
Difs0.Current.GetPar(Path0).SetJointPA(Index, Difs1.CurJoinRoot);
Difs1.JoinPA();
}
public void JoinPall()
{
foreach (Par item in Difs1.EnumJoinRoot)
{
Difs0.Current.GetPar(Path0).SetJointP(Index, item);
}
foreach (Pars item2 in Difs1.EnumAllPars())
{
Difs1.JoinPA(item2);
}
}
public void JoinPAall()
{
foreach (Par item in Difs1.EnumJoinRoot)
{
Difs0.Current.GetPar(Path0).SetJointPA(Index, item);
}
foreach (Pars item2 in Difs1.EnumAllPars())
{
Difs1.JoinPA(item2);
}
}
public void Set(JointS )
{
Difs0 = .Difs;
Path0 = .Path;
Index = .Index;
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
namespace _2DGAMELIB;
[Serializable]
public class Joints
{
public List<Joint> Joins = new List<Joint>();
public void JoinP()
{
foreach (Joint join in Joins)
{
join.JoinP();
}
}
public void JoinPA()
{
foreach (Joint join in Joins)
{
join.JoinPA();
}
}
}
[Serializable]
public class JointS
{
public Difs Difs;
public List<int> Path;
public int Index;
public JointS()
{
}
public JointS(Difs Difs, Par Par, int Index)
{
this.Difs = Difs;
Path = Par.GetPath();
this.Index = Index;
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
namespace _2DGAMELIB;
[Serializable]
public class JointsD
{
public List<JointD> Joins = new List<JointD>();
public void JoinP()
{
foreach (JointD join in Joins)
{
join.JoinP();
}
}
public void JoinPA()
{
foreach (JointD join in Joins)
{
join.JoinPA();
}
}
public void JoinPall()
{
foreach (JointD join in Joins)
{
join.JoinPall();
}
}
public void JoinPAall()
{
foreach (JointD join in Joins)
{
join.JoinPAall();
}
}
}

215
2DGAMELIB/_2DGAMELIB/Lab.cs Normal file
View File

@@ -0,0 +1,215 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace _2DGAMELIB;
public class Lab
{
private ParT parT;
private Med Med;
private Are Are;
private double Width;
private bool Input;
private double Min;
private TextBox tb;
public ParT ParT => parT;
public string Text
{
get
{
return parT.Text;
}
set
{
if (!Med.BaseControl.Contains(tb))
{
SetText(value);
}
}
}
private void SetText(string Text)
{
parT.Text = Text;
SetRect();
}
public Lab(Med Med, Are Are, string Name, ref Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, ref Color TextColor, ref Color ShadColor, ref Color BackColor, ref Color FramColor, bool Input)
{
Setting(Med, Are, Name, ref Position, Size, Width, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor, ref FramColor, Input);
}
public Lab(Med Med, Are Are, string Name, Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, Color TextColor, Color ShadColor, Color BackColor, Color FramColor, bool Input)
{
Setting(Med, Are, Name, ref Position, Size, Width, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor, ref FramColor, Input);
}
private void Setting(Med Med, Are Are, string Name, ref Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, ref Color TextColor, ref Color ShadColor, ref Color BackColor, ref Color FramColor, bool Input)
{
this.Med = Med;
this.Are = Are;
this.Width = Width;
this.Input = Input;
if (Input)
{
tb = new TextBox();
tb.WordWrap = true;
tb.Multiline = true;
tb.Text = Text;
tb.ForeColor = TextColor;
tb.BackColor = Color.FromArgb(255, BackColor);
tb.KeyUp += delegate
{
lock (Med.obj)
{
SetText(tb.Text);
parT.Text = "";
SetRectT();
}
};
tb.KeyDown += delegate(object s, KeyEventArgs e)
{
lock (Med.obj)
{
if (e.KeyCode == Keys.Return)
{
this.Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
e.SuppressKeyPress = true;
}
}
};
tb.PreviewKeyDown += delegate(object s, PreviewKeyDownEventArgs e)
{
e.IsInputKey = true;
};
Med.BaseControl.Controls.Add(tb);
Med.BaseControl.Controls.Remove(tb);
((Control)Med.BaseControl).Resize += Lab_Resize;
}
Out[] array = new Out[1] { Shas.Get正方形() };
if (FramColor == Color.Empty || FramColor == Color.Transparent)
{
array.OutlineFalse();
}
parT = new ParT
{
Tag = Name,
InitializeOP = array,
BasePointBase = array[0].ps[0],
PositionBase = Position,
SizeBase = Size,
Closed = true,
BrushColor = BackColor,
PenColor = FramColor,
Font = Font,
FontSize = TextSize,
TextColor = TextColor,
Text = "A"
};
if (ShadColor != Color.Empty)
{
parT.ShadBrush = new SolidBrush(ShadColor);
}
SetRect();
Min = parT.RectSize.Y;
SetText(Text);
}
private void Lab_Resize(object sender, EventArgs e)
{
Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
}
public void SetHitColor(Med Med)
{
if (parT.HitColor != Color.Transparent)
{
Med.RemUniqueColor(parT.HitColor);
}
parT.HitColor = Med.GetUniqueColor();
}
private void SetRect()
{
if (!string.IsNullOrEmpty(parT.Text))
{
parT.RectSize = new Vector2D(Width, 10.0);
Vector2D_2 stringRect = parT.GetStringRect(Are.DisUnit, Are.GD);
double x = ((stringRect.v2.X > Min) ? stringRect.v2.X : Min) + 0.07;
parT.RectSize = new Vector2D(x, stringRect.v2.Y);
}
else
{
double x2 = Min + 0.07;
parT.RectSize = new Vector2D(x2, Min);
}
parT.OP[0].ps[0] = new Vector2D(0.0, 0.0);
parT.OP[0].ps[1] = new Vector2D(parT.RectSize.X, 0.0);
parT.OP[0].ps[2] = new Vector2D(parT.RectSize.X, parT.RectSize.Y);
parT.OP[0].ps[3] = new Vector2D(0.0, parT.RectSize.Y);
}
private void SetRectT()
{
double resMag = Med.ResMag;
Vector2D vector2D = (parT.Position + Are.GetPosition()) * Med.Unit / resMag + Med.ResVector;
tb.Location = new Point((int)vector2D.X - 1, (int)vector2D.Y - 1);
double num = parT.Size * Med.Unit;
if (tb.Font != null)
{
tb.Font.Dispose();
}
tb.Font = new Font(parT.Font.FontFamily, (float)(parT.FontSize * num / resMag));
Vector2D vector2D2 = parT.RectSize * num / resMag;
tb.Size = new Size((int)(vector2D2.X + 2.0), (int)(vector2D2.Y + 10.0));
}
public bool Double(ref Color HitColor)
{
if (Input && parT.HitColor == HitColor && !Med.BaseControl.Controls.Contains(tb))
{
tb.Text = parT.Text;
parT.Text = "";
SetRectT();
Med.BaseControl.Controls.Add(tb);
tb.SelectAll();
tb.Focus();
tb.BringToFront();
return true;
}
return false;
}
public void Click(ref Color HitColor)
{
if (Input && parT.HitColor != HitColor && Med.BaseControl.Controls.Contains(tb))
{
Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
}
}
public void Dispose()
{
parT.Dispose();
if (Input)
{
((Control)Med.BaseControl).Resize -= Lab_Resize;
}
if (tb != null)
{
tb.Dispose();
}
}
}

View File

@@ -0,0 +1,79 @@
using System.Collections.Generic;
using System.Drawing;
namespace _2DGAMELIB;
public class Labs
{
private OrderedDictionary<string, Lab> labs = new OrderedDictionary<string, Lab>();
private Med Med;
private Are Are;
public Lab this[string Name] => labs[Name];
public Labs(Med Med, Are Are)
{
this.Med = Med;
this.Are = Are;
}
public void Add(string Name, Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, Color TextColor, Color ShadColor, Color BackColor, Color FramColor, bool Input)
{
labs.Add(Name, new Lab(Med, Are, Name, ref Position, Size, Width, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor, ref FramColor, Input));
}
public void Add(string Name, ref Vector2D Position, double Size, double Width, Font Font, double TextSize, string Text, ref Color TextColor, ref Color ShadColor, ref Color BackColor, ref Color FramColor, bool Input)
{
labs.Add(Name, new Lab(Med, Are, Name, ref Position, Size, Width, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor, ref FramColor, Input));
}
public void Double(ref Color HitColor)
{
using IEnumerator<Lab> enumerator = labs.Values.GetEnumerator();
while (enumerator.MoveNext() && !enumerator.Current.Double(ref HitColor))
{
}
}
public void Click(ref Color HitColor)
{
foreach (Lab value in labs.Values)
{
value.Click(ref HitColor);
}
}
public void SetHitColor(Med Med)
{
foreach (Lab value in labs.Values)
{
value.SetHitColor(Med);
}
}
public void Draw(Are Are)
{
foreach (Lab value in labs.Values)
{
Are.Draw(value.ParT);
}
}
public void Draw(AreM AreM)
{
foreach (Lab value in labs.Values)
{
AreM.Draw(value.ParT);
}
}
public void Dispose()
{
foreach (Lab value in labs.Values)
{
value.Dispose();
}
}
}

View File

@@ -0,0 +1,98 @@
using System;
namespace _2DGAMELIB;
//TODO remove these...
public static class Math
{
public static double RoundDown(this double Value, int Digits)
{
double num = System.Math.Pow(10.0, Digits);
if (!(Value > 0.0))
{
return System.Math.Ceiling(Value * num) / num;
}
return System.Math.Floor(Value * num) / num;
}
public static double Inverse(this double Rate)
{
if (Rate == 0.0)
{
return 1.0;
}
return (double)System.Math.Sign(Rate) - Rate;
}
public static double Reciprocal(this double Rate)
{
if (Rate == 0.0)
{
return 1.0;
}
return 1.0 / Rate;
}
public static double ToRadian(this double Degree)
{
return System.Math.PI * Degree / 180.0;
}
public static double ToDegree(this double Radian)
{
return Radian * 180.0 / System.Math.PI;
}
public static double Pow(this double x, double n)
{
return System.Math.Pow(x, n);
}
public static double Sin(this double θ)
{
return System.Math.Sin(θ);
}
public static double Abs(this double x)
{
return System.Math.Abs(x);
}
public static int Abs(this int x)
{
return System.Math.Abs(x);
}
public static int Sign(this double x)
{
return System.Math.Sign(x);
}
public static int Sign(this int x)
{
return System.Math.Sign(x);
}
public static double Sqrt(this double x)
{
return System.Math.Sqrt(x);
}
public static double Max(this double a, double b)
{
return System.Math.Max(a, b);
}
public static int Clamp(this int Value, int Min, int Max)
{
return System.Math.Min(Max, System.Math.Max(Min, Value));
}
public static double Clamp(this double Value, double Min, double Max)
{
return System.Math.Min(Max, System.Math.Max(Min, Value));
}
public static int Limit(this int Value, int Sta, int Les)
{
return System.Math.Min(Les-1, System.Math.Max(Sta, Value));
}
}

View File

@@ -0,0 +1,154 @@
using System;
namespace _2DGAMELIB;
public static class Matrix
{
public static MatrixD RotationZ(this double angle)
{
MatrixD result = default(MatrixD);
result.M11 = System.Math.Cos(angle);
result.M12 = System.Math.Sin(angle);
result.M13 = 0.0;
result.M14 = 0.0;
result.M21 = 0.0 - result.M12;
result.M22 = result.M11;
result.M23 = 0.0;
result.M24 = 0.0;
result.M31 = 0.0;
result.M32 = 0.0;
result.M33 = 1.0;
result.M34 = 0.0;
result.M41 = 0.0;
result.M42 = 0.0;
result.M43 = 0.0;
result.M44 = 1.0;
return result;
}
public static void RotationZ(this double angle, out MatrixD result)
{
result.M11 = System.Math.Cos(angle);
result.M12 = System.Math.Sin(angle);
result.M13 = 0.0;
result.M14 = 0.0;
result.M21 = 0.0 - result.M12;
result.M22 = result.M11;
result.M23 = 0.0;
result.M24 = 0.0;
result.M31 = 0.0;
result.M32 = 0.0;
result.M33 = 1.0;
result.M34 = 0.0;
result.M41 = 0.0;
result.M42 = 0.0;
result.M43 = 0.0;
result.M44 = 1.0;
}
public static Vector2D TransformCoordinate(this Vector2D coord, MatrixD transform)
{
double num = 1.0 / (coord.X * transform.M14 + coord.Y * transform.M24 + transform.M44);
return new Vector2D((coord.X * transform.M11 + coord.Y * transform.M21 + transform.M41) * num, (coord.X * transform.M12 + coord.Y * transform.M22 + transform.M42) * num);
}
public static Vector2D TransformCoordinate(ref Vector2D coord, ref MatrixD transform)
{
double num = 1.0 / (coord.X * transform.M14 + coord.Y * transform.M24 + transform.M44);
return new Vector2D((coord.X * transform.M11 + coord.Y * transform.M21 + transform.M41) * num, (coord.X * transform.M12 + coord.Y * transform.M22 + transform.M42) * num);
}
public static void TransformCoordinate(this Vector2D coord, MatrixD transform, out Vector2D result)
{
double num = 1.0 / (coord.X * transform.M14 + coord.Y * transform.M24 + transform.M44);
result.X = (coord.X * transform.M11 + coord.Y * transform.M21 + transform.M41) * num;
result.Y = (coord.X * transform.M12 + coord.Y * transform.M22 + transform.M42) * num;
}
public static void TransformCoordinate(ref Vector2D coord, ref MatrixD transform, out Vector2D result)
{
double num = 1.0 / (coord.X * transform.M14 + coord.Y * transform.M24 + transform.M44);
result.X = (coord.X * transform.M11 + coord.Y * transform.M21 + transform.M41) * num;
result.Y = (coord.X * transform.M12 + coord.Y * transform.M22 + transform.M42) * num;
}
public static Vector2D[] TransformCoordinate(this Vector2D[] coords, MatrixD transform)
{
int num = coords.Length;
Vector2D[] array = new Vector2D[num];
for (int i = 0; i < num; i++)
{
double num2 = 1.0 / (coords[i].X * transform.M14 + coords[i].Y * transform.M24 + transform.M44);
array[i].X = (coords[i].X * transform.M11 + coords[i].Y * transform.M21 + transform.M41) * num2;
array[i].Y = (coords[i].X * transform.M12 + coords[i].Y * transform.M22 + transform.M42) * num2;
}
return array;
}
public static Vector2D[] TransformCoordinate(this Vector2D[] coords, ref MatrixD transform)
{
int num = coords.Length;
Vector2D[] array = new Vector2D[num];
for (int i = 0; i < num; i++)
{
double num2 = 1.0 / (coords[i].X * transform.M14 + coords[i].Y * transform.M24 + transform.M44);
array[i].X = (coords[i].X * transform.M11 + coords[i].Y * transform.M21 + transform.M41) * num2;
array[i].Y = (coords[i].X * transform.M12 + coords[i].Y * transform.M22 + transform.M42) * num2;
}
return array;
}
public static void TransformCoordinate(this Vector2D[] coords, MatrixD transform, out Vector2D[] results)
{
int num = coords.Length;
results = new Vector2D[num];
for (int i = 0; i < num; i++)
{
double num2 = 1.0 / (coords[i].X * transform.M14 + coords[i].Y * transform.M24 + transform.M44);
results[i].X = (coords[i].X * transform.M11 + coords[i].Y * transform.M21 + transform.M41) * num2;
results[i].Y = (coords[i].X * transform.M12 + coords[i].Y * transform.M22 + transform.M42) * num2;
}
}
public static void TransformCoordinate(this Vector2D[] coords, ref MatrixD transform, out Vector2D[] results)
{
int num = coords.Length;
results = new Vector2D[num];
for (int i = 0; i < num; i++)
{
double num2 = 1.0 / (coords[i].X * transform.M14 + coords[i].Y * transform.M24 + transform.M44);
results[i].X = (coords[i].X * transform.M11 + coords[i].Y * transform.M21 + transform.M41) * num2;
results[i].Y = (coords[i].X * transform.M12 + coords[i].Y * transform.M22 + transform.M42) * num2;
}
}
public static Vector2D TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, MatrixD transform)
{
Vec.Subtract(ref coord, ref BasePoint, out coord);
TransformCoordinate(ref coord, ref transform, out var result);
Vec.Add(ref result, ref BasePoint, out result);
return result;
}
public static Vector2D TransformCoordinateBP(ref Vector2D coord, ref Vector2D BasePoint, ref MatrixD transform)
{
Vec.Subtract(ref coord, ref BasePoint, out var r);
TransformCoordinate(ref r, ref transform, out var result);
Vec.Add(ref result, ref BasePoint, out result);
return result;
}
public static void TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, MatrixD transform, out Vector2D result)
{
Vec.Subtract(ref coord, ref BasePoint, out coord);
TransformCoordinate(ref coord, ref transform, out result);
Vec.Add(ref result, ref BasePoint, out result);
}
public static void TransformCoordinateBP(ref Vector2D coord, ref Vector2D BasePoint, ref MatrixD transform, out Vector2D result)
{
Vec.Subtract(ref coord, ref BasePoint, out var r);
TransformCoordinate(ref r, ref transform, out result);
Vec.Add(ref result, ref BasePoint, out result);
}
}

View File

@@ -0,0 +1,587 @@
using System;
using System.Globalization;
namespace _2DGAMELIB;
[Serializable]
public struct MatrixD
{
public double M11;
public double M12;
public double M13;
public double M14;
public double M21;
public double M22;
public double M23;
public double M24;
public double M31;
public double M32;
public double M33;
public double M34;
public double M41;
public double M42;
public double M43;
public double M44;
public double this[int row, int col]
{
get
{
switch (row)
{
case 0:
switch (col)
{
case 0:
return M11;
case 1:
return M12;
case 2:
return M13;
case 3:
return M14;
default:
error(row, col);
return 0.0;
}
case 1:
switch (col)
{
case 0:
return M21;
case 1:
return M22;
case 2:
return M23;
case 3:
return M24;
default:
error(row, col);
return 0.0;
}
case 2:
switch (col)
{
case 0:
return M31;
case 1:
return M32;
case 2:
return M33;
case 3:
return M34;
default:
error(row, col);
return 0.0;
}
case 3:
switch (col)
{
case 0:
return M41;
case 1:
return M42;
case 2:
return M43;
case 3:
return M44;
default:
error(row, col);
return 0.0;
}
default:
error(row, col);
return 0.0;
}
}
set
{
switch (row)
{
case 0:
switch (col)
{
case 0:
M11 = value;
break;
case 1:
M12 = value;
break;
case 2:
M13 = value;
break;
case 3:
M14 = value;
break;
default:
error(row, col);
break;
}
break;
case 1:
switch (col)
{
case 0:
M21 = value;
break;
case 1:
M22 = value;
break;
case 2:
M23 = value;
break;
case 3:
M24 = value;
break;
default:
error(row, col);
break;
}
break;
case 2:
switch (col)
{
case 0:
M31 = value;
break;
case 1:
M32 = value;
break;
case 2:
M33 = value;
break;
case 3:
M34 = value;
break;
default:
error(row, col);
break;
}
break;
case 3:
switch (col)
{
case 0:
M41 = value;
break;
case 1:
M42 = value;
break;
case 2:
M43 = value;
break;
case 3:
M44 = value;
break;
default:
error(row, col);
break;
}
break;
default:
error(row, col);
break;
}
}
}
public static MatrixD Identity
{
get
{
MatrixD result = default(MatrixD);
result.M11 = 1.0;
result.M22 = 1.0;
result.M33 = 1.0;
result.M44 = 1.0;
return result;
}
}
public bool IsIdentity
{
get
{
if (M11 != 1.0 || M22 != 1.0 || M33 != 1.0 || M44 != 1.0)
{
return false;
}
if (M12 != 0.0 || M13 != 0.0 || M14 != 0.0 || M21 != 0.0 || M23 != 0.0 || M24 != 0.0 || M31 != 0.0 || M32 != 0.0 || M34 != 0.0 || M41 != 0.0 || M42 != 0.0 || M43 != 0.0)
{
return false;
}
return true;
}
}
public MatrixD(double M11, double M12, double M13, double M14, double M21, double M22, double M23, double M24, double M31, double M32, double M33, double M34, double M41, double M42, double M43, double M44)
{
this.M11 = M11;
this.M12 = M12;
this.M13 = M13;
this.M14 = M14;
this.M21 = M21;
this.M22 = M22;
this.M23 = M23;
this.M24 = M24;
this.M31 = M31;
this.M32 = M32;
this.M33 = M33;
this.M34 = M34;
this.M41 = M41;
this.M42 = M42;
this.M43 = M43;
this.M44 = M44;
}
private void error(int row, int col)
{
if (row < 0 || row > 3)
{
throw new ArgumentOutOfRangeException("row", "Rows and columns for matrices run from 0 to 3, inclusive.");
}
if (col < 0 || col > 3)
{
throw new ArgumentOutOfRangeException("col", "Rows and columns for matrices run from 0 to 3, inclusive.");
}
}
public Vector4D GetRow(int row)
{
return new Vector4D(this[row, 0], this[row, 1], this[row, 2], this[row, 3]);
}
public void SetRow(int row, Vector4D value)
{
this[row, 0] = value.X;
this[row, 1] = value.Y;
this[row, 2] = value.Z;
this[row, 3] = value.W;
}
public void SetRow(int row, ref Vector4D value)
{
this[row, 0] = value.X;
this[row, 1] = value.Y;
this[row, 2] = value.Z;
this[row, 3] = value.W;
}
public Vector4D GetCol(int column)
{
return new Vector4D(this[0, column], this[1, column], this[2, column], this[3, column]);
}
public void SetCol(int column, Vector4D value)
{
this[0, column] = value.X;
this[1, column] = value.Y;
this[2, column] = value.Z;
this[3, column] = value.W;
}
public void SetCol(int column, ref Vector4D value)
{
this[0, column] = value.X;
this[1, column] = value.Y;
this[2, column] = value.Z;
this[3, column] = value.W;
}
public double[] ToArray()
{
return new double[16]
{
M11, M12, M13, M14, M21, M22, M23, M24, M31, M32,
M33, M34, M41, M42, M43, M44
};
}
public void Invert()
{
MatrixD matDIdentity = Dat.MatDIdentity;
for (int i = 0; i < 4; i++)
{
double num = 1.0 / this[i, i];
for (int j = 0; j < 4; j++)
{
this[i, j] *= num;
matDIdentity[i, j] *= num;
}
for (int j = 0; j < 4; j++)
{
if (i != j)
{
num = this[j, i];
for (int k = 0; k < 4; k++)
{
this[j, k] -= this[i, k] * num;
matDIdentity[j, k] -= matDIdentity[i, k] * num;
}
}
}
}
this = matDIdentity;
}
public double Determinant()
{
double num = M33 * M44 - M34 * M43;
double num2 = M32 * M44 - M34 * M42;
double num3 = M32 * M43 - M33 * M42;
double num4 = M31 * M44 - M34 * M41;
double num5 = M31 * M43 - M33 * M41;
double num6 = M31 * M42 - M32 * M41;
return M11 * (M22 * num - M23 * num2 + M24 * num3) - M12 * (M21 * num - M23 * num4 + M24 * num5) + M13 * (M21 * num2 - M22 * num4 + M24 * num6) - M14 * (M21 * num3 - M22 * num5 + M23 * num6);
}
public static MatrixD operator +(MatrixD left, MatrixD right)
{
MatrixD result = default(MatrixD);
result.M11 = left.M11 + right.M11;
result.M12 = left.M12 + right.M12;
result.M13 = left.M13 + right.M13;
result.M14 = left.M14 + right.M14;
result.M21 = left.M21 + right.M21;
result.M22 = left.M22 + right.M22;
result.M23 = left.M23 + right.M23;
result.M24 = left.M24 + right.M24;
result.M31 = left.M31 + right.M31;
result.M32 = left.M32 + right.M32;
result.M33 = left.M33 + right.M33;
result.M34 = left.M34 + right.M34;
result.M41 = left.M41 + right.M41;
result.M42 = left.M42 + right.M42;
result.M43 = left.M43 + right.M43;
result.M44 = left.M44 + right.M44;
return result;
}
public static MatrixD operator -(MatrixD left, MatrixD right)
{
MatrixD result = default(MatrixD);
result.M11 = left.M11 - right.M11;
result.M12 = left.M12 - right.M12;
result.M13 = left.M13 - right.M13;
result.M14 = left.M14 - right.M14;
result.M21 = left.M21 - right.M21;
result.M22 = left.M22 - right.M22;
result.M23 = left.M23 - right.M23;
result.M24 = left.M24 - right.M24;
result.M31 = left.M31 - right.M31;
result.M32 = left.M32 - right.M32;
result.M33 = left.M33 - right.M33;
result.M34 = left.M34 - right.M34;
result.M41 = left.M41 - right.M41;
result.M42 = left.M42 - right.M42;
result.M43 = left.M43 - right.M43;
result.M44 = left.M44 - right.M44;
return result;
}
public static MatrixD operator -(MatrixD matrix)
{
MatrixD result = default(MatrixD);
result.M11 = 0.0 - matrix.M11;
result.M12 = 0.0 - matrix.M12;
result.M13 = 0.0 - matrix.M13;
result.M14 = 0.0 - matrix.M14;
result.M21 = 0.0 - matrix.M21;
result.M22 = 0.0 - matrix.M22;
result.M23 = 0.0 - matrix.M23;
result.M24 = 0.0 - matrix.M24;
result.M31 = 0.0 - matrix.M31;
result.M32 = 0.0 - matrix.M32;
result.M33 = 0.0 - matrix.M33;
result.M34 = 0.0 - matrix.M34;
result.M41 = 0.0 - matrix.M41;
result.M42 = 0.0 - matrix.M42;
result.M43 = 0.0 - matrix.M43;
result.M44 = 0.0 - matrix.M44;
return result;
}
public static MatrixD operator *(MatrixD left, MatrixD right)
{
MatrixD result = default(MatrixD);
result.M11 = left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31 + left.M14 * right.M41;
result.M12 = left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32 + left.M14 * right.M42;
result.M13 = left.M11 * right.M13 + left.M12 * right.M23 + left.M13 * right.M33 + left.M14 * right.M43;
result.M14 = left.M11 * right.M14 + left.M12 * right.M24 + left.M13 * right.M34 + left.M14 * right.M44;
result.M21 = left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31 + left.M24 * right.M41;
result.M22 = left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32 + left.M24 * right.M42;
result.M23 = left.M21 * right.M13 + left.M22 * right.M23 + left.M23 * right.M33 + left.M24 * right.M43;
result.M24 = left.M21 * right.M14 + left.M22 * right.M24 + left.M23 * right.M34 + left.M24 * right.M44;
result.M31 = left.M31 * right.M11 + left.M32 * right.M21 + left.M33 * right.M31 + left.M34 * right.M41;
result.M32 = left.M31 * right.M12 + left.M32 * right.M22 + left.M33 * right.M32 + left.M34 * right.M42;
result.M33 = left.M31 * right.M13 + left.M32 * right.M23 + left.M33 * right.M33 + left.M34 * right.M43;
result.M34 = left.M31 * right.M14 + left.M32 * right.M24 + left.M33 * right.M34 + left.M34 * right.M44;
result.M41 = left.M41 * right.M11 + left.M42 * right.M21 + left.M43 * right.M31 + left.M44 * right.M41;
result.M42 = left.M41 * right.M12 + left.M42 * right.M22 + left.M43 * right.M32 + left.M44 * right.M42;
result.M43 = left.M41 * right.M13 + left.M42 * right.M23 + left.M43 * right.M33 + left.M44 * right.M43;
result.M44 = left.M41 * right.M14 + left.M42 * right.M24 + left.M43 * right.M34 + left.M44 * right.M44;
return result;
}
public static MatrixD operator *(MatrixD left, double right)
{
MatrixD result = default(MatrixD);
result.M11 = left.M11 * right;
result.M12 = left.M12 * right;
result.M13 = left.M13 * right;
result.M14 = left.M14 * right;
result.M21 = left.M21 * right;
result.M22 = left.M22 * right;
result.M23 = left.M23 * right;
result.M24 = left.M24 * right;
result.M31 = left.M31 * right;
result.M32 = left.M32 * right;
result.M33 = left.M33 * right;
result.M34 = left.M34 * right;
result.M41 = left.M41 * right;
result.M42 = left.M42 * right;
result.M43 = left.M43 * right;
result.M44 = left.M44 * right;
return result;
}
public static MatrixD operator *(double right, MatrixD left)
{
MatrixD result = default(MatrixD);
result.M11 = left.M11 * right;
result.M12 = left.M12 * right;
result.M13 = left.M13 * right;
result.M14 = left.M14 * right;
result.M21 = left.M21 * right;
result.M22 = left.M22 * right;
result.M23 = left.M23 * right;
result.M24 = left.M24 * right;
result.M31 = left.M31 * right;
result.M32 = left.M32 * right;
result.M33 = left.M33 * right;
result.M34 = left.M34 * right;
result.M41 = left.M41 * right;
result.M42 = left.M42 * right;
result.M43 = left.M43 * right;
result.M44 = left.M44 * right;
return result;
}
public static MatrixD operator /(MatrixD left, MatrixD right)
{
MatrixD result = default(MatrixD);
result.M11 = left.M11 / right.M11;
result.M12 = left.M12 / right.M12;
result.M13 = left.M13 / right.M13;
result.M14 = left.M14 / right.M14;
result.M21 = left.M21 / right.M21;
result.M22 = left.M22 / right.M22;
result.M23 = left.M23 / right.M23;
result.M24 = left.M24 / right.M24;
result.M31 = left.M31 / right.M31;
result.M32 = left.M32 / right.M32;
result.M33 = left.M33 / right.M33;
result.M34 = left.M34 / right.M34;
result.M41 = left.M41 / right.M41;
result.M42 = left.M42 / right.M42;
result.M43 = left.M43 / right.M43;
result.M44 = left.M44 / right.M44;
return result;
}
public static MatrixD operator /(MatrixD left, double right)
{
MatrixD result = default(MatrixD);
result.M11 = left.M11 / right;
result.M12 = left.M12 / right;
result.M13 = left.M13 / right;
result.M14 = left.M14 / right;
result.M21 = left.M21 / right;
result.M22 = left.M22 / right;
result.M23 = left.M23 / right;
result.M24 = left.M24 / right;
result.M31 = left.M31 / right;
result.M32 = left.M32 / right;
result.M33 = left.M33 / right;
result.M34 = left.M34 / right;
result.M41 = left.M41 / right;
result.M42 = left.M42 / right;
result.M43 = left.M43 / right;
result.M44 = left.M44 / right;
return result;
}
public static bool operator ==(MatrixD left, MatrixD right)
{
if (left.M11 == right.M11 && left.M12 == right.M12 && left.M13 == right.M13 && left.M14 == right.M14 && left.M21 == right.M21 && left.M22 == right.M22 && left.M23 == right.M23 && left.M24 == right.M24 && left.M31 == right.M31 && left.M32 == right.M32 && left.M33 == right.M33 && left.M34 == right.M34 && left.M41 == right.M41 && left.M42 == right.M42 && left.M43 == right.M43)
{
return left.M44 == right.M44;
}
return false;
}
public static bool operator !=(MatrixD left, MatrixD right)
{
if (left.M11 == right.M11 && left.M12 == right.M12 && left.M13 == right.M13 && left.M14 == right.M14 && left.M21 == right.M21 && left.M22 == right.M22 && left.M23 == right.M23 && left.M24 == right.M24 && left.M31 == right.M31 && left.M32 == right.M32 && left.M33 == right.M33 && left.M34 == right.M34 && left.M41 == right.M41 && left.M42 == right.M42 && left.M43 == right.M43)
{
return left.M44 != right.M44;
}
return true;
}
public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "[M11:{0} M12:{1} M13:{2} M14:{3}] [M21:{4} M22:{5} M23:{6} M24:{7}] [M31:{8} M32:{9} M33:{10} M34:{11}] [M41:{12} M42:{13} M43:{14} M44:{15}]", M11.ToString(CultureInfo.CurrentCulture), M12.ToString(CultureInfo.CurrentCulture), M13.ToString(CultureInfo.CurrentCulture), M14.ToString(CultureInfo.CurrentCulture), M21.ToString(CultureInfo.CurrentCulture), M22.ToString(CultureInfo.CurrentCulture), M23.ToString(CultureInfo.CurrentCulture), M24.ToString(CultureInfo.CurrentCulture), M31.ToString(CultureInfo.CurrentCulture), M32.ToString(CultureInfo.CurrentCulture), M33.ToString(CultureInfo.CurrentCulture), M34.ToString(CultureInfo.CurrentCulture), M41.ToString(CultureInfo.CurrentCulture), M42.ToString(CultureInfo.CurrentCulture), M43.ToString(CultureInfo.CurrentCulture), M44.ToString(CultureInfo.CurrentCulture));
}
public override int GetHashCode()
{
return M11.GetHashCode() + M12.GetHashCode() + M13.GetHashCode() + M14.GetHashCode() + M21.GetHashCode() + M22.GetHashCode() + M23.GetHashCode() + M24.GetHashCode() + M31.GetHashCode() + M32.GetHashCode() + M33.GetHashCode() + M34.GetHashCode() + M41.GetHashCode() + M42.GetHashCode() + M43.GetHashCode() + M44.GetHashCode();
}
public override bool Equals(object value)
{
if (value == null)
{
return false;
}
if (value.GetType() != GetType())
{
return false;
}
return Equals((MatrixD)value);
}
public bool Equals(MatrixD value)
{
if (M11 == value.M11 && M12 == value.M12 && M13 == value.M13 && M14 == value.M14 && M21 == value.M21 && M22 == value.M22 && M23 == value.M23 && M24 == value.M24 && M31 == value.M31 && M32 == value.M32 && M33 == value.M33 && M34 == value.M34 && M41 == value.M41 && M42 == value.M42 && M43 == value.M43)
{
return M44 == value.M44;
}
return false;
}
public bool Equals(ref MatrixD value)
{
if (M11 == value.M11 && M12 == value.M12 && M13 == value.M13 && M14 == value.M14 && M21 == value.M21 && M22 == value.M22 && M23 == value.M23 && M24 == value.M24 && M31 == value.M31 && M32 == value.M32 && M33 == value.M33 && M34 == value.M34 && M41 == value.M41 && M42 == value.M42 && M43 == value.M43)
{
return M44 == value.M44;
}
return false;
}
}

479
2DGAMELIB/_2DGAMELIB/Med.cs Normal file
View File

@@ -0,0 +1,479 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Windows.Input;
namespace _2DGAMELIB;
public class Med
{
public static object obj;
private WPFImage baseControl;
public double Unit = 1762.4;
public Rect Base = new Rect(4.0, 3.0, 0.4);
public double DisQuality = 1.0;
public double HitAccuracy = 0.5;
public Bitmap BD;
public Graphics GD;
public Bitmap BH;
public Graphics GH;
private Color ClearColor = Color.Transparent;
public bool Drive = true;
private Size BaseSize = Size.Empty;
private double resMag = 1.0;
private Vector2D resVector = Dat.Vec2DZero;
private Sce Sce;
private string mode;
public string Modeb;
private Dictionary<string, Module> Modes;
private Func<Med, Dictionary<string, Module>> GetModes;
private int WidthM;
private int HeightM;
public static double FPS;
public FPS FPSF = new FPS(FPS);
private bool cur = true;
public HashSet<Color> HitColors = new HashSet<Color>
{
Color.Transparent,
Color.Black
};
private const int LOGPIXELSX = 88;
private const int LOGPIXELSY = 90;
public static double dpiX;
public static double dpiY;
public static double DpiX;
public static double DpiY;
public string UITitle;
public bool ShowFPS;
public Control BaseControlC => baseControl;
public WPFImage BaseControl => baseControl;
public double ResMag => resMag;
public Vector2D ResVector => resVector;
public string Mode
{
get
{
return mode;
}
set
{
Modes[mode].Up(MouseButtons.None, Dat.Vec2DZero, Color.Empty);
Modes[mode].Move(MouseButtons.None, Dat.Vec2DZero, Color.Empty);
Modeb = mode;
mode = value;
Modes[mode].Move(MouseButtons.None, Dat.Vec2DZero, Color.Empty);
Modes[mode].Setting();
}
}
public Vector2D CursorPosition => ToBasePosition(baseControl.PointToClient(System.Windows.Forms.Cursor.Position));
public Med()
{
Point dpi = GetDpi();
dpiX = dpi.X;
dpiY = dpi.Y;
DpiX = 96.0 / dpiX;
DpiY = 96.0 / dpiY;
}
public void FadeIn(double Rate)
{
Sce.TransformAlpha(GD, Rate);
}
public void FadeOut(double Rate)
{
Sce.TransD(GD, Rate);
}
public void DrawStart(Are Are)
{
Sce.DrawStart(Are);
}
public void DrawEnd(Are Are)
{
Sce.DrawEnd(Are);
}
public void ClearSta(Color ClearColor)
{
Sce.ClearStart(ref ClearColor);
}
public void InitializeModes(string Mode, Func<Med, Dictionary<string, Module>> GetModes)
{
mode = Mode;
this.GetModes = GetModes;
}
public Size Setting(WPFImage BaseControl)
{
baseControl = BaseControl;
BaseSize = new Size((int)(Base.LocalWidth * Unit), (int)(Base.LocalHeight * Unit));
BD = new Bitmap(BaseSize.Width, BaseSize.Height);
GD = Graphics.FromImage(BD);
GD.InterpolationMode = InterpolationMode.HighQualityBilinear;
BH = new Bitmap((int)((double)BaseSize.Width * HitAccuracy), (int)((double)BaseSize.Height * HitAccuracy));
GH = Graphics.FromImage(BH);
GH.InterpolationMode = InterpolationMode.Bilinear;
WidthM = BH.Width - 1;
HeightM = BH.Height - 1;
Clear();
Sce = new Sce(BaseSize.Width, BaseSize.Height);
Modes = GetModes(this);
BaseControl.Image.MouseDown += delegate(object s, MouseButtonEventArgs e)
{
Point Position5 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
MouseButtons arg2 = MouseButtons.None;
switch (e.ChangedButton)
{
case MouseButton.Left:
arg2 = MouseButtons.Left;
break;
case MouseButton.Middle:
arg2 = MouseButtons.Middle;
break;
case MouseButton.Right:
arg2 = MouseButtons.Right;
break;
case MouseButton.XButton1:
arg2 = MouseButtons.XButton1;
break;
case MouseButton.XButton2:
arg2 = MouseButtons.XButton2;
break;
}
Modes[mode].Down(arg2, ToBasePosition(Position5), GetHitColor(ref Position5));
};
BaseControl.Image.MouseUp += delegate(object s, MouseButtonEventArgs e)
{
Point Position4 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
MouseButtons arg = MouseButtons.None;
switch (e.ChangedButton)
{
case MouseButton.Left:
arg = MouseButtons.Left;
break;
case MouseButton.Middle:
arg = MouseButtons.Middle;
break;
case MouseButton.Right:
arg = MouseButtons.Right;
break;
case MouseButton.XButton1:
arg = MouseButtons.XButton1;
break;
case MouseButton.XButton2:
arg = MouseButtons.XButton2;
break;
}
Modes[mode].Up(arg, ToBasePosition(Position4), GetHitColor(ref Position4));
};
BaseControl.Image.MouseMove += delegate
{
Point Position3 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
Modes[mode].Move(Control.MouseButtons, ToBasePosition(Position3), GetHitColor(ref Position3));
};
BaseControl.Image.MouseLeave += delegate
{
Point Position2 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
Modes[mode].Leave(Control.MouseButtons, ToBasePosition(Position2), GetHitColor(ref Position2));
};
BaseControl.Image.MouseWheel += delegate(object s, MouseWheelEventArgs e)
{
Point Position = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
Modes[mode].Wheel(Control.MouseButtons, ToBasePosition(Position), e.Delta, GetHitColor(ref Position));
};
((Control)BaseControl).Resize += delegate
{
if (BaseSize.Width >= BaseSize.Height)
{
double num = (double)BaseSize.Width / (double)BaseSize.Height;
if ((double)baseControl.ClientSize.Width / (double)baseControl.ClientSize.Height <= num)
{
resMag = (double)BaseSize.Width / (double)baseControl.ClientSize.Width;
resVector.X = 0.0;
resVector.Y = ((double)baseControl.ClientSize.Height - (double)BaseSize.Height / resMag) * 0.5;
}
else
{
resMag = (double)BaseSize.Height / (double)baseControl.ClientSize.Height;
resVector.X = ((double)baseControl.ClientSize.Width - (double)BaseSize.Width / resMag) * 0.5;
resVector.Y = 0.0;
}
}
else
{
double num2 = (double)BaseSize.Height / (double)BaseSize.Width;
if ((double)baseControl.ClientSize.Height / (double)baseControl.ClientSize.Width <= num2)
{
resMag = (double)BaseSize.Height / (double)baseControl.ClientSize.Height;
resVector.X = ((double)baseControl.ClientSize.Width - (double)BaseSize.Width / resMag) * 0.5;
resVector.Y = 0.0;
}
else
{
resMag = (double)BaseSize.Width / (double)baseControl.ClientSize.Width;
resVector.X = 0.0;
resVector.Y = ((double)baseControl.ClientSize.Height - (double)BaseSize.Height / resMag) * 0.5;
}
}
};
return BaseSize;
}
public Vector2D ToBasePosition(Point Position)
{
return new Vector2D(((double)Position.X - resVector.X) / Unit * resMag, ((double)Position.Y - resVector.Y) / Unit * resMag);
}
public Point FromBasePosition(Vector2D Position)
{
return new Point((int)(Position.X / resMag * Unit + resVector.X), (int)(Position.Y / resMag * Unit + resVector.Y));
}
public Color GetHitColor(Point Position)
{
double num = HitAccuracy * resMag;
Point point = ((Position.ToVector2D() - resVector) * num).ToPoint();
if (point.X < 0)
{
point.X = 0;
}
if (point.Y < 0)
{
point.Y = 0;
}
if (point.X > WidthM)
{
point.X = WidthM;
}
if (point.Y > HeightM)
{
point.Y = HeightM;
}
return BH.GetPixel(point.X, point.Y);
}
public Color GetHitColor(ref Point Position)
{
double num = HitAccuracy * resMag;
Point point = ((Position.ToVector2D() - resVector) * num).ToPoint();
if (point.X < 0)
{
point.X = 0;
}
if (point.Y < 0)
{
point.Y = 0;
}
if (point.X > WidthM)
{
point.X = WidthM;
}
if (point.Y > HeightM)
{
point.Y = HeightM;
}
return BH.GetPixel(point.X, point.Y);
}
public void Drawing()
{
baseControl.BitmapSetting(BD);
Modes[mode].Setting();
double FPS = 0.0;
Action action = delegate
{
FPS = FPSF.Value;
if (FPS > 1.0)
{
Modes[mode].Draw(FPSF);
}
baseControl.SetBitmap(BD);
};
while (Drive)
{
long frame_start = FPSF.sw.ElapsedMilliseconds;
FPSF.FPSFixed(action);
long frame_end = FPSF.sw.ElapsedMilliseconds;
if (ShowFPS)
{
baseControl.Parent.Text = UITitle + " - FPS: " + System.Math.Round(FPSF.Value, 2);
}
Application.DoEvents();
long frame_update_end = FPSF.sw.ElapsedMilliseconds;
//System.Diagnostics.Debug.WriteLine("frame time: {0:D}", frame_end - frame_start);
//System.Diagnostics.Debug.WriteLine("event time: {0:D}", frame_update_end - frame_end);
}
}
public void Clear()
{
GD.Clear(ClearColor);
GH.Clear(ClearColor);
}
public void Draw(Are Are)
{
Are.Draw(GD, GH);
}
public void CursorHide()
{
if (cur)
{
System.Windows.Forms.Cursor.Hide();
cur = false;
}
}
public void CursorShow()
{
if (!cur)
{
System.Windows.Forms.Cursor.Show();
cur = true;
}
}
public void InvokeL(Action a)
{
baseControl.Invoke(a);
}
public Color GetUniqueColor()
{
Oth.GetRandomColor(out var ret);
while (HitColors.Contains(ret))
{
Oth.GetRandomColor(out ret);
}
HitColors.Add(ret);
return ret;
}
public void GetUniqueColor(out Color c)
{
Oth.GetRandomColor(out c);
while (HitColors.Contains(c))
{
Oth.GetRandomColor(out c);
}
HitColors.Add(c);
}
public void SetUniqueColor(IEnumerable<Par> ps)
{
foreach (Par p in ps)
{
p.HitColor = GetUniqueColor();
}
}
public void RemUniqueColor(Color Color)
{
HitColors.Remove(Color);
}
public void RemUniqueColor(IEnumerable<Par> ps)
{
foreach (Par p in ps)
{
HitColors.Remove(p.HitColor);
}
}
public void Dispose()
{
Drive = false;
foreach (Module value in Modes.Values)
{
value.Dispose();
}
BD.Dispose();
GD.Dispose();
BH.Dispose();
GH.Dispose();
Sce.Dispose();
}
[DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
[DllImport("user32.dll")]
private static extern IntPtr GetWindowDC(IntPtr hwnd);
[DllImport("gdi32.dll")]
private static extern int GetDeviceCaps(IntPtr hdc, int index);
[DllImport("user32.dll")]
private static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
public static Point GetDpi()
{
SetProcessDPIAware();
IntPtr windowDC = GetWindowDC(IntPtr.Zero);
Point result = new Point(GetDeviceCaps(windowDC, 88), GetDeviceCaps(windowDC, 90));
ReleaseDC(IntPtr.Zero, windowDC);
return result;
}
static Med()
{
obj = new object();
FPS = 60.0;
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace _2DGAMELIB;
public class Module
{
public Action<MouseButtons, Vector2D, Color> Down = delegate
{
};
public Action<MouseButtons, Vector2D, Color> Up = delegate
{
};
public Action<MouseButtons, Vector2D, Color> Move = delegate
{
};
public Action<MouseButtons, Vector2D, Color> Leave = delegate
{
};
public Action<MouseButtons, Vector2D, int, Color> Wheel = delegate
{
};
public Action<FPS> Draw = delegate
{
};
public Action Dispose = delegate
{
};
public Action Setting = delegate
{
};
}

View File

@@ -0,0 +1,76 @@
using System;
namespace _2DGAMELIB;
public class Mot : MotV
{
public Action<Mot> Staing;
public Action<Mot> Runing;
public Action<Mot> Reaing;
public Action<Mot> Rouing;
public Action<Mot> Ending;
private bool run;
private bool rou;
public bool Run => run;
public Mot(double Min, double Max)
: base(Min, Max)
{
}
public new void GetValue(FPS FPS)
{
if (!run)
{
return;
}
base.GetValue(FPS);
if (Runing != null)
{
Runing(this);
}
if (Value == min)
{
if (rou && Rouing != null)
{
Rouing(this);
}
rou = false;
}
else if (Value == max)
{
if (Reaing != null)
{
Reaing(this);
}
rou = true;
}
}
public void Start()
{
if (Staing != null)
{
Staing(this);
}
run = true;
}
public void End()
{
run = false;
if (Ending != null)
{
Ending(this);
}
ResetValue();
rou = false;
}
}

View File

@@ -0,0 +1,108 @@
namespace _2DGAMELIB;
public class MotV
{
public double Value;
protected double min = -1.0;
protected double max = 1.0;
private double Frame;
private double FrameHalf;
private double MinFrameHalf;
public double BaseSpeed = 1.0;
public double GotoSpeed = 1.0;
public double RetuSpeed = 1.0;
public double Interval;
private long st;
public double LowestIncrease = 1.0;
private int s = 1;
private double d;
private double m;
public double Min
{
get
{
return min;
}
set
{
min = value;
SetFrame();
}
}
public double Max
{
get
{
return max;
}
set
{
max = value;
SetFrame();
}
}
public MotV(double Min, double Max)
{
min = Min;
max = Max;
SetFrame();
ResetValue();
}
private void SetFrame()
{
Frame = max - min;
FrameHalf = Frame * 0.5;
MinFrameHalf = Min + FrameHalf;
}
public void ResetValue()
{
Value = min;
}
private void Count(FPS FPS)
{
m = Frame / FPS.Value;
Value += (m * d + m * LowestIncrease) * BaseSpeed * ((s > 0) ? GotoSpeed : RetuSpeed) * (double)s;
}
public void GetValue(FPS FPS)
{
if (!((double)(FPS.sw.ElapsedMilliseconds - st) < Interval) && FPS.Value > 0.0)
{
d = (MinFrameHalf - Value) / FrameHalf;
d *= d.Sign();
d = d.Inverse();
Count(FPS);
if (Value >= max)
{
Value = max;
s = -s;
}
else if (Value <= min)
{
Value = min;
s = -s;
st = FPS.sw.ElapsedMilliseconds;
}
}
}
}

View File

@@ -0,0 +1,43 @@
using System.Collections.Generic;
namespace _2DGAMELIB;
public class Mots
{
public Dictionary<string, Mot> ms;
public Mot this[string Name]
{
get
{
return ms[Name];
}
set
{
ms[Name] = value;
}
}
public Mots()
{
ms = new Dictionary<string, Mot>();
}
public void Add(string Name, Mot Mot)
{
ms.Add(Name, Mot);
}
public void Rem(string Name)
{
ms.Remove(Name);
}
public void Drive(FPS FPS)
{
foreach (Mot value in ms.Values)
{
value.GetValue(FPS);
}
}
}

View File

@@ -0,0 +1,221 @@
using System;
namespace _2DGAMELIB;
public class MyRandom : Random
{
protected uint x;
protected uint y;
protected uint z;
protected uint w;
private const double d_4294967296 = 2.3283064365386963E-10;
private const double d_9007199254740992 = 1.1102230246251565E-16;
protected uint InitMtSub(uint s, uint i)
{
return 1812433253 * (s ^ (s >> 30)) + i + 1;
}
public void Initialize(uint s)
{
x = InitMtSub(s, 0u);
y = InitMtSub(x, 1u);
z = InitMtSub(y, 2u);
w = InitMtSub(z, 3u);
}
public MyRandom(uint s)
{
Initialize(s);
}
public MyRandom()
: this(4357u)
{
}
public void Initialize(uint[] key)
{
uint num = (uint)key.Length;
uint[] array = new uint[4];
Initialize(1u);
array[0] = x;
array[1] = y;
array[2] = z;
array[3] = w;
uint s = w;
uint num2;
for (num2 = 0u; num2 < num; num2++)
{
array[num2 & 3] ^= (s = InitMtSub(s, key[num2] + num2));
}
uint num3 = 0u;
while (num3 < 3)
{
array[num2 & 3] ^= (s = InitMtSub(s, num3));
num3++;
num2++;
}
x = array[0];
y = array[1];
z = array[2];
w = array[3];
if (x == 0 && y == 0 && z == 0 && w == 0)
{
x = 1u;
}
}
public MyRandom(uint[] key)
{
Initialize(key);
}
public override int Next()
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
return (int)(0.5 * (double)(w = w ^ (w >> 19) ^ num ^ (num >> 8)));
}
public override int Next(int les)
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
return (int)((double)les * 2.3283064365386963E-10 * (double)(w = w ^ (w >> 19) ^ num ^ (num >> 8)));
}
public void Next(int les, out int o)
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
o = (int)((double)les * 2.3283064365386963E-10 * (double)(w = w ^ (w >> 19) ^ num ^ (num >> 8)));
}
public override int Next(int sta, int les)
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
return (int)((double)(les - sta) * 2.3283064365386963E-10 * (double)(w = w ^ (w >> 19) ^ num ^ (num >> 8))) + sta;
}
public int NextM(int max)
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
return (int)((double)((long)max + 1L) * 2.3283064365386963E-10 * (double)(w = w ^ (w >> 19) ^ num ^ (num >> 8)));
}
public int NextM(int min, int max)
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
return (int)((double)((long)(max - min) + 1L) * 2.3283064365386963E-10 * (double)(w = w ^ (w >> 19) ^ num ^ (num >> 8))) + min;
}
public override double NextDouble()
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
uint num2 = (w = w ^ (w >> 19) ^ num ^ (num >> 8)) >> 11;
num = x ^ (x << 11);
x = y;
y = z;
z = w;
return 1.1102230246251565E-16 * ((double)(w = w ^ (w >> 19) ^ num ^ (num >> 8)) * 2097152.0 + (double)num2);
}
public double NextDouble(double les)
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
uint num2 = (w = w ^ (w >> 19) ^ num ^ (num >> 8)) >> 11;
num = x ^ (x << 11);
x = y;
y = z;
z = w;
return les * 1.1102230246251565E-16 * ((double)(w = w ^ (w >> 19) ^ num ^ (num >> 8)) * 2097152.0 + (double)num2);
}
public double NextDouble(double sta, double les)
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
uint num2 = (w = w ^ (w >> 19) ^ num ^ (num >> 8)) >> 11;
num = x ^ (x << 11);
x = y;
y = z;
z = w;
return (les - sta) * 1.1102230246251565E-16 * ((double)(w = w ^ (w >> 19) ^ num ^ (num >> 8)) * 2097152.0 + (double)num2) + sta;
}
public bool NextBool()
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
return (w = w ^ (w >> 19) ^ num ^ (num >> 8)) % 2 == 0;
}
public int NextSign()
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
if ((w = w ^ (w >> 19) ^ num ^ (num >> 8)) % 2 != 0)
{
return -1;
}
return 1;
}
public double NextNorCos(double mu = 0.0, double sigma = 1.0)
{
uint num = x ^ (x << 11);
x = y;
y = z;
z = w;
uint num2 = (w = w ^ (w >> 19) ^ num ^ (num >> 8)) >> 11;
num = x ^ (x << 11);
x = y;
y = z;
z = w;
double d = 1.1102230246251565E-16 * ((double)(w = w ^ (w >> 19) ^ num ^ (num >> 8)) * 2097152.0 + (double)num2);
num = x ^ (x << 11);
x = y;
y = z;
z = w;
num2 = (w = w ^ (w >> 19) ^ num ^ (num >> 8)) >> 11;
num = x ^ (x << 11);
x = y;
y = z;
z = w;
double num3 = 1.1102230246251565E-16 * ((double)(w = w ^ (w >> 19) ^ num ^ (num >> 8)) * 2097152.0 + (double)num2);
return System.Math.Sqrt(-2.0 * System.Math.Log(d)) * System.Math.Cos(System.Math.PI * 2.0 * num3) * sigma + mu;
}
}

612
2DGAMELIB/_2DGAMELIB/Obj.cs Normal file
View File

@@ -0,0 +1,612 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.IO;
namespace _2DGAMELIB;
[Serializable]
public class Obj
{
public string Tag = "";
public OrderedDictionary<string, Difs> Difss = new OrderedDictionary<string, Difs>();
private Difs r;
private JointsD jsd;
public IEnumerable<string> Keys => Difss.Keys;
public IEnumerable<Difs> Values => Difss.Values;
public Difs this[string Name]
{
get
{
return Difss[Name];
}
set
{
Difss[Name] = value;
}
}
public Difs this[int Index]
{
get
{
return Difss[Index];
}
set
{
Difss[Index] = value;
}
}
public double PositionSize
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.PositionSize = value;
}
}
}
public Vector2D PositionVector
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.PositionVector = value;
}
}
}
public double AngleBase
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.AngleBase = value;
}
}
}
public double AngleCont
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.AngleCont = value;
}
}
}
public double SizeBase
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.SizeBase = value;
}
}
}
public double SizeCont
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.SizeCont = value;
}
}
}
public double SizeXBase
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.SizeXBase = value;
}
}
}
public double SizeXCont
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.SizeXCont = value;
}
}
}
public double SizeYBase
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.SizeYBase = value;
}
}
}
public double SizeYCont
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.SizeYCont = value;
}
}
}
public bool Dra
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.Dra = value;
}
}
}
public bool Hit
{
set
{
foreach (Difs value2 in Difss.Values)
{
value2.Hit = value;
}
}
}
public Difs JoinRoot => r;
public IEnumerable<Par> EnumAllPar()
{
foreach (Difs value in Difss.Values)
{
foreach (Par item in value.EnumAllPar())
{
yield return item;
}
}
}
public void SetDefault()
{
foreach (Difs value in Difss.Values)
{
value.SetDefault();
}
}
public Obj SetDefaultR()
{
foreach (Difs value in Difss.Values)
{
value.SetDefault();
}
return this;
}
public Obj()
{
}
public Obj(Obj Obj)
{
Copy(Obj);
}
private void Copy(Obj Obj)
{
Tag = Obj.Tag;
foreach (string key in Obj.Difss.Keys)
{
Difss.Add(key, new Difs(Obj.Difss[key]));
}
}
public void Add(string Name, Difs Difs)
{
Difss.Add(Name, Difs);
}
public void Add(Difs Difs)
{
Difss.Add(Difs.Tag, Difs);
}
public void Insert(int Index, string Name, Difs Difs)
{
Difss.Insert(Index, Name, Difs);
}
public void Remove(string Name)
{
Difss.Remove(Name);
}
public void Draw(Are Are)
{
foreach (Difs value in Difss.Values)
{
value.Draw(Are);
}
}
public void Draws(Are Are)
{
foreach (Difs value in Difss.Values)
{
value.Draws(Are);
}
}
public void Draw(AreM AreM)
{
foreach (Difs value in Difss.Values)
{
value.Draw(AreM);
}
}
public void Draws(AreM AreM)
{
foreach (Difs value in Difss.Values)
{
value.Draws(AreM);
}
}
private Difs GetJoinRootDifs()
{
Difs[] array = Difss.Values.ToArray();
if (array.Length <= 1)
{
return array.FirstOrDefault();
}
Par[] pa = EnumAllPar().ToArray();
Difs[] array2 = array;
Vector2D p;
foreach (Difs difs in array2)
{
if (difs.EnumJoinRoot.All(delegate(Par p0)
{
p = p0.Position;
return pa.All((Par p1) => p0 == p1 || p1.JP.All((Joi j) => !(p1.ToGlobal(j.Joint).DistanceSquared(p) <= Join.IdentityDistance)));
}))
{
return difs;
}
}
return array.First();
}
public void SetJoints()
{
Difs[] array = Difss.Values.ToArray();
Difs[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
array2[i].SetJoints();
}
r = GetJoinRootDifs();
if (r != null)
{
jsd = r.GetJointsD(array);
}
}
public void SetJoints(string Name)
{
Difs[] array = Difss.Values.ToArray();
Difs[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
array2[i].SetJoints();
}
r = Difss[Name];
if (r != null)
{
jsd = r.GetJointsD(array);
}
}
public void JoinP()
{
if (r != null)
{
r.JoinPA();
jsd.JoinP();
}
}
public void JoinPA()
{
if (r != null)
{
r.JoinPA();
jsd.JoinPA();
}
}
public void JoinPall()
{
if (r != null)
{
r.JoinPA();
jsd.JoinPall();
}
}
public void JoinPAall()
{
if (r != null)
{
r.JoinPA();
jsd.JoinPAall();
}
}
public HashSet<string> GetHitDifsTagsCur(ref Color HitColor)
{
HashSet<string> hashSet = new HashSet<string>();
foreach (Difs value in Values)
{
if (value.Current.IsHit(ref HitColor))
{
hashSet.Add(value.Tag);
}
}
return hashSet;
}
public List<Difs> GetHitDifssCur(ref Color HitColor)
{
List<Difs> list = new List<Difs>();
foreach (Difs value in Values)
{
if (value.Current.IsHit(ref HitColor))
{
list.Add(value);
}
}
return list;
}
public HashSet<string> GetHitParTagsCur(ref Color HitColor)
{
HashSet<string> hashSet = new HashSet<string>();
foreach (Difs value in Values)
{
foreach (string hitTag in value.Current.GetHitTags(ref HitColor))
{
hashSet.Add(hitTag);
}
}
return hashSet;
}
public List<Par> GetHitParsCur(ref Color HitColor)
{
List<Par> list = new List<Par>();
foreach (Difs value in Values)
{
list.AddRange(value.Current.GetHitPars(ref HitColor));
}
return list;
}
public bool IsHitCur(ref Color HitColor)
{
foreach (Difs value in Values)
{
if (value.IsHit(ref HitColor))
{
return true;
}
}
return false;
}
public HashSet<string> GetHitDifsTags(ref Color HitColor)
{
HashSet<string> hashSet = new HashSet<string>();
foreach (Difs value in Values)
{
if (value.IsHit(ref HitColor))
{
hashSet.Add(value.Tag);
}
}
return hashSet;
}
public List<Difs> GetHitDifss(ref Color HitColor)
{
List<Difs> list = new List<Difs>();
foreach (Difs value in Values)
{
if (value.IsHit(ref HitColor))
{
list.Add(value);
}
}
return list;
}
public HashSet<string> GetHitParTags(ref Color HitColor)
{
HashSet<string> hashSet = new HashSet<string>();
foreach (Difs value in Values)
{
foreach (string hitTag in value.GetHitTags(ref HitColor))
{
hashSet.Add(hitTag);
}
}
return hashSet;
}
public List<Par> GetHitPars(ref Color HitColor)
{
List<Par> list = new List<Par>();
foreach (Difs value in Values)
{
list.AddRange(value.GetHitPars(ref HitColor));
}
return list;
}
public bool IsHit(ref Color HitColor)
{
foreach (Difs value in Values)
{
if (value.IsHit(ref HitColor))
{
return true;
}
}
return false;
}
public void Symmetrization(string[] Names)
{
Difs[] array = Difss.Values.ToArray();
Difs[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
array2[i].SetJoints();
}
JointsD jointsD = GetJoinRootDifs().GetJointsD(array);
foreach (string name in Names)
{
symmetrization(name, array, jointsD);
}
}
public void Symmetrization(string Name, string[] Names)
{
Difs[] array = Difss.Values.ToArray();
Difs[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
array2[i].SetJoints();
}
JointsD jointsD = Difss[Name].GetJointsD(array);
foreach (string name in Names)
{
symmetrization(name, array, jointsD);
}
}
private void symmetrization(string Name, Difs[] da, JointsD jsdb)
{
Difs difs = Difss[Name];
JointsD jointsD = difs.GetJointsD(da);
Difs difs2 = new Difs(difs);
difs2.SetJoints();
difs2.ReverseX();
TagReplace(difs2);
SetPos(difs2, GetSymPos(difs, jsdb) - difs2.CurJoinRoot.Position);
foreach (Pars item in difs2.EnumAllPars())
{
difs2.JoinP(item);
}
Difss.Add(difs2.Tag, difs2);
string key = null;
foreach (JointD join in jointsD.Joins)
{
difs2 = new Difs(join.Difs1);
difs2.SetJoints();
difs2.ReverseX();
TagReplace(difs2);
if (join.Difs0.Tag.Contains("左"))
{
key = join.Difs0.Tag.Replace("左", "右");
}
else if (join.Difs0.Tag.Contains("右"))
{
key = join.Difs0.Tag.Replace("右", "左");
}
Par par = Difss[key].Current.GetPar(join.Path0);
SetPos(difs2, par.ToGlobal(par.JP[join.Index].Joint) - difs2.CurJoinRoot.Position);
foreach (Pars item2 in difs2.EnumAllPars())
{
difs2.JoinP(item2);
}
Difss.Add(difs2.Tag, difs2);
}
}
private void TagReplace(Difs ds)
{
if (ds.Tag.Contains("左"))
{
ds.Tag = ds.Tag.Replace("左", "右");
}
else if (ds.Tag.Contains("右"))
{
ds.Tag = ds.Tag.Replace("右", "左");
}
}
private Vector2D GetSymPos(Difs r, JointsD jsdb)
{
JointD jointD = null;
foreach (JointD join in jsdb.Joins)
{
if (join.Difs1 == r)
{
jointD = join;
break;
}
}
Vector2D position = r.CurJoinRoot.Position;
Par par = jointD.Difs0.Current.GetPar(jointD.Path0);
Joi joi = par.JP[jointD.Index];
foreach (Joi item in par.JP)
{
Vector2D result = par.ToGlobal(item.Joint);
if (item != joi && System.Math.Abs(result.Y - position.Y) < 1E-06)
{
return result;
}
}
return Dat.Vec2DZero;
}
private void SetPos(Difs ds, Vector2D v)
{
foreach (Par item in ds.EnumAllPar())
{
item.PositionBase += v;
}
}
public void Dispose()
{
foreach (Difs value in Difss.Values)
{
value.Dispose();
}
}
}

View File

@@ -0,0 +1,206 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace _2DGAMELIB;
[Serializable]
public class OrderedDictionary<T1, T2>
{
private List<T1> keys;
private Dictionary<T1, T2> values;
public T2 this[T1 Key]
{
get
{
return values[Key];
}
set
{
values[Key] = value;
}
}
public T2 this[int Index]
{
get
{
return values[keys[Index]];
}
set
{
values[keys[Index]] = value;
}
}
public IEnumerable<T1> Keys => keys;
public IEnumerable<T2> Values
{
get
{
foreach (T1 key in keys)
{
yield return values[key];
}
}
}
public int Count => keys.Count;
public OrderedDictionary()
{
keys = new List<T1>();
values = new Dictionary<T1, T2>();
}
public OrderedDictionary(int capacity)
{
keys = new List<T1>(capacity);
values = new Dictionary<T1, T2>(capacity);
}
public int IndexOf(T1 Key)
{
return keys.IndexOf(Key);
}
public int IndexOf(ref T1 Key)
{
return keys.IndexOf(Key);
}
public int IndexOf(T2 Value)
{
int num = 0;
foreach (T2 value in Values)
{
if (value.Equals(Value))
{
return num;
}
num++;
}
return -1;
}
public int IndexOf(ref T2 Value)
{
int num = 0;
foreach (T2 value in Values)
{
if (value.Equals(Value))
{
return num;
}
num++;
}
return -1;
}
public int LastIndexOf(T1 Key)
{
return keys.LastIndexOf(Key);
}
public int LastIndexOf(ref T1 Key)
{
return keys.LastIndexOf(Key);
}
public int LastIndexOf(T2 Value)
{
int num = keys.Count - 1;
foreach (T2 item in Values.Reverse())
{
if (item.Equals(Value))
{
return num;
}
num--;
}
return -1;
}
public int LastIndexOf(ref T2 Value)
{
int num = keys.Count - 1;
foreach (T2 item in Values.Reverse())
{
if (item.Equals(Value))
{
return num;
}
num--;
}
return -1;
}
public void Add(T1 Key, T2 Value)
{
keys.Add(Key);
values.Add(Key, Value);
}
public void Add(ref T1 Key, ref T2 Value)
{
keys.Add(Key);
values.Add(Key, Value);
}
public void Insert(int Index, T1 Key, T2 Value)
{
keys.Insert(Index, Key);
values.Add(Key, Value);
}
public void Insert(int Index, ref T1 Key, ref T2 Value)
{
keys.Insert(Index, Key);
values.Add(Key, Value);
}
public void Remove(T1 Key)
{
keys.Remove(Key);
values.Remove(Key);
}
public void Remove(ref T1 Key)
{
keys.Remove(Key);
values.Remove(Key);
}
public void Reverse()
{
keys.Reverse();
}
public void Reverse(int Index, int Count)
{
keys.Reverse(Index, Count);
}
public bool ContainsKey(T1 Key)
{
return values.ContainsKey(Key);
}
public bool ContainsKey(ref T1 Key)
{
return values.ContainsKey(Key);
}
public bool ContainsValue(T2 Value)
{
return values.ContainsValue(Value);
}
public bool ContainsValue(ref T2 Value)
{
return values.ContainsValue(Value);
}
}

366
2DGAMELIB/_2DGAMELIB/Oth.cs Normal file
View File

@@ -0,0 +1,366 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _2DGAMELIB;
public static class Oth
{
private static double s1;
private static double s0;
public static double GetDiagonalLength(this double Width, double Height)
{
return System.Math.Sqrt(Width * Width + Height * Height);
}
public static Color Reverse(this Color c)
{
return Color.FromArgb(c.A, 255 - c.R, 255 - c.G, 255 - c.B);
}
public static void GetRandomColor(out Color ret)
{
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)
{
return Color.FromArgb((c1.A + c2.A) / 2, (c1.R + c2.R) / 2, (c1.G + c2.G) / 2, (c1.B + c2.B) / 2);
}
public static void GetInter(ref Color c1, ref Color c2, out Color ret)
{
ret = Color.FromArgb((c1.A + c2.A) / 2, (c1.R + c2.R) / 2, (c1.G + c2.G) / 2, (c1.B + c2.B) / 2);
}
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)));
}
public static Color FuncHSV(this Color Color, Func<Hsv, Hsv> Func)
{
return Func(new Hsv(ref Color)).GetColor();
}
public static Rectangle GetRect(this Bitmap Bmp)
{
return new Rectangle(0, 0, Bmp.Width, Bmp.Height);
}
public static LinearGradientBrush GetLGB(double Unit, Vector2D[] MM, Color Color1, Color Color2)
{
return new LinearGradientBrush((MM[0] * Unit * s0).ToPointF(), (MM[1] * Unit * s1).ToPointF(), Color1, Color2)
{
GammaCorrection = true
};
}
public static LinearGradientBrush GetLGB(double Unit, Vector2D[] MM, ref Color Color1, ref Color Color2)
{
return new LinearGradientBrush((MM[0] * Unit * s0).ToPointF(), (MM[1] * Unit * s1).ToPointF(), Color1, Color2)
{
GammaCorrection = true
};
}
private static void GetMinMaxX(Par Par, ref double MinX, ref double MaxX)
{
foreach (Out item in Par.OP)
{
foreach (Vector2D p in item.ps)
{
Vector2D vector2D = Par.ToGlobal(p);
if (MinX > vector2D.X)
{
MinX = vector2D.X;
}
else if (MaxX < vector2D.X)
{
MaxX = vector2D.X;
}
}
}
}
private static void GetMinMaxY(Par Par, ref double MinY, ref double MaxY)
{
foreach (Out item in Par.OP)
{
foreach (Vector2D p in item.ps)
{
Vector2D vector2D = Par.ToGlobal(p);
if (MinY > vector2D.Y)
{
MinY = vector2D.Y;
}
else if (MaxY < vector2D.Y)
{
MaxY = vector2D.Y;
}
}
}
}
private static void GetMinMaxY(Par[] Pars, ref double MinY, ref double MaxY)
{
for (int i = 0; i < Pars.Length; i++)
{
GetMinMaxY(Pars[i], ref MinY, ref MaxY);
}
}
public static void GetMiX_MaX(this Par Par, out Vector2D[] MM)
{
Vector2D vector2D = Par.ToGlobal(Par.OP.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);
}
public static void GetMaX_MiX(this Par Par, out Vector2D[] MM)
{
Vector2D vector2D = Par.ToGlobal(Par.OP.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);
}
public static void GetMiY_MaY(this Par Par, out Vector2D[] MM)
{
Vector2D vector2D = Par.ToGlobal(Par.OP.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);
}
public static void GetMiY_MaY(this Par[] Pars, out Vector2D[] MM)
{
Par par = Pars.First();
Vector2D vector2D = par.ToGlobal(par.OP.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)
{
Vector2D vector2D = Par.ToGlobal(Par.OP.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);
}
public static Obj ObjLoad(this byte[] bd)
{
return bd.Load<byte[]>().ToDeserialObject<Obj>().SetDefaultR();
}
public static bool Lot(this double p)
{
return RNG.XS.NextDouble() < p;
}
public static int GetRandomIndex(params double[] WeightTable)
{
double les = WeightTable.Sum();
double num = RNG.XS.NextDouble(les);
int result = -1;
for (int i = 0; i < WeightTable.Length; i++)
{
if (WeightTable[i] >= num)
{
result = i;
break;
}
num -= WeightTable[i];
}
return result;
}
public static Encoding GetEncoding(this byte[] Bytes)
{
byte[] array = null;
if (Bytes.Length > 4000)
{
array = new byte[4000];
Array.Copy(Bytes, array, 4000);
}
else
{
array = Bytes;
}
int num = array.Length;
bool flag = false;
for (int i = 0; i < num; i++)
{
byte b = array[i];
if (b <= 6 || b == 127 || b == byte.MaxValue)
{
flag = true;
if (b == 0 && i < num - 1 && array[i + 1] <= 127)
{
return Encoding.Unicode;
}
}
}
if (flag)
{
return null;
}
bool flag2 = true;
byte[] array2 = array;
foreach (byte b2 in array2)
{
if (b2 == 27 || 128 <= b2)
{
flag2 = false;
break;
}
}
if (flag2)
{
return Encoding.ASCII;
}
for (int k = 0; k < num - 2; k++)
{
byte b = array[k];
byte b3 = array[k + 1];
byte b4 = array[k + 2];
if (b != 27)
{
continue;
}
if (b3 == 36 && b4 == 64)
{
return Encoding.GetEncoding(50220);
}
if (b3 == 36 && b4 == 66)
{
return Encoding.GetEncoding(50220);
}
if (b3 == 40 && (b4 == 66 || b4 == 74))
{
return Encoding.GetEncoding(50220);
}
if (b3 == 40 && b4 == 73)
{
return Encoding.GetEncoding(50220);
}
if (k < num - 3)
{
byte b5 = array[k + 3];
if (b3 == 36 && b4 == 40 && b5 == 68)
{
return Encoding.GetEncoding(50220);
}
if (k < num - 5 && b3 == 38 && b4 == 64 && b5 == 27 && array[k + 4] == 36 && array[k + 5] == 66)
{
return Encoding.GetEncoding(50220);
}
}
}
int num2 = 0;
int num3 = 0;
int num4 = 0;
for (int l = 0; l < num - 1; l++)
{
byte b = array[l];
byte b3 = array[l + 1];
if (((129 <= b && b <= 159) || (224 <= b && b <= 252)) && ((64 <= b3 && b3 <= 126) || (128 <= b3 && b3 <= 252)))
{
num2 += 2;
l++;
}
}
for (int m = 0; m < num - 1; m++)
{
byte b = array[m];
byte b3 = array[m + 1];
if ((161 <= b && b <= 254 && 161 <= b3 && b3 <= 254) || (b == 142 && 161 <= b3 && b3 <= 223))
{
num3 += 2;
m++;
}
else if (m < num - 2)
{
byte b4 = array[m + 2];
if (b == 143 && 161 <= b3 && b3 <= 254 && 161 <= b4 && b4 <= 254)
{
num3 += 3;
m += 2;
}
}
}
for (int n = 0; n < num - 1; n++)
{
byte b = array[n];
byte b3 = array[n + 1];
if (192 <= b && b <= 223 && 128 <= b3 && b3 <= 191)
{
num4 += 2;
n++;
}
else if (n < num - 2)
{
byte b4 = array[n + 2];
if (224 <= b && b <= 239 && 128 <= b3 && b3 <= 191 && 128 <= b4 && b4 <= 191)
{
num4 += 3;
n += 2;
}
}
}
if (num3 > num2 && num3 > num4)
{
return Encoding.GetEncoding(51932);
}
if (num2 > num3 && num2 > num4)
{
return Encoding.GetEncoding(932);
}
if (num4 > num3 && num4 > num2)
{
return Encoding.UTF8;
}
return null;
}
public static string Join(this IEnumerable<string> strs, string Separator)
{
return string.Join(Separator, strs);
}
public static string[] Split(this string str, string Separator)
{
return str.Split(new string[1] { Separator }, StringSplitOptions.None);
}
static Oth()
{
s1 = 1.01;
s0 = s1.Reciprocal();
}
public static void SaveExMod<T>(this T Obj, string Path)
{
Obj.ToSerialBytes().Save(Path);
}
public static T LoadExMod<T>(this string Path)
{
return Path.Load<byte[]>().ToDeserialObject<T>();
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.IO;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace _2DGAMELIB;
//outline/path/line basically represents a curve :3
[Serializable]
public class Out
{
public List<Vector2D> ps = new List<Vector2D>();
public float Tension = 0.5f;
public bool Outline = true;
public Out()
{
}
public Out(Out Out)
{
ps = new List<Vector2D>(Out.ps);
Tension = Out.Tension;
Outline = Out.Outline;
}
}

1094
2DGAMELIB/_2DGAMELIB/Par.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,375 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using Newtonsoft.Json;
namespace _2DGAMELIB;
// renders text
[Serializable]
public class ParT : Par
{
[NonSerialized, JsonIgnore]
private Font font = new Font("", 1f);
private double fontSize = 1.0;
private bool EditF = true;
[NonSerialized, JsonIgnore]
private Brush brusht = new SolidBrush(Color.Black);
private const double Shift = 1.0;
[NonSerialized, JsonIgnore]
private Brush brushs;
[NonSerialized, JsonIgnore]
private StringFormat stringformat = new StringFormat();
private Vector2D positionT = Dat.Vec2DZero;
private Vector2D rectSize = Dat.Vec2DOne;
public string Text = "";
private RectangleF rect;
private double us;
private double usx;
private double usy;
private Vector2D bp;
private Vector2D p;
private Vector2D v;
private double a0;
private double a1;
private double M11;
private double M12;
private float af;
private float xf;
private float yf;
private bool EditT = true;
private bool EditTS = true;
private CharacterRange[] crr = new CharacterRange[1];
private CharacterRange[] cre = new CharacterRange[1];
public Font Font
{
get
{
return font;
}
set
{
if (font != value && font != null)
{
font.Dispose();
}
font = value;
EditF = true;
}
}
public double FontSize
{
get
{
return fontSize;
}
set
{
fontSize = value;
EditF = true;
}
}
public Brush TextBrush
{
get
{
return brusht;
}
set
{
if (brusht != value && brusht != null)
{
brusht.Dispose();
}
brusht = value;
}
}
public Color TextColor
{
get
{
return ((SolidBrush)brusht).Color;
}
set
{
((SolidBrush)brusht).Color = value;
}
}
public Brush ShadBrush
{
get
{
return brushs;
}
set
{
if (brushs != value && brushs != null)
{
brushs.Dispose();
}
brushs = value;
}
}
public Color ShadColor
{
get
{
return ((SolidBrush)brushs).Color;
}
set
{
((SolidBrush)brushs).Color = value;
}
}
public StringFormat StringFormat
{
get
{
return stringformat;
}
set
{
if (stringformat != value && stringformat != null)
{
stringformat.Dispose();
}
stringformat = value;
}
}
public Vector2D PositionT
{
get
{
return positionT;
}
set
{
positionT = value;
EditT = true;
}
}
public Vector2D RectSize
{
get
{
return rectSize;
}
set
{
rectSize = value;
EditT = true;
}
}
public new void SetDefault()
{
base.SetDefault();
font = new Font("", 1f);
brusht = new SolidBrush(Color.Black);
brushs = null;
stringformat = new StringFormat();
}
public ParT()
{
}
public ParT(ParT ParT)
{
CopyT(ParT);
}
private void CopyT(ParT ParT)
{
Copy(ParT);
fontSize = ParT.fontSize;
if (ParT.font != null)
{
Font = ParT.font.Copy();
}
if (ParT.brusht != null)
{
TextBrush = ParT.brusht.Copy();
}
if (ParT.brushs != null)
{
ShadBrush = ParT.brushs.Copy();
}
if (ParT.stringformat != null)
{
StringFormat = ParT.stringformat.Copy();
}
positionT = ParT.positionT;
rectSize = ParT.rectSize;
Text = ParT.Text;
}
public new void Draw(double Unit, Graphics Graphics)
{
if (Edit)
{
EditT = true;
}
if (EditS || EditPS)
{
EditTS = true;
}
base.Draw(Unit, Graphics);
DrawString(Unit, Graphics);
}
private void Calculation(double Unit)
{
us = Unit * base.Size;
usx = us * base.SizeX;
usy = us * base.SizeY;
bp = base.BasePoint;
bp.X *= usx;
bp.Y *= usy;
a0 = base.Angle;
a1 = System.Math.PI * a0 / 180.0;
M11 = System.Math.Cos(a1);
M12 = System.Math.Sin(a1);
v.X = bp.X * M11 + bp.Y * (0.0 - M12);
v.Y = bp.X * M12 + bp.Y * M11;
p = base.Position;
bp.X = p.X * Unit - v.X;
bp.Y = p.Y * Unit - v.Y;
rect.X = (float)(positionT.X * us);
rect.Y = (float)(positionT.Y * us);
rect.Width = (float)(rectSize.X * us);
rect.Height = (float)(rectSize.Y * us);
}
private void DrawString(double Unit, Graphics Graphics)
{
if (EditT)
{
Calculation(Unit);
EditT = false;
}
if (EditF || EditTS)
{
Font = new Font(font.FontFamily, (float)(us * fontSize * Med.DpiY));
EditF = false;
EditTS = false;
}
af = (float)a0;
xf = (float)base.SizeX;
yf = (float)base.SizeY;
if (brushs != null)
{
Graphics.TranslateTransform((float)(bp.X + 1.0), (float)(bp.Y + 1.0));
Graphics.RotateTransform(af);
Graphics.ScaleTransform(xf, yf);
Graphics.DrawString(Text, font, brushs, rect, stringformat);
Graphics.ResetTransform();
}
Graphics.TranslateTransform((float)bp.X, (float)bp.Y);
Graphics.RotateTransform(af);
Graphics.ScaleTransform(xf, yf);
Graphics.DrawString(Text, font, brusht, rect, stringformat);
Graphics.ResetTransform();
}
public Vector2D_2 GetStringRect(double Unit, Graphics Graphics)
{
double num = Unit * base.Size;
if (EditF || EditS || EditPS || EditTS)
{
Font = new Font(font.FontFamily, (float)(num * fontSize * Med.DpiY));
EditF = false;
EditTS = false;
}
crr[0] = new CharacterRange(0, Text.Length);
stringformat.SetMeasurableCharacterRanges(crr);
RectangleF bounds = Graphics.MeasureCharacterRanges(Text, font, new RectangleF((float)(positionT.X * num), (float)(positionT.Y * num), (float)(rectSize.X * num), (float)(rectSize.Y * num)), stringformat)[0].GetBounds(Graphics);
return new Vector2D_2(new Vector2D((double)bounds.X / num, (double)bounds.Y / num), new Vector2D((double)bounds.Width / num, (double)bounds.Height / num));
}
public Vector2D[] GetStringRectPoints(double Unit, Graphics Graphics)
{
Vector2D_2 stringRect = GetStringRect(Unit, Graphics);
stringRect.v2.X *= 1.07;
return new Vector2D[4]
{
stringRect.v1,
new Vector2D(stringRect.v2.X, stringRect.v1.Y),
stringRect.v2,
new Vector2D(stringRect.v1.X, stringRect.v2.Y)
};
}
public void SetStringRectOutline(double Unit, Graphics Graphics)
{
Vector2D[] stringRectPoints = GetStringRectPoints(Unit, Graphics);
Out @out = new Out
{
Tension = 0f
};
Vector2D vector2D = Dat.Vec2DZero - stringRectPoints[0];
double x = 0.05;
double num = 0.025;
@out.ps.Add(stringRectPoints[0].AddY(0.0 - num) + vector2D);
@out.ps.Add(stringRectPoints[1].AddXY(x, 0.0 - num) + vector2D);
@out.ps.Add(stringRectPoints[2].AddXY(x, num) + vector2D);
@out.ps.Add(stringRectPoints[3].AddY(num) + vector2D);
base.OP.Add(@out);
}
public new void Dispose()
{
base.Dispose();
if (font != null)
{
font.Dispose();
}
if (brusht != null)
{
brusht.Dispose();
}
if (brushs != null)
{
brushs.Dispose();
}
if (stringformat != null)
{
stringformat.Dispose();
}
}
}

View File

@@ -0,0 +1,864 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Windows.Documents;
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<string> Keys => pars.Keys;
public IEnumerable<object> Values => pars.Values;
public double PositionSize
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).PositionSize = value;
}
else if (value2 is Par)
{
((Par)value2).PositionSize = value;
}
}
}
}
public Vector2D PositionVector
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).PositionVector = value;
}
else if (value2 is Par)
{
((Par)value2).PositionVector = value;
}
}
}
}
public double AngleBase
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).AngleBase = value;
}
else if (value2 is Par)
{
((Par)value2).AngleBase = value;
}
}
}
}
public double AngleCont
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).AngleCont = value;
}
else if (value2 is Par)
{
((Par)value2).AngleCont = value;
}
}
}
}
public double SizeBase
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).SizeBase = value;
}
else if (value2 is Par)
{
((Par)value2).SizeBase = value;
}
}
}
}
public double SizeCont
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).SizeCont = value;
}
else if (value2 is Par)
{
((Par)value2).SizeCont = value;
}
}
}
}
public double SizeXBase
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).SizeXBase = value;
}
else if (value2 is Par)
{
((Par)value2).SizeXBase = value;
}
}
}
}
public double SizeXCont
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).SizeXCont = value;
}
else if (value2 is Par)
{
((Par)value2).SizeXCont = value;
}
}
}
}
public double SizeYBase
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).SizeYBase = value;
}
else if (value2 is Par)
{
((Par)value2).SizeYBase = value;
}
}
}
}
public double SizeYCont
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).SizeYCont = value;
}
else if (value2 is Par)
{
((Par)value2).SizeYCont = value;
}
}
}
}
public bool Dra
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).Dra = value;
}
else if (value2 is Par)
{
((Par)value2).Dra = value;
}
}
}
}
public bool Hit
{
set
{
foreach (object value2 in pars.Values)
{
if (value2 is Pars)
{
((Pars)value2).Hit = value;
}
else if (value2 is Par)
{
((Par)value2).Hit = 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(Pars Parent)
{
parent = Parent;
}
public int IndexOf(string Name)
{
return pars.IndexOf(Name);
}
public int IndexOf(object obj)
{
return pars.IndexOf(obj);
}
public int LastIndexOf(string Name)
{
return pars.LastIndexOf(Name);
}
public int LastIndexOf(object obj)
{
return pars.LastIndexOf(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(string Name, object obj)
{
if (obj is Pars)
{
((Pars)obj).SetParent(this);
}
else if (obj is ParT)
{
((ParT)obj).SetParent(this);
}
else if (obj is Par)
{
((Par)obj).SetParent(this);
}
pars.Add(Name, obj);
}
public void Add(Par Par)
{
Par.SetParent(this);
pars.Add(Par.Tag, Par);
}
public void Add(ParT ParT)
{
ParT.SetParent(this);
pars.Add(ParT.Tag, ParT);
}
public void Add(Pars Pars)
{
Pars.SetParent(this);
pars.Add(Pars.Tag, Pars);
}
public void Add(object obj)
{
if (obj is Pars)
{
Add((Pars)obj);
}
else if (obj is ParT)
{
Add((ParT)obj);
}
else if (obj is Par)
{
Add((Par)obj);
}
}
public void Insert(int Index, string Name, Par Par)
{
Par.SetParent(this);
pars.Insert(Index, Name, Par);
}
public void Insert(int Index, string Name, ParT ParT)
{
ParT.SetParent(this);
pars.Insert(Index, Name, ParT);
}
public void Insert(int Index, string Name, Pars Pars)
{
Pars.SetParent(this);
pars.Insert(Index, Name, Pars);
}
public void Insert(int Index, string Name, object obj)
{
if (obj is Pars)
{
((Pars)obj).SetParent(this);
}
else if (obj is ParT)
{
((ParT)obj).SetParent(this);
}
else if (obj is Par)
{
((Par)obj).SetParent(this);
}
pars.Insert(Index, Name, obj);
}
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(Par Par)
{
Tag = Par.Tag;
Add(Par.Tag, Par);
}
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 List<string> GetHitTags(ref Color HitColor)
{
List<string> list = new List<string>();
foreach (object value in pars.Values)
{
Par par;
if (value is Pars)
{
list.AddRange(((Pars)value).GetHitTags(ref HitColor));
}
else if (value is Par && (par = (Par)value).HitColor == HitColor)
{
list.Add(par.Tag);
}
}
return list;
}
public List<Par> GetHitPars(ref Color HitColor)
{
List<Par> list = new List<Par>();
foreach (object value in pars.Values)
{
Par item;
if (value is Pars)
{
list.AddRange(((Pars)value).GetHitPars(ref HitColor));
}
else if (value is Par && (item = (Par)value).HitColor == HitColor)
{
list.Add(item);
}
}
return list;
}
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).HitColor == 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 Pars GetRoot()
{
Pars pars2 = parent;
while (pars2.Parent != null)
{
pars2 = pars2.Parent;
}
return pars2;
}
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 bool IsParentTag(string Tag)
{
if (Parent != null)
{
return Parent.Tag == Tag;
}
return false;
}
public bool IsRootTag(string Tag)
{
Pars root = GetRoot();
if (root != null)
{
return root.Tag == Tag;
}
return false;
}
public bool ContainsParentTag(string Tag)
{
if (Parent != null)
{
return Parent.Tag.Contains(Tag);
}
return false;
}
public bool ContainsRootTag(string Tag)
{
return GetRoot()?.Tag.Contains(Tag) ?? false;
}
public void ScalingXY(double Scale)
{
foreach (Par item in EnumAllPar())
{
item.ScalingXY(Scale);
item.ScalingXY(Scale);
}
}
public void ScalingX(double Scale)
{
foreach (Par item in EnumAllPar())
{
item.ScalingX(Scale);
item.ScalingX(Scale);
}
}
public void ScalingY(double Scale)
{
foreach (Par item in EnumAllPar())
{
item.ScalingY(Scale);
item.ScalingY(Scale);
}
}
public void ExpansionXY(double Rate)
{
foreach (Par item in EnumAllPar())
{
item.ExpansionXY(Rate);
item.ExpansionXY(Rate);
}
}
public void ExpansionX(double Rate)
{
foreach (Par item in EnumAllPar())
{
item.ExpansionX(Rate);
item.ExpansionX(Rate);
}
}
public void ExpansionY(double Rate)
{
foreach (Par item in EnumAllPar())
{
item.ExpansionY(Rate);
item.ExpansionY(Rate);
}
}
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();
}
}
}
}
public static class pars
{
public static bool IsPars(this object obj)
{
return obj is Pars;
}
public static bool IsParT(this object obj)
{
return obj is ParT;
}
public static bool IsPar(this object obj)
{
return obj is Par;
}
public static Pars ToPars(this object obj)
{
return (Pars)obj;
}
public static ParT ToParT(this object obj)
{
return (ParT)obj;
}
public static Par ToPar(this object obj)
{
return (Par)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

@@ -0,0 +1,51 @@
using System;
using System.Globalization;
namespace _2DGAMELIB;
public static class Qua
{
public static QuaternionD RotationZQ(this double angle)
{
double num = angle * 0.5;
QuaternionD result = default(QuaternionD);
result.X = 0.0;
result.Y = 0.0;
result.Z = System.Math.Sin(num);
result.W = System.Math.Cos(num);
return result;
}
public static void TransformCoordinate(ref Vector2D coord, ref QuaternionD rotation, out Vector2D result)
{
double num = rotation.Y + rotation.Y;
double num2 = rotation.Z + rotation.Z;
double num3 = rotation.W * num2;
double num4 = rotation.X * num;
double num5 = rotation.Z * num2;
result.X = coord.X * (1.0 - rotation.Y * num - num5) + coord.Y * (num4 - num3);
result.Y = coord.X * (num4 + num3) + coord.Y * (1.0 - rotation.X * (rotation.X + rotation.X) - num5);
}
public static Vector2D TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, QuaternionD rotation)
{
Vec.Subtract(ref coord, ref BasePoint, out coord);
TransformCoordinate(ref coord, ref rotation, out var result);
Vec.Add(ref result, ref BasePoint, out result);
return result;
}
}
//used in a total of 1 places
[Serializable]
public struct QuaternionD
{
public double X;
public double Y;
public double Z;
public double W;
}

View File

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

View File

@@ -0,0 +1,47 @@
namespace _2DGAMELIB;
public class Rect
{
public double XRatio = 1.0;
public double YRatio = 1.0;
public double Size = 1.0;
public double LocalWidth => XRatio * Size;
public double LocalHeight => YRatio * Size;
public Vector2D LocalCenter => new Vector2D(LocalWidth * 0.5, LocalHeight * 0.5);
public Rect()
{
}
public Rect(double XRatio, double YRatio, double Size)
{
SetXYRatio(XRatio, YRatio);
this.Size = Size;
}
public void SetXYRatio(double X, double Y)
{
XRatio = X / Y;
YRatio = 1.0;
}
public Vector2D GetPosition(double X, double Y)
{
return new Vector2D(LocalWidth * X, LocalHeight * Y);
}
public Vector2D GetPosition(Vector2D p)
{
return new Vector2D(LocalWidth * p.X, LocalHeight * p.Y);
}
public Vector2D GetPosition(ref Vector2D p)
{
return new Vector2D(LocalWidth * p.X, LocalHeight * p.Y);
}
}

View File

@@ -0,0 +1,80 @@
using System.Drawing;
using System.Drawing.Imaging;
namespace _2DGAMELIB;
//Basically used to animate switching between two static images
public class Sce
{
private Bitmap Start;
private Graphics GS;
private Bitmap End;
private Graphics GE;
private int w;
private int h;
private int o;
private Rectangle r;
private ColorMatrix cm = new ColorMatrix();
private ImageAttributes ia = new ImageAttributes();
public Sce(int Width, int Height)
{
w = Width;
h = Height;
Start = new Bitmap(w, h);
GS = Graphics.FromImage(Start);
End = new Bitmap(w, h);
GE = Graphics.FromImage(End);
r = new Rectangle(0, 0, w, h);
}
public void TransformAlpha(Graphics Graphics, double Rate)
{
Graphics.DrawImage(Start, 0, 0);
cm.Matrix33 = (float)Rate;
ia.SetColorMatrix(cm);
Graphics.DrawImage(End, r, 0, 0, w, h, GraphicsUnit.Pixel, ia);
}
public void TransD(Graphics Graphics, double Rate)
{
Graphics.DrawImage(End, 0, 0);
cm.Matrix33 = (float)Rate.Inverse();
ia.SetColorMatrix(cm);
Graphics.DrawImage(Start, r, 0, 0, w, h, GraphicsUnit.Pixel, ia);
}
public void DrawStart(Are Are)
{
Are.Draw(GS);
}
public void DrawEnd(Are Are)
{
Are.Draw(GE);
}
public void ClearStart(ref Color ClearColor)
{
GS.Clear(ClearColor);
}
public void Dispose()
{
Start.Dispose();
GS.Dispose();
End.Dispose();
GE.Dispose();
ia.Dispose();
}
}

View File

@@ -0,0 +1,92 @@
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
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 void ToJson<T>(this T Object, string Path)
{
using StreamWriter textWriter = File.CreateText(Path);
JsonSerializer jsonSerializer = new JsonSerializer();
jsonSerializer.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
jsonSerializer.TypeNameHandling = TypeNameHandling.All;
jsonSerializer.Formatting = Newtonsoft.Json.Formatting.Indented;
jsonSerializer.Serialize(textWriter, Object);
}
public static T UnJson<T>(string Path)
{
using StreamReader reader = File.OpenText(Path);
return (T)new JsonSerializer
{
NullValueHandling = NullValueHandling.Ignore,
TypeNameHandling = TypeNameHandling.All
}.Deserialize(reader, typeof(T));
}
}

View File

@@ -0,0 +1,557 @@
using System.Collections.Generic;
using System.Linq;
namespace _2DGAMELIB;
public static class Shas
{
public static readonly double D3 = 1.0 / 3.0;
public static readonly double D3_2 = 2.0 / 3.0;
public static Vector2D = Dat.Vec2DZero;
public static Vector2D = new Vector2D(0.5, 0.0);
public static Vector2D = new Vector2D(D3, 0.0);
public static Vector2D = new Vector2D(D3_2, 0.0);
public static Vector2D = new Vector2D(1.0, 0.0);
public static Vector2D = new Vector2D(0.0, 0.5);
public static Vector2D = new Vector2D(0.5, 0.5);
public static Vector2D = new Vector2D(D3, 0.5);
public static Vector2D = new Vector2D(D3_2, 0.5);
public static Vector2D = new Vector2D(1.0, 0.5);
public static Vector2D = new Vector2D(0.0, D3);
public static Vector2D = new Vector2D(0.5, D3);
public static Vector2D = new Vector2D(D3, D3);
public static Vector2D = new Vector2D(D3_2, D3);
public static Vector2D = new Vector2D(1.0, D3);
public static Vector2D = new Vector2D(0.0, D3_2);
public static Vector2D = new Vector2D(0.5, D3_2);
public static Vector2D = new Vector2D(D3, D3_2);
public static Vector2D = new Vector2D(D3_2, D3_2);
public static Vector2D = new Vector2D(1.0, D3_2);
public static Vector2D = new Vector2D(0.0, 1.0);
public static Vector2D = new Vector2D(0.5, 1.0);
public static Vector2D = new Vector2D(D3, 1.0);
public static Vector2D = new Vector2D(D3_2, 1.0);
public static Vector2D = Dat.Vec2DOne;
private static MatrixD m120 = 120.0.ToRadian().RotationZ();
private static MatrixD m240 = 240.0.ToRadian().RotationZ();
public static Vector2D TP1 = ;
public static Vector2D TP2 = GetTP2();
public static Vector2D TP3 = GetTP3();
public static Vector2D TP1_2 = (TP1 + TP2) * 0.5;
public static Vector2D TP2_3 = (TP2 + TP3) * 0.5;
public static Vector2D TP3_1 = (TP3 + TP1) * 0.5;
private static Vector2D GetTP2()
{
return Matrix.TransformCoordinateBP(ref TP1, ref , ref m120);
}
private static Vector2D GetTP3()
{
return Matrix.TransformCoordinateBP(ref TP1, ref , ref m240);
}
public static Vector2D MulX(this Vector2D Vector, double X)
{
Vector.X *= X;
return Vector;
}
public static Vector2D MulY(this Vector2D Vector, double Y)
{
Vector.Y *= Y;
return Vector;
}
public static Vector2D MulXY(this Vector2D Vector, double X, double Y)
{
Vector.X *= X;
Vector.Y *= Y;
return Vector;
}
public static Vector2D AddX(this Vector2D Point, double X)
{
Point.X += X;
return Point;
}
public static Vector2D AddY(this Vector2D Point, double Y)
{
Point.Y += Y;
return Point;
}
public static Vector2D AddXY(this Vector2D Point, double X, double Y)
{
Point.X += X;
Point.Y += Y;
return Point;
}
public static void SetTension(this IEnumerable<Out> Out, float Tension)
{
foreach (Out item in Out)
{
item.Tension = Tension;
}
}
public static void OutlineFalse(this IEnumerable<Out> Out)
{
foreach (Out item in Out)
{
item.Outline = false;
}
}
public static Vector2D GetCenter(this IEnumerable<Out> Out)
{
double num = 0.0;
Vector2D vec2DZero = Dat.Vec2DZero;
foreach (Out item in Out)
{
foreach (Vector2D p in item.ps)
{
vec2DZero += p;
}
num += (double)item.ps.Count;
}
return vec2DZero / num;
}
public static Vector2D GetCenter(this IEnumerable<Joi> Joi)
{
double num = 0.0;
Vector2D vec2DZero = Dat.Vec2DZero;
foreach (Joi item in Joi)
{
vec2DZero += item.Joint;
num += 1.0;
}
return vec2DZero / num;
}
public static void Rotation(this IEnumerable<Out> Out, Vector2D BP, double Angle)
{
MatrixD transform = Angle.ToRadian().RotationZ();
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
item.ps[i] = item.ps[i].TransformCoordinateBP(BP, transform);
}
}
}
public static void ScalingX(this IEnumerable<Out> Out, Vector2D BP, double Rate)
{
double num = BP.X - BP.X * Rate;
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D value = item.ps[i];
value.X = value.X * Rate + num;
item.ps[i] = value;
}
}
}
public static void ScalingX(this IEnumerable<Out> Out, ref Vector2D BP, double Rate)
{
double num = BP.X - BP.X * Rate;
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D value = item.ps[i];
value.X = value.X * Rate + num;
item.ps[i] = value;
}
}
}
public static void ScalingY(this IEnumerable<Out> Out, Vector2D BP, double Rate)
{
double num = BP.Y - BP.Y * Rate;
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D value = item.ps[i];
value.Y = value.Y * Rate + num;
item.ps[i] = value;
}
}
}
public static void ScalingY(this IEnumerable<Out> Out, ref Vector2D BP, double Rate)
{
double num = BP.Y - BP.Y * Rate;
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D value = item.ps[i];
value.Y = value.Y * Rate + num;
item.ps[i] = value;
}
}
}
public static void ScalingXY(this IEnumerable<Out> 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)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D value = item.ps[i];
value.X = value.X * Rate + vector2D.X;
value.Y = value.Y * Rate + vector2D.Y;
item.ps[i] = value;
}
}
}
public static void ScalingXY(this IEnumerable<Out> 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)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D value = item.ps[i];
value.X = value.X * Rate + vector2D.X;
value.Y = value.Y * Rate + vector2D.Y;
item.ps[i] = value;
}
}
}
public static void ScalingXY(this IEnumerable<Out> 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)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D value = item.ps[i];
value.X = value.X * X + vector2D.X;
value.Y = value.Y * Y + vector2D.Y;
item.ps[i] = value;
}
}
}
public static void ScalingX(this IEnumerable<Joi> Joi, Vector2D BP, double Rate)
{
double num = BP.X - BP.X * Rate;
foreach (Joi item in Joi)
{
item.Joint.X = item.Joint.X * Rate + num;
}
}
public static void ScalingX(this IEnumerable<Joi> Joi, ref Vector2D BP, double Rate)
{
double num = BP.X - BP.X * Rate;
foreach (Joi item in Joi)
{
item.Joint.X = item.Joint.X * Rate + num;
}
}
public static void ScalingY(this IEnumerable<Joi> Joi, Vector2D BP, double Rate)
{
double num = BP.Y - BP.Y * Rate;
foreach (Joi item in Joi)
{
item.Joint.Y = item.Joint.Y * Rate + num;
}
}
public static void ScalingY(this IEnumerable<Joi> Joi, ref Vector2D BP, double Rate)
{
double num = BP.Y - BP.Y * Rate;
foreach (Joi item in Joi)
{
item.Joint.Y = item.Joint.Y * Rate + num;
}
}
public static void ScalingXY(this IEnumerable<Joi> 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)
{
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)
{
Vector2D vector2D = default(Vector2D);
vector2D.X = BP.X - BP.X * Rate;
vector2D.Y = BP.Y - BP.Y * Rate;
foreach (Joi 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)
{
double num = BP.X - (1.0 - BP.X);
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D value = item.ps[i];
value.X = 1.0 - value.X + num;
item.ps[i] = value;
}
item.ps.Reverse();
}
Out.Reverse();
}
public static void ReverseY(this List<Out> Out, Vector2D BP)
{
double num = BP.Y - (1.0 - BP.Y);
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D value = item.ps[i];
value.Y = 1.0 - value.Y + num;
item.ps[i] = value;
}
item.ps.Reverse();
}
Out.Reverse();
}
public static void ReverseY(this List<Out> Out, ref Vector2D BP)
{
double num = BP.Y - (1.0 - BP.Y);
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D value = item.ps[i];
value.Y = 1.0 - value.Y + num;
item.ps[i] = value;
}
item.ps.Reverse();
}
Out.Reverse();
}
public static void ReverseX(this List<Joi> Joi, ref Vector2D BP)
{
double num = BP.X - (1.0 - BP.X);
foreach (Joi item in Joi)
{
item.Joint.X = 1.0 - item.Joint.X + num;
}
}
public static void ReverseY(this List<Joi> Joi, ref Vector2D BP)
{
double num = BP.Y - (1.0 - BP.Y);
foreach (Joi item in Joi)
{
item.Joint.Y = 1.0 - item.Joint.Y + num;
}
}
public static void ExpansionX(this List<Out> Out, Vector2D BP, double Rate)
{
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D vector2D = (item.ps[i] - BP).newNormalize();
vector2D.Y = 0.0;
item.ps[i] += vector2D * Rate;
}
}
}
public static void ExpansionX(this List<Out> Out, ref Vector2D BP, double Rate)
{
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D vector2D = (item.ps[i] - BP).newNormalize();
vector2D.Y = 0.0;
item.ps[i] += vector2D * Rate;
}
}
}
public static void ExpansionY(this List<Out> Out, Vector2D BP, double Rate)
{
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D vector2D = (item.ps[i] - BP).newNormalize();
vector2D.X = 0.0;
item.ps[i] += vector2D * Rate;
}
}
}
public static void ExpansionY(this List<Out> Out, ref Vector2D BP, double Rate)
{
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
Vector2D vector2D = (item.ps[i] - BP).newNormalize();
vector2D.X = 0.0;
item.ps[i] += vector2D * Rate;
}
}
}
public static void ExpansionXY(this List<Out> Out, Vector2D BP, double Rate)
{
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
item.ps[i] += (item.ps[i] - BP).newNormalize() * Rate;
}
}
}
public static void ExpansionXY(this List<Out> Out, ref Vector2D BP, double Rate)
{
foreach (Out item in Out)
{
for (int i = 0; i < item.ps.Count; i++)
{
item.ps[i] += (item.ps[i] - BP).newNormalize() * Rate;
}
}
}
public static void ExpansionX(this List<Joi> Joi, ref Vector2D BP, double Rate)
{
foreach (Joi item in Joi)
{
Vector2D vector2D = (item.Joint - BP).newNormalize();
vector2D.Y = 0.0;
item.Joint += vector2D * Rate;
}
}
public static void ExpansionY(this List<Joi> Joi, ref Vector2D BP, double Rate)
{
foreach (Joi item in Joi)
{
Vector2D vector2D = (item.Joint - BP).newNormalize();
vector2D.X = 0.0;
item.Joint += vector2D * Rate;
}
}
public static void ExpansionXY(this List<Joi> Joi, Vector2D BP, double Rate)
{
foreach (Joi item in Joi)
{
item.Joint += (item.Joint - BP).newNormalize() * Rate;
}
}
public static void ExpansionXY(this List<Joi> Joi, ref Vector2D BP, double Rate)
{
foreach (Joi item in Joi)
{
item.Joint += (item.Joint - BP).newNormalize() * Rate;
}
}
public static IEnumerable<Vector2D> EnumPoints(this IEnumerable<Out> Out)
{
HashSet<Vector2D> hs = new HashSet<Vector2D>();
foreach (Out item in Out)
{
foreach (Vector2D p in item.ps)
{
if (!hs.Contains(p))
{
yield return p;
hs.Add(p);
}
}
}
}
public static Out Get三角形()
{
return new Out
{
Tension = 0f,
ps = { TP1, TP2, TP3 }
};
}
public static Out Get正方形()
{
return new Out
{
Tension = 0f,
ps = { , , , }
};
}
}

View File

@@ -0,0 +1,75 @@
using System;
using System.Windows.Media;
namespace _2DGAMELIB;
public class SoundPlayer
{
public MediaPlayer mp = new MediaPlayer();
private bool l;
private TimeSpan ts = new TimeSpan(0L);
public bool Loop
{
get
{
return l;
}
set
{
if (value)
{
if (l != value)
{
mp.MediaEnded += loop;
}
}
else if (l != value)
{
mp.MediaEnded -= loop;
}
l = value;
}
}
public SoundPlayer(string Path)
{
mp.Open(new Uri(Path));
mp.Volume = 1.0;
}
public SoundPlayer(string Path, bool Loop)
{
mp.Open(new Uri(Path));
this.Loop = Loop;
mp.Volume = 1.0;
}
private void loop(object s, EventArgs e)
{
mp.Position = ts;
mp.Play();
}
public void Play()
{
mp.Play();
}
public void Stop()
{
mp.Stop();
}
public void Pause()
{
mp.Pause();
}
public void Close()
{
mp.Close();
}
}

167
2DGAMELIB/_2DGAMELIB/Swi.cs Normal file
View File

@@ -0,0 +1,167 @@
using System.Collections.Generic;
using System.Drawing;
namespace _2DGAMELIB;
public class Swi
{
private bool flag;
private Color OnColor = Color.Red;
private List<Color> colors;
public bool Flag => flag;
public Swi(Color OnColor)
{
this.OnColor = OnColor;
}
public Swi(ref Color OnColor)
{
this.OnColor = OnColor;
}
public void OnOff(But But)
{
But1 but = (But1)But;
if (!flag)
{
flag = true;
if (colors == null)
{
colors = new List<Color>(but.BaseColors);
}
int i;
for (i = 0; i < but.BaseColors.Count; i++)
{
but.BaseColors[i] = OnColor;
but.OverColors[i] = but.BaseColors[i].FuncHSV(delegate(Hsv hsv)
{
hsv.Hue += 30;
hsv.Sat -= 30;
hsv.Val += 100;
return hsv;
});
but.PushColors[i] = but.OverColors[i].FuncHSV(delegate(Hsv hsv)
{
hsv.Hue += 30;
hsv.Sat -= 30;
hsv.Val += 100;
return hsv;
});
}
i = 0;
{
foreach (Par item in but.Pars.EnumAllPar())
{
item.BrushColor = but.OverColors[i];
i++;
}
return;
}
}
flag = false;
if (colors != null)
{
but.BaseColors = colors;
colors = null;
}
int j;
for (j = 0; j < but.BaseColors.Count; j++)
{
but.OverColors[j] = but.BaseColors[j].FuncHSV(delegate(Hsv hsv)
{
hsv.Hue += 30;
hsv.Sat -= 30;
hsv.Val += 100;
return hsv;
});
but.PushColors[j] = but.OverColors[j].FuncHSV(delegate(Hsv hsv)
{
hsv.Hue += 30;
hsv.Sat -= 30;
hsv.Val += 100;
return hsv;
});
}
j = 0;
foreach (Par item2 in but.Pars.EnumAllPar())
{
item2.BrushColor = but.OverColors[j];
j++;
}
}
public void SetFlag(But But, bool On)
{
But1 but = (But1)But;
if (On)
{
flag = true;
if (colors == null)
{
colors = new List<Color>(but.BaseColors);
}
int i;
for (i = 0; i < but.BaseColors.Count; i++)
{
but.BaseColors[i] = OnColor;
but.OverColors[i] = but.BaseColors[i].FuncHSV(delegate(Hsv hsv)
{
hsv.Hue += 30;
hsv.Sat -= 30;
hsv.Val += 100;
return hsv;
});
but.PushColors[i] = but.OverColors[i].FuncHSV(delegate(Hsv hsv)
{
hsv.Hue += 30;
hsv.Sat -= 30;
hsv.Val += 100;
return hsv;
});
}
i = 0;
{
foreach (Par item in but.Pars.EnumAllPar())
{
item.BrushColor = but.BaseColors[i];
i++;
}
return;
}
}
flag = false;
if (colors != null)
{
but.BaseColors = colors;
colors = null;
}
int j;
for (j = 0; j < but.BaseColors.Count; j++)
{
but.OverColors[j] = but.BaseColors[j].FuncHSV(delegate(Hsv hsv)
{
hsv.Hue += 30;
hsv.Sat -= 30;
hsv.Val += 100;
return hsv;
});
but.PushColors[j] = but.OverColors[j].FuncHSV(delegate(Hsv hsv)
{
hsv.Hue += 30;
hsv.Sat -= 30;
hsv.Val += 100;
return hsv;
});
}
j = 0;
foreach (Par item2 in but.Pars.EnumAllPar())
{
item2.BrushColor = but.BaseColors[j];
j++;
}
}
}

405
2DGAMELIB/_2DGAMELIB/Tex.cs Normal file
View File

@@ -0,0 +1,405 @@
using System;
using System.Drawing;
using System.IO;
using System.Linq;
namespace _2DGAMELIB;
public class Tex
{
private Pars pars;
private ParT parT;
private Par feed;
public int Space;
private string text;
private double speed = 1.0;
private Action<Tex> Action = delegate
{
};
private MotV mv;
private bool f1;
private bool f2;
private double Count;
private int Max;
public Action<Tex> Done;
private byte a0;
private byte a1;
private string ConfigPath = Directory.GetCurrentDirectory() + "\\Config.ini";
private bool FastText;
public Pars Pars => pars;
public ParT ParT => parT;
public Par Feed => feed;
public string TextIm
{
get
{
return text.Substring(Space, text.Length - Space);
}
set
{
if (feed != null)
{
a0 = feed.BrushColor.A;
a1 = feed.PenColor.A;
feed.BrushColor = Color.FromArgb(0, feed.BrushColor);
feed.PenColor = Color.FromArgb(0, feed.PenColor);
}
text = new string(' ', Space) + value;
Max = text.Length;
Count = Max;
f1 = false;
if (parT != null)
{
parT.Text = text;
}
}
}
public string Text
{
get
{
return text.Substring(Space, text.Length - Space);
}
set
{
if (feed != null)
{
a0 = feed.BrushColor.A;
a1 = feed.PenColor.A;
feed.BrushColor = Color.FromArgb(0, feed.BrushColor);
feed.PenColor = Color.FromArgb(0, feed.PenColor);
}
text = new string(' ', Space) + value;
Max = text.Length;
Count = Space;
f1 = false;
}
}
public double Speed
{
get
{
return speed;
}
set
{
speed = value;
}
}
public Vector2D Position
{
get
{
return parT.PositionBase;
}
set
{
parT.PositionBase = value;
if (feed != null)
{
feed.PositionBase = parT.ToGlobal(parT.OP[0].ps[2] * 0.95);
}
}
}
public bool IsPlaying => !f1;
public Tex(string Name, ref Vector2D Position, double Size, double Width, double Height, Font Font, double TextSize, int Space, string Text, ref Color TextColor, ref Color ShadColor, ref Color BackColor, double Speed, ref Color FeedColor, Action<Tex> Action)
{
try
{
if (!File.Exists(ConfigPath))
{
this.Speed = Speed;
speed = Speed;
}
else
{
string[] source = ConfigPath.ReadLines();
FastText = source.First((string s) => s.StartsWith("FastText:")).Last() == '1';
}
}
catch
{
this.Speed = Speed;
speed = Speed;
}
if (FastText)
{
this.Speed = 50.0;
speed = 50.0;
}
else
{
this.Speed = Speed;
speed = Speed;
}
this.Space = Space;
this.Text = Text;
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.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, Color FeedColor, Action<Tex> Action)
{
try
{
if (!File.Exists(ConfigPath))
{
this.Speed = Speed;
speed = Speed;
}
else
{
string[] source = ConfigPath.ReadLines();
FastText = source.First((string s) => s.StartsWith("FastText:")).Last() == '1';
}
}
catch
{
this.Speed = Speed;
speed = Speed;
}
if (FastText)
{
this.Speed = 50.0;
speed = 50.0;
}
else
{
this.Speed = Speed;
speed = Speed;
}
this.Space = Space;
this.Text = Text;
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.BaseSpeed = 2.0;
}
public Tex(string Name, ref Vector2D Position, double Size, double Width, double Height, Font Font, double TextSize, int Space, string Text, ref Color TextColor, ref Color ShadColor, ref Color BackColor, double Speed)
{
try
{
if (!File.Exists(ConfigPath))
{
this.Speed = Speed;
speed = Speed;
}
else
{
string[] source = ConfigPath.ReadLines();
FastText = source.First((string s) => s.StartsWith("FastText:")).Last() == '1';
}
}
catch
{
this.Speed = Speed;
speed = Speed;
}
if (FastText)
{
this.Speed = 50.0;
speed = 50.0;
}
else
{
this.Speed = Speed;
speed = Speed;
}
this.Space = Space;
this.Text = Text;
SetParT(Name, ref Position, Size, Width, Height, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor);
}
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)
{
try
{
if (!File.Exists(ConfigPath))
{
this.Speed = Speed;
speed = Speed;
}
else
{
string[] source = ConfigPath.ReadLines();
FastText = source.First((string s) => s.StartsWith("FastText:")).Last() == '1';
}
}
catch
{
this.Speed = Speed;
speed = Speed;
}
if (FastText)
{
this.Speed = 50.0;
speed = 50.0;
}
else
{
this.Speed = Speed;
speed = Speed;
}
this.Space = Space;
this.Text = Text;
SetParT(Name, ref Position, Size, Width, Height, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor);
}
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.Get正方形() };
array.OutlineFalse();
parT = new ParT
{
Tag = Name,
InitializeOP = array,
PositionBase = Position,
SizeBase = Size,
Closed = true,
BrushColor = BackColor,
Font = Font,
FontSize = TextSize,
TextColor = TextColor,
RectSize = new Vector2D(Width, Height),
Text = Text
};
ParT.OP.ScalingX(ParT.BasePointBase, Width);
ParT.OP.ScalingY(ParT.BasePointBase, Height);
if (ShadColor != Color.Empty)
{
parT.ShadBrush = new SolidBrush(ShadColor);
}
pars.Add(parT.Tag, parT);
}
private void SetFeed(string Name, double Size, ref Color FeedColor)
{
Out[] array = new Out[1] { Shas.Get三角形() };
feed = new Par
{
Tag = Name + "_Feed",
InitializeOP = array,
BasePointBase = array.GetCenter(),
PositionBase = parT.ToGlobal(parT.OP[0].ps[2] * 0.96),
SizeBase = Size * 0.07,
SizeYBase = 0.9,
Closed = true,
PenColor = Color.FromArgb(0, Color.Black),
BrushColor = Color.FromArgb(0, FeedColor),
Hit = false
};
feed.OP.ReverseY(feed.BasePointBase);
pars.Add(feed.Tag, feed);
}
public void SetHitColor(Med Med)
{
if (parT.HitColor != Color.Transparent)
{
Med.RemUniqueColor(parT.HitColor);
}
parT.HitColor = Med.GetUniqueColor();
}
public void Progression(FPS FPS)
{
if (!f1)
{
Count += Speed / FPS.Value;
int num = (int)Count;
if (num <= Max)
{
parT.Text = text.Substring(0, num);
return;
}
parT.Text = text;
f1 = true;
if (feed != null)
{
feed.BrushColor = Color.FromArgb(a0, feed.BrushColor);
feed.PenColor = Color.FromArgb(a1, feed.PenColor);
}
if (Done != null)
{
Done(this);
Done = null;
}
}
else if (feed != null && feed.Dra)
{
mv.GetValue(FPS);
feed.BrushColor = Color.FromArgb((int)mv.Value, feed.BrushColor);
feed.PenColor = Color.FromArgb(feed.BrushColor.A, feed.PenColor);
}
}
public bool Down(ref Color HitColor)
{
if (parT.HitColor == HitColor)
{
f2 = true;
if (!f1 && Speed == speed)
{
Speed *= 10.0;
return true;
}
}
return false;
}
public bool Up(ref Color HitColor)
{
if (f1 && f2 && parT.HitColor == HitColor && Speed == speed)
{
f1 = false;
f2 = false;
if (feed != null)
{
feed.BrushColor = Color.FromArgb(0, feed.BrushColor);
feed.PenColor = Color.FromArgb(feed.BrushColor.A, feed.PenColor);
mv.ResetValue();
}
Action(this);
return true;
}
Speed = speed;
f2 = false;
return false;
}
public void Dispose()
{
pars.Dispose();
}
}

View File

@@ -0,0 +1,27 @@
using System.IO;
using System.Text;
namespace _2DGAMELIB;
public static class Text
{
public static void ToText(this string str, string Path, Encoding Encoding)
{
using StreamWriter streamWriter = new StreamWriter(Path, append: false, Encoding);
streamWriter.Write(str);
}
public static string FromText(this string Path)
{
using FileStream fileStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
byte[] array = new byte[fileStream.Length];
fileStream.Read(array, 0, array.Length);
using StreamReader streamReader = new StreamReader(new MemoryStream(array), array.GetEncoding());
return streamReader.ReadToEnd();
}
public static string[] ReadLines(this string Path)
{
return Path.FromText().Replace("\r", "").Split('\n');
}
}

123
2DGAMELIB/_2DGAMELIB/UI.cs Normal file
View File

@@ -0,0 +1,123 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Forms;
namespace _2DGAMELIB;
public class UI : Form
{
private Point Position = Point.Empty;
private Med Med;
private IContainer components;
private WPFImage wpfImage1;
private System.Windows.Controls.Image hostedComponent1;
private string ConfigPath = Directory.GetCurrentDirectory() + "\\Config.ini";
private bool BigWindow;
public UI(Med Med)
{
InitializeComponent();
this.Med = Med;
}
private void UI_Load(object sender, EventArgs e)
{
base.ClientSize = Med.Setting(wpfImage1);
base.ClientSize = new Size(1024, 768);
try
{
if (!File.Exists(ConfigPath))
{
BigWindow = false;
}
else
{
string[] source = ConfigPath.ReadLines();
BigWindow = source.First((string s) => s.StartsWith("BigWindow:")).Last() == '1';
}
}
catch
{
BigWindow = false;
}
if (BigWindow)
{
base.ClientSize = new Size(1280, 960);
}
UI_Resize(null, null);
if (Position == Point.Empty)
{
Position = (Screen.PrimaryScreen.Bounds.Size.ToVector2D() * 0.5 - base.Size.ToVector2D() * 0.5).ToPoint();
}
base.Location = Position;
}
private void UI_FormClosing(object sender, FormClosingEventArgs e)
{
Med.Drive = false;
}
private void UI_Move(object sender, EventArgs e)
{
Position = base.Location;
}
private void UI_Resize(object sender, EventArgs e)
{
wpfImage1.ImageSetting();
wpfImage1.Image.Width = (double)base.ClientSize.Width * Med.DpiX;
wpfImage1.Image.Height = (double)base.ClientSize.Height * Med.DpiY;
}
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(_2DGAMELIB.UI));
this.wpfImage1 = new _2DGAMELIB.WPFImage();
this.hostedComponent1 = new System.Windows.Controls.Image();
base.SuspendLayout();
this.wpfImage1.BackColor = System.Drawing.Color.Black;
this.wpfImage1.Dock = System.Windows.Forms.DockStyle.Fill;
this.wpfImage1.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.wpfImage1.Location = new System.Drawing.Point(0, 0);
this.wpfImage1.Name = "wpfImage1";
this.wpfImage1.Text = "wpfImage1";
this.wpfImage1.TabIndex = 0;
this.wpfImage1.Child = this.hostedComponent1;
this.Text = "UI";
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
base.Controls.Add(this.wpfImage1);
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
base.Name = "UI";
base.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(UI_FormClosing);
base.Load += new System.EventHandler(UI_Load);
base.Move += new System.EventHandler(UI_Move);
base.Resize += new System.EventHandler(UI_Resize);
base.ResumeLayout(false);
}
}

View File

@@ -0,0 +1,67 @@
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

@@ -0,0 +1,126 @@
using System;
using System.Globalization;
namespace _2DGAMELIB;
[Serializable]
public struct Vector2D
{
public double X;
public double Y;
public double this[int index]
{
get
{
return index switch
{
0 => X,
1 => Y,
_ => throw new ArgumentOutOfRangeException("index", "Indices for Vector2D run from 0 to 1, inclusive."),
};
}
set
{
switch (index)
{
case 0:
X = value;
break;
case 1:
Y = value;
break;
default:
throw new ArgumentOutOfRangeException("index", "Indices for Vector2D run from 0 to 1, inclusive.");
}
}
}
public Vector2D(int value)
{
X = value;
Y = value;
}
public Vector2D(float value)
{
X = value;
Y = value;
}
public Vector2D(double value)
{
X = value;
Y = value;
}
public Vector2D(int x, int y)
{
X = x;
Y = y;
}
public Vector2D(float x, float y)
{
X = x;
Y = y;
}
public Vector2D(double x, double y)
{
X = x;
Y = y;
}
public double Length()
{
return System.Math.Sqrt(X * X + Y * Y);
}
public double LengthSquared()
{
return X * X + Y * Y;
}
public void Normalize()
{
double num = Length();
if (num != 0.0)
{
double num2 = 1.0 / num;
X *= num2;
Y *= num2;
}
}
public static Vector2D operator +(Vector2D left, Vector2D right)
{
return new Vector2D(left.X + right.X, left.Y + right.Y);
}
public static Vector2D operator -(Vector2D left, Vector2D right)
{
return new Vector2D(left.X - right.X, left.Y - right.Y);
}
public static Vector2D operator -(Vector2D value)
{
return new Vector2D(0.0 - value.X, 0.0 - value.Y);
}
public static Vector2D operator *(Vector2D value, double scale)
{
return new Vector2D(value.X * scale, value.Y * scale);
}
public static Vector2D operator *(double scale, Vector2D value)
{
return new Vector2D(value.X * scale, value.Y * scale);
}
public static Vector2D operator /(Vector2D value, double scale)
{
return new Vector2D(value.X / scale, value.Y / scale);
}
}

View File

@@ -0,0 +1,23 @@
using System;
namespace _2DGAMELIB;
[Serializable]
public struct Vector2D_2
{
public Vector2D v1;
public Vector2D v2;
public Vector2D_2(Vector2D v1, Vector2D v2)
{
this.v1 = v1;
this.v2 = v2;
}
public Vector2D_2(ref Vector2D v1, ref Vector2D v2)
{
this.v1 = v1;
this.v2 = v2;
}
}

View File

@@ -0,0 +1,189 @@
using System;
using System.Globalization;
namespace _2DGAMELIB;
[Serializable]
public struct Vector3D
{
public double X;
public double Y;
public double Z;
public double this[int index]
{
get
{
return index switch
{
0 => X,
1 => Y,
2 => Z,
_ => throw new ArgumentOutOfRangeException("index", "Indices for Vector3D run from 0 to 2, inclusive."),
};
}
set
{
switch (index)
{
case 0:
X = value;
break;
case 1:
Y = value;
break;
case 2:
Z = value;
break;
default:
throw new ArgumentOutOfRangeException("index", "Indices for Vector3D run from 0 to 2, inclusive.");
}
}
}
public Vector3D(double value)
{
X = value;
Y = value;
Z = value;
}
public Vector3D(Vector2D value, double z)
{
X = value.X;
Y = value.Y;
Z = z;
}
public Vector3D(ref Vector2D value, double z)
{
X = value.X;
Y = value.Y;
Z = z;
}
public Vector3D(double x, double y, double z)
{
X = x;
Y = y;
Z = z;
}
public double Length()
{
return System.Math.Sqrt(X * X + Y * Y + Z * Z);
}
public double LengthSquared()
{
return X * X + Y * Y + Z * Z;
}
public void Normalize()
{
double num = Length();
if (num != 0.0)
{
double num2 = 1.0 / num;
X *= num2;
Y *= num2;
Z *= num2;
}
}
public static Vector3D operator +(Vector3D left, Vector3D right)
{
return new Vector3D(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
}
public static Vector3D operator -(Vector3D left, Vector3D right)
{
return new Vector3D(left.X - right.X, left.Y - right.Y, left.Z - right.Z);
}
public static Vector3D operator -(Vector3D value)
{
return new Vector3D(0.0 - value.X, 0.0 - value.Y, 0.0 - value.Z);
}
public static Vector3D operator *(Vector3D value, double scale)
{
return new Vector3D(value.X * scale, value.Y * scale, value.Z * scale);
}
public static Vector3D operator *(double scale, Vector3D value)
{
return new Vector3D(value.X * scale, value.Y * scale, value.Z * scale);
}
public static Vector3D operator /(Vector3D value, double scale)
{
return new Vector3D(value.X / scale, value.Y / scale, value.Z / scale);
}
public static bool operator ==(Vector3D left, Vector3D right)
{
if (left.X == right.X && left.Y == right.Y)
{
return left.Z == right.Z;
}
return false;
}
public static bool operator !=(Vector3D left, Vector3D right)
{
if (left.X == right.X && left.Y == right.Y)
{
return left.Z != right.Z;
}
return true;
}
public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "X:{0} Y:{1} Z:{2}", new object[3]
{
X.ToString(CultureInfo.CurrentCulture),
Y.ToString(CultureInfo.CurrentCulture),
Z.ToString(CultureInfo.CurrentCulture)
});
}
public override int GetHashCode()
{
return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode();
}
public override bool Equals(object value)
{
if (value == null)
{
return false;
}
if (value.GetType() != GetType())
{
return false;
}
return Equals((Vector3D)value);
}
public bool Equals(Vector3D value)
{
if (X == value.X && Y == value.Y)
{
return Z == value.Z;
}
return false;
}
public bool Equals(ref Vector3D value)
{
if (X == value.X && Y == value.Y)
{
return Z == value.Z;
}
return false;
}
}

View File

@@ -0,0 +1,211 @@
using System;
using System.Globalization;
namespace _2DGAMELIB;
[Serializable]
public struct Vector4D
{
public double X;
public double Y;
public double Z;
public double W;
public double this[int index]
{
get
{
return index switch
{
0 => X,
1 => Y,
2 => Z,
3 => W,
_ => throw new ArgumentOutOfRangeException("index", "Indices for Vector4D run from 0 to 3, inclusive."),
};
}
set
{
switch (index)
{
case 0:
X = value;
break;
case 1:
Y = value;
break;
case 2:
Z = value;
break;
case 3:
W = value;
break;
default:
throw new ArgumentOutOfRangeException("index", "Indices for Vector4D run from 0 to 3, inclusive.");
}
}
}
public Vector4D(double value)
{
X = value;
Y = value;
Z = value;
W = value;
}
public Vector4D(Vector2D value, double z, double w)
{
X = value.X;
Y = value.Y;
Z = z;
W = w;
}
public Vector4D(ref Vector2D value, double z, double w)
{
X = value.X;
Y = value.Y;
Z = z;
W = w;
}
public Vector4D(Vector3D value, double w)
{
X = value.X;
Y = value.Y;
Z = value.Z;
W = w;
}
public Vector4D(ref Vector3D value, double w)
{
X = value.X;
Y = value.Y;
Z = value.Z;
W = w;
}
public Vector4D(double x, double y, double z, double w)
{
X = x;
Y = y;
Z = z;
W = w;
}
public double Length()
{
return System.Math.Sqrt(X * X + Y * Y + Z * Z + W * W);
}
public double LengthSquared()
{
return X * X + Y * Y + Z * Z + W * W;
}
public void Normalize()
{
double num = Length();
if (num != 0.0)
{
double num2 = 1.0 / num;
X *= num2;
Y *= num2;
Z *= num2;
W *= num2;
}
}
public static Vector4D operator +(Vector4D left, Vector4D right)
{
return new Vector4D(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
}
public static Vector4D operator -(Vector4D left, Vector4D right)
{
return new Vector4D(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
}
public static Vector4D operator -(Vector4D value)
{
return new Vector4D(0.0 - value.X, 0.0 - value.Y, 0.0 - value.Z, 0.0 - value.W);
}
public static Vector4D operator *(Vector4D value, double scale)
{
return new Vector4D(value.X * scale, value.Y * scale, value.Z * scale, value.W * scale);
}
public static Vector4D operator *(double scale, Vector4D value)
{
return new Vector4D(value.X * scale, value.Y * scale, value.Z * scale, value.W * scale);
}
public static Vector4D operator /(Vector4D value, double scale)
{
return new Vector4D(value.X / scale, value.Y / scale, value.Z / scale, value.W / scale);
}
public static bool operator ==(Vector4D left, Vector4D right)
{
if (left.X == right.X && left.Y == right.Y && left.Z == right.Z)
{
return left.W == right.W;
}
return false;
}
public static bool operator !=(Vector4D left, Vector4D right)
{
if (left.X == right.X && left.Y == right.Y && left.Z == right.Z)
{
return left.W != right.W;
}
return true;
}
public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "X:{0} Y:{1} Z:{2} W:{3}", X.ToString(CultureInfo.CurrentCulture), Y.ToString(CultureInfo.CurrentCulture), Z.ToString(CultureInfo.CurrentCulture), W.ToString(CultureInfo.CurrentCulture));
}
public override int GetHashCode()
{
return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode();
}
public override bool Equals(object value)
{
if (value == null)
{
return false;
}
if (value.GetType() != GetType())
{
return false;
}
return Equals((Vector4D)value);
}
public bool Equals(Vector4D value)
{
if (X == value.X && Y == value.Y && Z == value.Z)
{
return W == value.W;
}
return false;
}
public bool Equals(ref Vector4D value)
{
if (X == value.X && Y == value.Y && Z == value.Z)
{
return W == value.W;
}
return false;
}
}

View File

@@ -0,0 +1,97 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms.Integration;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace _2DGAMELIB;
public class WPFImage : ElementHost
{
private int ByteSize;
private Rectangle rect1;
private Int32Rect rect2;
private BitmapData data;
public WriteableBitmap wb;
private bool HighQuality;
private string ConfigPath = Directory.GetCurrentDirectory() + "\\Config.ini";
public System.Windows.Controls.Image Image => (System.Windows.Controls.Image)base.Child;
public WPFImage()
{
System.Windows.Controls.Image child = new System.Windows.Controls.Image
{
Stretch = Stretch.Uniform
};
base.Child = child;
}
public void ImageSetting()
{
try
{
if (!File.Exists(ConfigPath))
{
HighQuality = false;
}
else
{
string[] source = ConfigPath.ReadLines();
HighQuality = source.First((string s) => s.StartsWith("AntiAliasing:")).Last() == '1';
}
}
catch
{
HighQuality = false;
}
if (HighQuality)
{
RenderOptions.SetBitmapScalingMode(Image, BitmapScalingMode.LowQuality);
}
else
{
RenderOptions.SetBitmapScalingMode(Image, BitmapScalingMode.NearestNeighbor);
}
RenderOptions.SetEdgeMode(Image, EdgeMode.Aliased);
}
[DllImport("Kernel32.dll")]
public static extern void CopyMemory(IntPtr Destination, IntPtr Source, int ByteSize);
//the guy that gets called to update a frame
public void SetBitmap(Bitmap bmp)
{
data = bmp.LockBits(rect1, ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
wb.Lock();
CopyMemory(wb.BackBuffer, data.Scan0, ByteSize);
wb.AddDirtyRect(rect2);
wb.Unlock();
bmp.UnlockBits(data);
}
public void BitmapSetting(Bitmap bmp)
{
int pixelWidth = bmp.Width;
int num = bmp.Height;
rect1 = new Rectangle(0, 0, pixelWidth, num);
rect2 = new Int32Rect(0, 0, pixelWidth, num);
wb = new WriteableBitmap(pixelWidth, num, bmp.HorizontalResolution, bmp.VerticalResolution, PixelFormats.Bgra32, null);
ByteSize = wb.BackBufferStride * num;
Image.Source = wb;
}
}

View File

@@ -0,0 +1,66 @@
using System.Drawing;
namespace _2DGAMELIB;
public static class _Con
{
public static Vector2D ToVector2D(this Point Point)
{
return new Vector2D(Point.X, Point.Y);
}
public static Point ToPoint(this Vector2D Vector)
{
return new Point((int)Vector.X, (int)Vector.Y);
}
public static Point ToPoint(ref Vector2D Vector)
{
return new Point((int)Vector.X, (int)Vector.Y);
}
public static Vector2D ToVector2D(this PointF Point)
{
return new Vector2D(Point.X, Point.Y);
}
public static PointF ToPointF(this Vector2D Vector)
{
return new PointF((float)Vector.X, (float)Vector.Y);
}
public static PointF ToPointF(ref Vector2D Vector)
{
return new PointF((float)Vector.X, (float)Vector.Y);
}
public static Vector2D ToVector2D(this Size Size)
{
return new Vector2D(Size.Width, Size.Height);
}
public static Size ToSize(this Vector2D Vector)
{
return new Size((int)Vector.X, (int)Vector.Y);
}
public static Size ToSize(ref Vector2D Vector)
{
return new Size((int)Vector.X, (int)Vector.Y);
}
public static Vector2D ToVector2D(this SizeF Size)
{
return new Vector2D(Size.Width, Size.Height);
}
public static SizeF ToSizeF(this Vector2D Vector)
{
return new SizeF((float)Vector.X, (float)Vector.Y);
}
public static SizeF ToSizeF(ref Vector2D Vector)
{
return new SizeF((float)Vector.X, (float)Vector.Y);
}
}