no more windows??

This commit is contained in:
lewd-alt
2025-05-07 10:45:18 -07:00
parent eecd2a0399
commit 9d89d2cb6a
933 changed files with 408908 additions and 407973 deletions

View File

@@ -9,7 +9,7 @@
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup>
<LangVersion>10.0</LangVersion>
<LangVersion>9.0</LangVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,200 +2,201 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace _2DGAMELIB;
public class Are : Rect
namespace _2DGAMELIB
{
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)
public class Are : Rect
{
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);
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;
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();
}
}
}
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

@@ -1,84 +1,85 @@
using System.Drawing;
using System.Drawing.Drawing2D;
namespace _2DGAMELIB;
public class AreM : Are
namespace _2DGAMELIB
{
private double strength;
public class AreM : Are
{
private double strength;
private double unitS;
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);
}
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;
}
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(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(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;
}
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;
}
}
}

View File

@@ -1,166 +1,167 @@
using System;
using System.Drawing;
namespace _2DGAMELIB;
public class But
namespace _2DGAMELIB
{
private bool dra = true;
public class But
{
private bool dra = true;
private Color hc = Color.Transparent;
private Color hc = Color.Transparent;
protected Pars pars;
protected Pars pars;
protected Action<But> Over = delegate
{
};
protected Action<But> Over = delegate
{
};
protected Action<But> Push = delegate
{
};
protected Action<But> Push = delegate
{
};
protected Action<But> Release = delegate
{
};
protected Action<But> Release = delegate
{
};
protected Action<But> Out = delegate
{
};
protected Action<But> Out = delegate
{
};
public Action<But> Action = delegate
{
};
public Action<But> Action = delegate
{
};
private bool f1;
private bool f1;
private bool f2;
private bool f2;
public bool Dra
{
get
{
return dra;
}
set
{
Move(ref hc);
dra = value;
}
}
public bool Dra
{
get
{
return dra;
}
set
{
Move(ref hc);
dra = value;
}
}
public Pars Pars => pars;
public Pars Pars => pars;
public But(Par Par, Action<But> Action)
{
pars = new Pars(Par);
this.Action = Action;
}
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(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 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 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 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 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 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(Are Are)
{
if (dra)
{
Are.Draw(pars);
}
}
public void Draw(AreM AreM)
{
if (dra)
{
AreM.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 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 void Dispose()
{
pars.Dispose();
}
public bool IsBut1()
{
return this is But1;
}
public bool IsBut1()
{
return this is But1;
}
public But1 ToBut1()
{
return (But1)this;
}
public But1 ToBut1()
{
return (But1)this;
}
}
}

View File

@@ -3,108 +3,109 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace _2DGAMELIB;
public class But1 : But
namespace _2DGAMELIB
{
public List<Color> BaseColors = new List<Color>();
public class But1 : But
{
public List<Color> BaseColors = new List<Color>();
public List<Color> OverColors = new List<Color>();
public List<Color> OverColors = new List<Color>();
public List<Color> PushColors = new List<Color>();
public List<Color> PushColors = new List<Color>();
public List<Color> TextColors = new List<Color>();
public List<Color> TextColors = new List<Color>();
public But1(Par Par, Action<But> Action)
: base(Par, Action)
{
Setting();
}
public But1(Par Par, Action<But> Action)
: base(Par, Action)
{
Setting();
}
public But1(ParT ParT, Action<But> Action)
: base(ParT, Action)
{
Setting();
}
public But1(ParT ParT, Action<But> Action)
: base(ParT, Action)
{
Setting();
}
public But1(Pars Pars, Action<But> Action)
: base(Pars, 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++;
}
};
}
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

@@ -2,87 +2,88 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace _2DGAMELIB;
public class Buts
namespace _2DGAMELIB
{
private OrderedDictionary<string, But> buts = new OrderedDictionary<string, But>();
public class Buts
{
private OrderedDictionary<string, But> buts = new OrderedDictionary<string, But>();
public But this[string Name] => buts[Name];
public But this[string Name] => buts[Name];
public IEnumerable<But> EnumBut => buts.Values;
public IEnumerable<But> EnumBut => buts.Values;
public void Add(string Name, But But)
{
buts.Add(Name, But);
}
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 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 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 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 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 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(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 Draw(AreM AreM)
{
foreach (But value in buts.Values)
{
value.Draw(AreM);
}
}
public void Dispose()
{
foreach (But value in buts.Values)
{
value.Dispose();
}
}
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);
}
public bool IsHit(Color hc)
{
return EnumBut.Any((But e) => e.Pars.Values.First().ToPar().HitColor == hc);
}
}
}

View File

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

View File

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

View File

@@ -2,289 +2,290 @@ using System;
using System.Collections.Generic;
using System.Drawing;
namespace _2DGAMELIB;
[Serializable]
public class Dif
namespace _2DGAMELIB
{
public string Tag = "";
[Serializable]
public class Dif
{
public string Tag = "";
private List<Pars> parss = new List<Pars>();
private List<Pars> parss = new List<Pars>();
public List<Pars> Parss => parss;
public List<Pars> Parss => parss;
public int Count => parss.Count;
public int Count => parss.Count;
public Pars this[int Index]
{
get
{
return parss[Index];
}
set
{
parss[Index] = value;
}
}
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 double PositionSize
{
set
{
foreach (Pars item in parss)
{
item.PositionSize = value;
}
}
}
public Vector2D PositionVector
{
set
{
foreach (Pars item in parss)
{
item.PositionVector = 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 AngleBase
{
set
{
foreach (Pars item in parss)
{
item.AngleBase = value;
}
}
}
public double AngleCont
{
set
{
foreach (Pars item in parss)
{
item.AngleCont = 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 SizeBase
{
set
{
foreach (Pars item in parss)
{
item.SizeBase = value;
}
}
}
public double SizeCont
{
set
{
foreach (Pars item in parss)
{
item.SizeCont = 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 SizeXBase
{
set
{
foreach (Pars item in parss)
{
item.SizeXBase = value;
}
}
}
public double SizeXCont
{
set
{
foreach (Pars item in parss)
{
item.SizeXCont = 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 SizeYBase
{
set
{
foreach (Pars item in parss)
{
item.SizeYBase = value;
}
}
}
public double SizeYCont
{
set
{
foreach (Pars item in parss)
{
item.SizeYCont = 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 Dra
{
set
{
foreach (Pars item in parss)
{
item.Dra = value;
}
}
}
public bool Hit
{
set
{
foreach (Pars item in parss)
{
item.Hit = 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 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 void SetDefault()
{
foreach (Pars item in parss)
{
item.SetDefault();
}
}
public Dif()
{
}
public Dif()
{
}
public Dif(Dif Dif)
{
Copy(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));
}
}
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 Add(Pars Pars)
{
parss.Add(Pars);
}
public void Insert(int Index, Pars Pars)
{
parss.Insert(Index, Pars);
}
public void Insert(int Index, Pars Pars)
{
parss.Insert(Index, Pars);
}
public void Remove(Pars Pars)
{
parss.Remove(Pars);
}
public void Remove(Pars Pars)
{
parss.Remove(Pars);
}
public void RemoveAt(int Index)
{
parss.RemoveAt(Index);
}
public void RemoveAt(int Index)
{
parss.RemoveAt(Index);
}
public void Draws(Are Are)
{
foreach (Pars item in parss)
{
Are.Draw(item);
}
}
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 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<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 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 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 ReverseX()
{
foreach (Pars item in parss)
{
item.ReverseX();
}
}
public void ReverseY()
{
foreach (Pars item in parss)
{
item.ReverseY();
}
}
public void ReverseY()
{
foreach (Pars item in parss)
{
item.ReverseY();
}
}
public void Dispose()
{
foreach (Pars item in parss)
{
item.Dispose();
}
}
public void Dispose()
{
foreach (Pars item in parss)
{
item.Dispose();
}
}
}
}

View File

@@ -4,471 +4,472 @@ using System.Drawing;
using System.Linq;
using Newtonsoft.Json;
namespace _2DGAMELIB;
[Serializable]
public class Difs
namespace _2DGAMELIB
{
public string Tag = "";
[Serializable]
public class Difs
{
public string Tag = "";
public double ValueX;
public double ValueX;
public double ValueY;
public double ValueY;
private List<Dif> difs = new List<Dif>();
private List<Dif> difs = new List<Dif>();
public Dictionary<Pars, Joints> pj;
public Dictionary<Pars, Joints> pj;
public Dictionary<Pars, Par> pr;
public Dictionary<Pars, Par> pr;
public List<Dif> Difss => difs;
public List<Dif> Difss => difs;
public int CountX => difs.Count;
public int CountX => difs.Count;
public int CountY
{
get
{
if (difs.Count > 0)
{
return difs[IndexX].Count;
}
return 0;
}
}
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 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 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 Dif this[int Index]
{
get
{
return difs[Index];
}
set
{
difs[Index] = value;
}
}
public Pars Current => difs[IndexX][IndexY];
public Pars Current => difs[IndexX][IndexY];
public double PositionSize
{
set
{
foreach (Dif dif in difs)
{
dif.PositionSize = value;
}
}
}
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 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 AngleBase
{
set
{
foreach (Dif dif in difs)
{
dif.AngleBase = value;
}
}
}
public double AngleCont
{
set
{
foreach (Dif dif in difs)
{
dif.AngleCont = 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 SizeBase
{
set
{
foreach (Dif dif in difs)
{
dif.SizeBase = value;
}
}
}
public double SizeCont
{
set
{
foreach (Dif dif in difs)
{
dif.SizeCont = 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 SizeXBase
{
set
{
foreach (Dif dif in difs)
{
dif.SizeXBase = value;
}
}
}
public double SizeXCont
{
set
{
foreach (Dif dif in difs)
{
dif.SizeXCont = 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 SizeYBase
{
set
{
foreach (Dif dif in difs)
{
dif.SizeYBase = value;
}
}
}
public double SizeYCont
{
set
{
foreach (Dif dif in difs)
{
dif.SizeYCont = 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 Dra
{
set
{
foreach (Dif dif in difs)
{
dif.Dra = value;
}
}
}
public bool Hit
{
set
{
foreach (Dif dif in difs)
{
dif.Hit = 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 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;
}
}
}
[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 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 void SetDefault()
{
foreach (Dif dif in difs)
{
dif.SetDefault();
}
}
public Difs()
{
}
public Difs()
{
}
public Difs(Difs Difs)
{
Copy(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));
}
}
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 Add(Dif Dif)
{
difs.Add(Dif);
}
public void Insert(int Index, Dif Dif)
{
difs.Insert(Index, Dif);
}
public void Insert(int Index, Dif Dif)
{
difs.Insert(Index, Dif);
}
public void Remove(Dif Dif)
{
difs.Remove(Dif);
}
public void Remove(Dif Dif)
{
difs.Remove(Dif);
}
public void RemoveAt(int Index)
{
difs.RemoveAt(Index);
}
public void RemoveAt(int Index)
{
difs.RemoveAt(Index);
}
public void Draw(Are Are)
{
Are.Draw(Current);
}
public void Draw(Are Are)
{
Are.Draw(Current);
}
public void Draws(Are Are)
{
foreach (Dif dif in difs)
{
dif.Draws(Are);
}
}
public void Draws(Are Are)
{
foreach (Dif dif in difs)
{
dif.Draws(Are);
}
}
public void Draw(AreM AreM)
{
AreM.Draw(Current);
}
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 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 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 JoinP()
{
pj[Current].JoinP();
}
public void JoinPA()
{
pj[Current].JoinPA();
}
public void JoinPA()
{
pj[Current].JoinPA();
}
public void JoinPall()
{
foreach (Joints value in pj.Values)
{
value.JoinP();
}
}
public void JoinPall()
{
foreach (Joints value in pj.Values)
{
value.JoinP();
}
}
public void JoinPAall()
{
foreach (Joints value in pj.Values)
{
value.JoinPA();
}
}
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 JoinP(Pars ps)
{
if (pj.ContainsKey(ps))
{
pj[ps].JoinP();
}
}
public void JoinPA(Pars ps)
{
if (pj.ContainsKey(ps))
{
pj[ps].JoinPA();
}
}
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 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<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 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 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 ReverseX()
{
SetJoints();
foreach (Dif dif in difs)
{
dif.ReverseX();
}
JoinP();
}
public void ReverseY()
{
SetJoints();
foreach (Dif dif in difs)
{
dif.ReverseY();
}
JoinP();
}
public void ReverseY()
{
SetJoints();
foreach (Dif dif in difs)
{
dif.ReverseY();
}
JoinP();
}
public void Dispose()
{
foreach (Dif dif in difs)
{
dif.Dispose();
}
}
public void Dispose()
{
foreach (Dif dif in difs)
{
dif.Dispose();
}
}
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -1,306 +1,307 @@
using System.Drawing;
namespace _2DGAMELIB;
public static class HSV
namespace _2DGAMELIB
{
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 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 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(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 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, 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(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(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 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(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(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 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(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);
}
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 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;
}
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

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

View File

@@ -2,195 +2,196 @@ using System;
using System.Collections.Generic;
using System.Linq;
namespace _2DGAMELIB;
public static class Join
namespace _2DGAMELIB
{
public static double IdentityDistance = System.Math.Pow(5E-05, 2.0);
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;
}
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;
}
}
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;
}
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;
}
}
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

@@ -1,30 +1,31 @@
using System;
namespace _2DGAMELIB;
[Serializable]
public class Joint
namespace _2DGAMELIB
{
public Par Par0;
[Serializable]
public class Joint
{
public Par Par0;
public int Index;
public int Index;
public Par Par1;
public Par Par1;
public Joint(Par Par0, int Index, Par Par1)
{
this.Par0 = Par0;
this.Index = Index;
this.Par1 = 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 JoinP()
{
Par0.SetJointP(Index, Par1);
}
public void JoinPA()
{
Par0.SetJointPA(Index, Par1);
}
public void JoinPA()
{
Par0.SetJointPA(Index, Par1);
}
}
}

View File

@@ -1,72 +1,73 @@
using System;
using System.Collections.Generic;
namespace _2DGAMELIB;
[Serializable]
public class JointD
namespace _2DGAMELIB
{
public Difs Difs0;
[Serializable]
public class JointD
{
public Difs Difs0;
public List<int> Path0;
public List<int> Path0;
public int Index;
public int Index;
public Difs Difs1;
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 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 JointD(Difs Difs1)
{
this.Difs1 = Difs1;
}
public void JoinP()
{
Difs0.Current.GetPar(Path0).SetJointP(Index, Difs1.CurJoinRoot);
Difs1.JoinPA();
}
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 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 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 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;
}
public void Set(JointS )
{
Difs0 = .Difs;
Path0 = .Path;
Index = .Index;
}
}
}

View File

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

View File

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

View File

@@ -1,181 +1,182 @@
using System;
using System.Drawing;
namespace _2DGAMELIB;
public class Lab
namespace _2DGAMELIB
{
private ParT parT;
public class Lab
{
private ParT parT;
private Med Med;
private Med Med;
private Are Are;
private Are Are;
private double Width;
private double Width;
private bool Input;
private bool Input;
private double Min;
private double Min;
public ParT ParT => parT;
public ParT ParT => parT;
public string Text
{
get
{
return parT.Text;
}
set
{
public string Text
{
get
{
return parT.Text;
}
set
{
//TODO fix?
//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)
{
//Note: Input is always false
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;
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)
{
//TODO fix?
//if (!Med.BaseControl.Contains(tb))
{
SetText(value);
}
}
}
//Med.BaseControl.Controls.Remove(tb);
//SetText(tb.Text);
}
private void SetText(string Text)
{
parT.Text = Text;
SetRect();
}
public void SetHitColor(Med Med)
{
if (parT.HitColor != Color.Transparent)
{
Med.RemUniqueColor(parT.HitColor);
}
parT.HitColor = Med.GetUniqueColor();
}
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)
{
//Note: Input is always false
Setting(Med, Are, Name, ref Position, Size, Width, Font, TextSize, Text, ref TextColor, ref ShadColor, ref BackColor, ref FramColor, Input);
}
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);
}
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 SetRectT()
{
/*
double resMag = Med.ResMag;
Vector2D vector2D = (parT.Position + Are.GetPosition()) * Med.Unit / resMag + Med.ResVector;
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;
tb.Location = new Point((int)vector2D.X - 1, (int)vector2D.Y - 1);
double num = parT.Size * Med.Unit;
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);
}
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));*/
}
private void Lab_Resize(object sender, EventArgs e)
{
//TODO fix?
//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)
{
//TODO fix?
//if (Input && parT.HitColor == HitColor && !Med.BaseControl.Controls.Contains(tb))
/*{
tb.Text = parT.Text;
parT.Text = "";
SetRectT();
//Med.BaseControl.Controls.Add(tb);
tb.SelectAll();
tb.Focus();
tb.BringToFront();
return true;
}*/
return false;
}
public void Click(ref Color HitColor)
{
//TODO fix?
/*if (Input && parT.HitColor != HitColor && Med.BaseControl.Controls.Contains(tb))
{
//Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
}*/
}
public void Dispose()
{
parT.Dispose();
if (Input)
{
public bool Double(ref Color HitColor)
{
//TODO fix?
//((Control)Med.BaseControl).Resize -= Lab_Resize;
}
}
//if (Input && parT.HitColor == HitColor && !Med.BaseControl.Controls.Contains(tb))
/*{
tb.Text = parT.Text;
parT.Text = "";
SetRectT();
//Med.BaseControl.Controls.Add(tb);
tb.SelectAll();
tb.Focus();
tb.BringToFront();
return true;
}*/
return false;
}
public void Click(ref Color HitColor)
{
//TODO fix?
/*if (Input && parT.HitColor != HitColor && Med.BaseControl.Controls.Contains(tb))
{
//Med.BaseControl.Controls.Remove(tb);
SetText(tb.Text);
}*/
}
public void Dispose()
{
parT.Dispose();
if (Input)
{
//TODO fix?
//((Control)Med.BaseControl).Resize -= Lab_Resize;
}
}
}
}

View File

@@ -1,79 +1,80 @@
using System.Collections.Generic;
using System.Drawing;
namespace _2DGAMELIB;
public class Labs
namespace _2DGAMELIB
{
private OrderedDictionary<string, Lab> labs = new OrderedDictionary<string, Lab>();
public class Labs
{
private OrderedDictionary<string, Lab> labs = new OrderedDictionary<string, Lab>();
private Med Med;
private Med Med;
private Are Are;
private Are Are;
public Lab this[string Name] => labs[Name];
public Lab this[string Name] => labs[Name];
public Labs(Med Med, Are Are)
{
this.Med = Med;
this.Are = Are;
}
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, 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 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 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 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 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(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 Draw(AreM AreM)
{
foreach (Lab value in labs.Values)
{
AreM.Draw(value.ParT);
}
}
public void Dispose()
{
foreach (Lab value in labs.Values)
{
value.Dispose();
}
}
public void Dispose()
{
foreach (Lab value in labs.Values)
{
value.Dispose();
}
}
}
}

View File

@@ -1,98 +1,99 @@
using System;
namespace _2DGAMELIB;
//TODO remove these...
public static class Math
namespace _2DGAMELIB
{
public static double RoundDown(this double Value, int Digits)
//TODO remove these...
public static class Math
{
double num = System.Math.Pow(10.0, Digits);
if (!(Value > 0.0))
public static double RoundDown(this double Value, int Digits)
{
return System.Math.Ceiling(Value * num) / num;
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;
}
return System.Math.Floor(Value * num) / num;
}
public static double Inverse(this double Rate)
{
if (Rate == 0.0)
public static double Inverse(this double Rate)
{
return 1.0;
if (Rate == 0.0)
{
return 1.0;
}
return (double)System.Math.Sign(Rate) - Rate;
}
return (double)System.Math.Sign(Rate) - Rate;
}
public static double Reciprocal(this double Rate)
{
if (Rate == 0.0)
public static double Reciprocal(this double Rate)
{
return 1.0;
if (Rate == 0.0)
{
return 1.0;
}
return 1.0 / Rate;
}
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));
}
}
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

@@ -1,154 +1,155 @@
using System;
namespace _2DGAMELIB;
public static class Matrix
namespace _2DGAMELIB
{
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 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 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(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 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(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 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, 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 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, 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 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(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 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(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);
}
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);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,465 +5,466 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
namespace _2DGAMELIB;
public class Med
namespace _2DGAMELIB
{
public static object obj;
public class Med
{
public static object obj;
private GlImage baseControl;
private GlImage baseControl;
public double Unit = 1762.4;
public double Unit = 1762.4;
public Rect Base = new Rect(4.0, 3.0, 0.4);
public Rect Base = new Rect(4.0, 3.0, 0.4);
public double DisQuality = 1.0;
public double DisQuality = 1.0;
public double HitAccuracy = 0.5;
public double HitAccuracy = 0.5;
public Bitmap BD;
public Bitmap BD;
public Graphics GD;
public Graphics GD;
public Bitmap BH;
public Bitmap BH;
public Graphics GH;
public Graphics GH;
private Color ClearColor = Color.Transparent;
private Color ClearColor = Color.Transparent;
public bool Drive = true;
public bool Drive = true;
private Size BaseSize = Size.Empty;
private Size BaseSize = Size.Empty;
private double resMag = 1.0;
private double resMag = 1.0;
private Vector2D resVector = Dat.Vec2DZero;
private Vector2D resVector = Dat.Vec2DZero;
private Sce Sce;
private Sce Sce;
private string mode;
private string mode;
public string Modeb;
public string Modeb;
private Dictionary<string, Module> Modes;
private Dictionary<string, Module> Modes;
private Func<Med, Dictionary<string, Module>> GetModes;
private Func<Med, Dictionary<string, Module>> GetModes;
private int WidthM;
private int WidthM;
private int HeightM;
private int HeightM;
public static double FPS;
public static double FPS;
public FPS FPSF = new FPS(FPS);
public FPS FPSF = new FPS(FPS);
private bool cur = true;
private bool cur = true;
public HashSet<Color> HitColors = new HashSet<Color>
{
Color.Transparent,
Color.Black
};
public HashSet<Color> HitColors = new HashSet<Color>
{
Color.Transparent,
Color.Black
};
private const int LOGPIXELSX = 88;
private const int LOGPIXELSX = 88;
private const int LOGPIXELSY = 90;
private const int LOGPIXELSY = 90;
public static double dpiX;
public static double dpiX;
public static double dpiY;
public static double dpiY;
public static double DpiX;
public static double DpiX;
public static double DpiY;
public static double DpiY;
public string UITitle;
public string UITitle;
public bool ShowFPS;
public bool ShowFPS;
//public Control BaseControlC => baseControl;
//public Control BaseControlC => baseControl;
public GlImage BaseControl => baseControl;
public GlImage BaseControl => baseControl;
public double ResMag => resMag;
public double ResMag => resMag;
public Vector2D ResVector => resVector;
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 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.GetCursorPoint()); //ToBasePosition(baseControl.PointToClient(System.Windows.Forms.Cursor.Position));
public Vector2D CursorPosition => ToBasePosition(baseControl.GetCursorPoint()); //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 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 FadeIn(double Rate)
{
Sce.TransformAlpha(GD, Rate);
}
public void FadeOut(double Rate)
{
Sce.TransD(GD, Rate);
}
public void FadeOut(double Rate)
{
Sce.TransD(GD, Rate);
}
public void DrawStart(Are Are)
{
Sce.DrawStart(Are);
}
public void DrawStart(Are Are)
{
Sce.DrawStart(Are);
}
public void DrawEnd(Are Are)
{
Sce.DrawEnd(Are);
}
public void DrawEnd(Are Are)
{
Sce.DrawEnd(Are);
}
public void ClearSta(Color ClearColor)
{
Sce.ClearStart(ref ClearColor);
}
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 void InitializeModes(string Mode, Func<Med, Dictionary<string, Module>> GetModes)
{
mode = Mode;
this.GetModes = GetModes;
}
public Size Setting(GlImage 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);
public Size Setting(GlImage 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.Click = delegate (IntPtr window, GLFW.MouseButton button, InputState state, GLFW.ModifierKeys modifiers)
{
double x, y;
Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
Point Position5 = new Point((int)x, (int)y);
MouseButtons arg2 = MouseButtons.None;
switch (button)
BaseControl.Click = delegate (IntPtr window, GLFW.MouseButton button, InputState state, GLFW.ModifierKeys modifiers)
{
case GLFW.MouseButton.Left:
arg2 = MouseButtons.Left;
break;
case GLFW.MouseButton.Middle:
arg2 = MouseButtons.Middle;
break;
case GLFW.MouseButton.Right:
arg2 = MouseButtons.Right;
break;
case GLFW.MouseButton.Button4:
arg2 = MouseButtons.Button4;
break;
case GLFW.MouseButton.Button5:
arg2 = MouseButtons.Button5;
break;
}
(state == InputState.Press ? Modes[mode].Down : Modes[mode].Up)(arg2, ToBasePosition(Position5), GetHitColor(ref Position5));
};
BaseControl.Move = delegate (IntPtr window, double x, double y)
{
Point Position3 = new Point((int)x, (int)y);
Modes[mode].Move(BaseControl.GetMouseButtons(), ToBasePosition(Position3), GetHitColor(ref Position3));
};
BaseControl.Leave = delegate (IntPtr window, bool entered)
{
if (!entered)
{
double x, y;
Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
Point Position2 = new Point((int)x, (int)y);
Modes[mode].Leave(BaseControl.GetMouseButtons(), ToBasePosition(Position2), GetHitColor(ref Position2));
}
};
BaseControl.Scroll = delegate (IntPtr window, double xo, double yo)
{
double x, y;
Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
Point Position = new Point((int)x, (int)y);
//Note: yo may be inverted
Modes[mode].Wheel(BaseControl.GetMouseButtons(), ToBasePosition(Position), (int)yo, GetHitColor(ref Position));
};
BaseControl.Resize = delegate (IntPtr window, int width, int height)
{
//TODO mess with viewport
if (BaseSize.Width >= BaseSize.Height)
{
double num = (double)BaseSize.Width / (double)BaseSize.Height;
if ((double)width / (double)height <= num)
double x, y;
Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
Point Position5 = new Point((int)x, (int)y);
MouseButtons arg2 = MouseButtons.None;
switch (button)
{
resMag = (double)BaseSize.Width / (double)width;
resVector.X = 0.0;
resVector.Y = ((double)height - (double)BaseSize.Height / resMag) * 0.5;
case GLFW.MouseButton.Left:
arg2 = MouseButtons.Left;
break;
case GLFW.MouseButton.Middle:
arg2 = MouseButtons.Middle;
break;
case GLFW.MouseButton.Right:
arg2 = MouseButtons.Right;
break;
case GLFW.MouseButton.Button4:
arg2 = MouseButtons.Button4;
break;
case GLFW.MouseButton.Button5:
arg2 = MouseButtons.Button5;
break;
}
(state == InputState.Press ? Modes[mode].Down : Modes[mode].Up)(arg2, ToBasePosition(Position5), GetHitColor(ref Position5));
};
BaseControl.Move = delegate (IntPtr window, double x, double y)
{
Point Position3 = new Point((int)x, (int)y);
Modes[mode].Move(BaseControl.GetMouseButtons(), ToBasePosition(Position3), GetHitColor(ref Position3));
};
BaseControl.Leave = delegate (IntPtr window, bool entered)
{
if (!entered)
{
double x, y;
Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
Point Position2 = new Point((int)x, (int)y);
Modes[mode].Leave(BaseControl.GetMouseButtons(), ToBasePosition(Position2), GetHitColor(ref Position2));
}
};
BaseControl.Scroll = delegate (IntPtr window, double xo, double yo)
{
double x, y;
Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
Point Position = new Point((int)x, (int)y);
//Note: yo may be inverted
Modes[mode].Wheel(BaseControl.GetMouseButtons(), ToBasePosition(Position), (int)yo, GetHitColor(ref Position));
};
BaseControl.Resize = delegate (IntPtr window, int width, int height)
{
//TODO mess with viewport
if (BaseSize.Width >= BaseSize.Height)
{
double num = (double)BaseSize.Width / (double)BaseSize.Height;
if ((double)width / (double)height <= num)
{
resMag = (double)BaseSize.Width / (double)width;
resVector.X = 0.0;
resVector.Y = ((double)height - (double)BaseSize.Height / resMag) * 0.5;
}
else
{
resMag = (double)BaseSize.Height / (double)height;
resVector.X = ((double)width - (double)BaseSize.Width / resMag) * 0.5;
resVector.Y = 0.0;
}
}
else
{
resMag = (double)BaseSize.Height / (double)height;
resVector.X = ((double)width - (double)BaseSize.Width / resMag) * 0.5;
resVector.Y = 0.0;
double num2 = (double)BaseSize.Height / (double)BaseSize.Width;
if ((double)height / (double)width <= num2)
{
resMag = (double)BaseSize.Height / (double)height;
resVector.X = ((double)width - (double)BaseSize.Width / resMag) * 0.5;
resVector.Y = 0.0;
}
else
{
resMag = (double)BaseSize.Width / (double)width;
resVector.X = 0.0;
resVector.Y = ((double)height - (double)BaseSize.Height / resMag) * 0.5;
}
}
}
else
};
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)
{
FPSF.FPSFixed(action);
if (ShowFPS)
{
baseControl.SetTitle(UITitle + " - FPS: " + System.Math.Round(FPSF.Value, 2));
}
baseControl.PollEvents();
}
}
public void Clear()
{
GD.Clear(ClearColor);
GH.Clear(ClearColor);
}
public void Draw(Are Are)
{
Are.Draw(GD, GH);
}
public void CursorHide()
{
if (cur)
{
//TODO fix?
//System.Windows.Forms.Cursor.Hide();
cur = false;
}
}
public void CursorShow()
{
if (!cur)
{
double num2 = (double)BaseSize.Height / (double)BaseSize.Width;
if ((double)height / (double)width <= num2)
{
resMag = (double)BaseSize.Height / (double)height;
resVector.X = ((double)width - (double)BaseSize.Width / resMag) * 0.5;
resVector.Y = 0.0;
}
else
{
resMag = (double)BaseSize.Width / (double)width;
resVector.X = 0.0;
resVector.Y = ((double)height - (double)BaseSize.Height / resMag) * 0.5;
}
}
};
//TODO fix?
//System.Windows.Forms.Cursor.Show();
cur = true;
}
}
return BaseSize;
}
public void InvokeL(Action a)
{
//TODO this look right?
a();
//baseControl.Invoke(a);
}
public Vector2D ToBasePosition(Point Position)
{
return new Vector2D(((double)Position.X - resVector.X) / Unit * resMag, ((double)Position.Y - resVector.Y) / Unit * resMag);
}
public Color GetUniqueColor()
{
Oth.GetRandomColor(out var ret);
while (HitColors.Contains(ret))
{
Oth.GetRandomColor(out ret);
}
HitColors.Add(ret);
return ret;
}
public Point FromBasePosition(Vector2D Position)
{
return new Point((int)(Position.X / resMag * Unit + resVector.X), (int)(Position.Y / resMag * Unit + resVector.Y));
}
public void GetUniqueColor(out Color c)
{
Oth.GetRandomColor(out c);
while (HitColors.Contains(c))
{
Oth.GetRandomColor(out c);
}
HitColors.Add(c);
}
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 void SetUniqueColor(IEnumerable<Par> ps)
{
foreach (Par p in ps)
{
p.HitColor = GetUniqueColor();
}
}
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 RemUniqueColor(Color Color)
{
HitColors.Remove(Color);
}
public void Drawing()
{
baseControl.BitmapSetting(BD);
Modes[mode].Setting();
double FPS = 0.0;
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();
}
Action action = delegate
{
FPS = FPSF.Value;
if (FPS > 1.0)
{
Modes[mode].Draw(FPSF);
}
baseControl.SetBitmap(BD);
};
[DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
[DllImport("user32.dll")]
private static extern IntPtr GetWindowDC(IntPtr hwnd);
while (Drive)
{
FPSF.FPSFixed(action);
[DllImport("gdi32.dll")]
private static extern int GetDeviceCaps(IntPtr hdc, int index);
if (ShowFPS)
{
baseControl.SetTitle(UITitle + " - FPS: " + System.Math.Round(FPSF.Value, 2));
}
baseControl.PollEvents();
}
}
[DllImport("user32.dll")]
private static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
public void Clear()
{
GD.Clear(ClearColor);
GH.Clear(ClearColor);
}
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;
}
public void Draw(Are Are)
{
Are.Draw(GD, GH);
}
public void CursorHide()
{
if (cur)
{
//TODO fix?
//System.Windows.Forms.Cursor.Hide();
cur = false;
}
}
public void CursorShow()
{
if (!cur)
{
//TODO fix?
//System.Windows.Forms.Cursor.Show();
cur = true;
}
}
public void InvokeL(Action a)
{
//TODO this look right?
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;
}
static Med()
{
obj = new object();
FPS = 60.0;
}
}
}

View File

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

View File

@@ -1,76 +1,77 @@
using System;
namespace _2DGAMELIB;
public class Mot : MotV
namespace _2DGAMELIB
{
public Action<Mot> Staing;
public class Mot : MotV
{
public Action<Mot> Staing;
public Action<Mot> Runing;
public Action<Mot> Runing;
public Action<Mot> Reaing;
public Action<Mot> Reaing;
public Action<Mot> Rouing;
public Action<Mot> Rouing;
public Action<Mot> Ending;
public Action<Mot> Ending;
private bool run;
private bool run;
private bool rou;
private bool rou;
public bool Run => run;
public bool Run => run;
public Mot(double Min, double Max)
: base(Min, Max)
{
}
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 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 Start()
{
if (Staing != null)
{
Staing(this);
}
run = true;
}
public void End()
{
run = false;
if (Ending != null)
{
Ending(this);
}
ResetValue();
rou = false;
}
public void End()
{
run = false;
if (Ending != null)
{
Ending(this);
}
ResetValue();
rou = false;
}
}
}

View File

@@ -1,108 +1,109 @@
namespace _2DGAMELIB;
public class MotV
namespace _2DGAMELIB
{
public double Value;
public class MotV
{
public double Value;
protected double min = -1.0;
protected double min = -1.0;
protected double max = 1.0;
protected double max = 1.0;
private double Frame;
private double Frame;
private double FrameHalf;
private double FrameHalf;
private double MinFrameHalf;
private double MinFrameHalf;
public double BaseSpeed = 1.0;
public double BaseSpeed = 1.0;
public double GotoSpeed = 1.0;
public double GotoSpeed = 1.0;
public double RetuSpeed = 1.0;
public double RetuSpeed = 1.0;
public double Interval;
public double Interval;
private long st;
private long st;
public double LowestIncrease = 1.0;
public double LowestIncrease = 1.0;
private int s = 1;
private int s = 1;
private double d;
private double d;
private double m;
private double m;
public double Min
{
get
{
return min;
}
set
{
min = value;
SetFrame();
}
}
public double Min
{
get
{
return min;
}
set
{
min = value;
SetFrame();
}
}
public double Max
{
get
{
return max;
}
set
{
max = value;
SetFrame();
}
}
public double Max
{
get
{
return max;
}
set
{
max = value;
SetFrame();
}
}
public MotV(double Min, double Max)
{
min = Min;
max = Max;
SetFrame();
ResetValue();
}
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;
}
private void SetFrame()
{
Frame = max - min;
FrameHalf = Frame * 0.5;
MinFrameHalf = Min + FrameHalf;
}
public void ResetValue()
{
Value = min;
}
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;
}
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;
}
}
}
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

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

View File

@@ -1,221 +1,222 @@
using System;
namespace _2DGAMELIB;
public class MyRandom : Random
namespace _2DGAMELIB
{
protected uint x;
public class MyRandom : Random
{
protected uint x;
protected uint y;
protected uint y;
protected uint z;
protected uint z;
protected uint w;
protected uint w;
private const double d_4294967296 = 2.3283064365386963E-10;
private const double d_4294967296 = 2.3283064365386963E-10;
private const double d_9007199254740992 = 1.1102230246251565E-16;
private const double d_9007199254740992 = 1.1102230246251565E-16;
protected uint InitMtSub(uint s, uint i)
{
return 1812433253 * (s ^ (s >> 30)) + i + 1;
}
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 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(uint s)
{
Initialize(s);
}
public MyRandom()
: this(4357u)
{
}
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 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 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()
{
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 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 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 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 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 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 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 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 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 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 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;
}
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;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,205 +2,206 @@ using System;
using System.Collections.Generic;
using System.Linq;
namespace _2DGAMELIB;
[Serializable]
public class OrderedDictionary<T1, T2>
namespace _2DGAMELIB
{
private List<T1> keys;
[Serializable]
public class OrderedDictionary<T1, T2>
{
private List<T1> keys;
private Dictionary<T1, T2> values;
private Dictionary<T1, T2> values;
public T2 this[T1 Key]
{
get
{
return values[Key];
}
set
{
values[Key] = value;
}
}
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 T2 this[int Index]
{
get
{
return values[keys[Index]];
}
set
{
values[keys[Index]] = value;
}
}
public IEnumerable<T1> Keys => keys;
public IEnumerable<T1> Keys => keys;
public IEnumerable<T2> Values
{
get
{
foreach (T1 key in keys)
{
yield return values[key];
}
}
}
public IEnumerable<T2> Values
{
get
{
foreach (T1 key in keys)
{
yield return values[key];
}
}
}
public int Count => keys.Count;
public int Count => keys.Count;
public OrderedDictionary()
{
keys = new List<T1>();
values = new Dictionary<T1, T2>();
}
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 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(T1 Key)
{
return keys.IndexOf(Key);
}
public int IndexOf(ref 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(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 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(T1 Key)
{
return keys.LastIndexOf(Key);
}
public int LastIndexOf(ref 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(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 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(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 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, 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 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(T1 Key)
{
keys.Remove(Key);
values.Remove(Key);
}
public void Remove(ref 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()
{
keys.Reverse();
}
public void Reverse(int Index, int Count)
{
keys.Reverse(Index, Count);
}
public void Reverse(int Index, int Count)
{
keys.Reverse(Index, Count);
}
public bool ContainsKey(T1 Key)
{
return values.ContainsKey(Key);
}
public bool ContainsKey(T1 Key)
{
return values.ContainsKey(Key);
}
public bool ContainsKey(ref 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(T2 Value)
{
return values.ContainsValue(Value);
}
public bool ContainsValue(ref T2 Value)
{
return values.ContainsValue(Value);
}
public bool ContainsValue(ref T2 Value)
{
return values.ContainsValue(Value);
}
}
}

View File

@@ -5,360 +5,361 @@ using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
namespace _2DGAMELIB;
public static class Oth
namespace _2DGAMELIB
{
private static double s1;
public static class Oth
{
private static double s1;
private static double s0;
private static double s0;
public static double GetDiagonalLength(this double Width, double Height)
{
return System.Math.Sqrt(Width * Width + Height * Height);
}
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 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 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 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 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 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 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 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, 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
};
}
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 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 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);
}
}
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 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 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 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 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 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 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 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 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 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 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);
}
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();
}
static Oth()
{
s1 = 1.01;
s0 = s1.Reciprocal();
}
public static void SaveExMod<T>(this T Obj, string Path)
{
Obj.ToSerialBytes().Save(Path);
}
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>();
}
public static T LoadExMod<T>(this string Path)
{
return Path.Load<byte[]>().ToDeserialObject<T>();
}
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -3,373 +3,374 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using Newtonsoft.Json;
namespace _2DGAMELIB;
// renders text
[Serializable]
public class ParT : Par
namespace _2DGAMELIB
{
[NonSerialized, JsonIgnore]
private Font font = new Font("", 1f);
// renders text
[Serializable]
public class ParT : Par
{
[NonSerialized, JsonIgnore]
private Font font = new Font("", 1f);
private double fontSize = 1.0;
private double fontSize = 1.0;
private bool EditF = true;
private bool EditF = true;
[NonSerialized, JsonIgnore]
private Brush brusht = new SolidBrush(Color.Black);
[NonSerialized, JsonIgnore]
private Brush brusht = new SolidBrush(Color.Black);
private const double Shift = 1.0;
private const double Shift = 1.0;
[NonSerialized, JsonIgnore]
private Brush brushs;
[NonSerialized, JsonIgnore]
private Brush brushs;
[NonSerialized, JsonIgnore]
private StringFormat stringformat = new StringFormat();
[NonSerialized, JsonIgnore]
private StringFormat stringformat = new StringFormat();
private Vector2D positionT = Dat.Vec2DZero;
private Vector2D positionT = Dat.Vec2DZero;
private Vector2D rectSize = Dat.Vec2DOne;
private Vector2D rectSize = Dat.Vec2DOne;
public string Text = "";
public string Text = "";
private RectangleF rect;
private RectangleF rect;
private double us;
private double us;
private double usx;
private double usx;
private double usy;
private double usy;
private Vector2D bp;
private Vector2D bp;
private Vector2D p;
private Vector2D p;
private Vector2D v;
private Vector2D v;
private double a0;
private double a0;
private double a1;
private double a1;
private double M11;
private double M11;
private double M12;
private double M12;
private float af;
private float af;
private float xf;
private float xf;
private float yf;
private float yf;
private bool EditT = true;
private bool EditT = true;
private bool EditTS = true;
private bool EditTS = true;
private CharacterRange[] crr = new CharacterRange[1];
private CharacterRange[] crr = new CharacterRange[1];
private CharacterRange[] cre = 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 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 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 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 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 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 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 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 PositionT
{
get
{
return positionT;
}
set
{
positionT = value;
EditT = true;
}
}
public Vector2D RectSize
{
get
{
return rectSize;
}
set
{
rectSize = 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 new void SetDefault()
{
base.SetDefault();
font = new Font("", 1f);
brusht = new SolidBrush(Color.Black);
brushs = null;
stringformat = new StringFormat();
}
public ParT()
{
}
public ParT()
{
}
public ParT(ParT ParT)
{
CopyT(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;
}
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);
}
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 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();
}
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_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();
}
}
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();
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,51 +1,52 @@
using System;
using System.Globalization;
namespace _2DGAMELIB;
public static class Qua
namespace _2DGAMELIB
{
public static QuaternionD RotationZQ(this double angle)
public static class Qua
{
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 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;
}
}
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)
//used in a total of 1 places
[Serializable]
public struct QuaternionD
{
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;
public double X;
public double Y;
public double Z;
public double W;
}
}
//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

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

View File

@@ -1,47 +1,48 @@
namespace _2DGAMELIB;
public class Rect
namespace _2DGAMELIB
{
public double XRatio = 1.0;
public class Rect
{
public double XRatio = 1.0;
public double YRatio = 1.0;
public double YRatio = 1.0;
public double Size = 1.0;
public double Size = 1.0;
public double LocalWidth => XRatio * Size;
public double LocalWidth => XRatio * Size;
public double LocalHeight => YRatio * Size;
public double LocalHeight => YRatio * Size;
public Vector2D LocalCenter => new Vector2D(LocalWidth * 0.5, LocalHeight * 0.5);
public Vector2D LocalCenter => new Vector2D(LocalWidth * 0.5, LocalHeight * 0.5);
public Rect()
{
}
public Rect()
{
}
public Rect(double XRatio, double YRatio, double Size)
{
SetXYRatio(XRatio, YRatio);
this.Size = Size;
}
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 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(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(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);
}
public Vector2D GetPosition(ref Vector2D p)
{
return new Vector2D(LocalWidth * p.X, LocalHeight * p.Y);
}
}
}

View File

@@ -1,80 +1,81 @@
using System.Drawing;
using System.Drawing.Imaging;
namespace _2DGAMELIB;
//Basically used to animate switching between two static images
public class Sce
namespace _2DGAMELIB
{
private Bitmap Start;
private Graphics GS;
//Basically used to animate switching between two static images
public class Sce
{
private Bitmap Start;
private Bitmap End;
private Graphics GS;
private Graphics GE;
private Bitmap End;
private int w;
private Graphics GE;
private int h;
private int w;
private int o;
private int h;
private Rectangle r;
private int o;
private ColorMatrix cm = new ColorMatrix();
private Rectangle r;
private ImageAttributes ia = new ImageAttributes();
private ColorMatrix cm = new ColorMatrix();
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);
}
private ImageAttributes ia = new ImageAttributes();
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 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 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 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 DrawStart(Are Are)
{
Are.Draw(GS);
}
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 DrawEnd(Are Are)
{
Are.Draw(GE);
}
public void DrawStart(Are Are)
{
Are.Draw(GS);
}
public void ClearStart(ref Color ClearColor)
{
GS.Clear(ClearColor);
}
public void DrawEnd(Are Are)
{
Are.Draw(GE);
}
public void Dispose()
{
Start.Dispose();
GS.Dispose();
End.Dispose();
GE.Dispose();
ia.Dispose();
}
public void ClearStart(ref Color ClearColor)
{
GS.Clear(ClearColor);
}
public void Dispose()
{
Start.Dispose();
GS.Dispose();
End.Dispose();
GE.Dispose();
ia.Dispose();
}
}
}

View File

@@ -3,90 +3,91 @@ using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Newtonsoft.Json;
namespace _2DGAMELIB;
//serialization stuff
public static class Ser
namespace _2DGAMELIB
{
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);
}
//serialization stuff
public static class Ser
{
private static SerializableAttribute s = new SerializableAttribute();
public static byte[] ToSerialBytes<T>(this T Object)
{
using MemoryStream memoryStream = new MemoryStream();
new BinaryFormatter().Serialize(memoryStream, Object);
return memoryStream.ToArray();
}
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 T ToDeserialObject<T>(this byte[] Bytes)
{
using MemoryStream serializationStream = new MemoryStream(Bytes);
return (T)new BinaryFormatter().Deserialize(serializationStream);
}
public static byte[] ToSerialBytes<T>(this T Object)
{
using MemoryStream memoryStream = new MemoryStream();
new BinaryFormatter().Serialize(memoryStream, Object);
return memoryStream.ToArray();
}
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 ToDeserialObject<T>(this byte[] Bytes)
{
using MemoryStream serializationStream = new MemoryStream(Bytes);
return (T)new BinaryFormatter().Deserialize(serializationStream);
}
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 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 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 Load<T>(this string Path)
{
using FileStream serializationStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
return (T)new BinaryFormatter().Deserialize(serializationStream);
}
public static T FromXml<T>(this string Path)
{
using FileStream input = new FileStream(Path, FileMode.Open, FileAccess.Read);
using XmlReader reader = XmlReader.Create(input);
return (T)new DataContractSerializer(typeof(T)).ReadObject(reader);
}
*/
static Ser(){}
public static T 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 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 FromXml<T>(this string Path)
{
using FileStream input = new FileStream(Path, FileMode.Open, FileAccess.Read);
using XmlReader reader = XmlReader.Create(input);
return (T)new DataContractSerializer(typeof(T)).ReadObject(reader);
}
*/
static Ser(){}
public static T UnJson<T>(string Path)
{
using StreamReader reader = File.OpenText(Path);
return (T)new JsonSerializer
{
NullValueHandling = NullValueHandling.Ignore,
TypeNameHandling = TypeNameHandling.All
}.Deserialize(reader, typeof(T));
}
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));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,58 +1,59 @@
using System;
namespace _2DGAMELIB;
public class SoundPlayer
namespace _2DGAMELIB
{
//Todo Fix
//public MediaPlayer mp = new MediaPlayer();
public class SoundPlayer
{
//Todo Fix
//public MediaPlayer mp = new MediaPlayer();
private bool l;
private bool l;
private TimeSpan ts = new TimeSpan(0L);
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 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, bool Loop)
{
//mp.Open(new Uri(Path));
this.Loop = Loop;
//mp.Volume = 1.0;
}
public SoundPlayer(string Path, bool Loop)
{
//mp.Open(new Uri(Path));
this.Loop = Loop;
//mp.Volume = 1.0;
}
public void Play()
{
//mp.Play();
}
public void Play()
{
//mp.Play();
}
public void Stop()
{
//mp.Stop();
}
public void Stop()
{
//mp.Stop();
}
public void Close()
{
//mp.Close();
}
public void Close()
{
//mp.Close();
}
}
}

View File

@@ -1,167 +1,168 @@
using System.Collections.Generic;
using System.Drawing;
namespace _2DGAMELIB;
public class Swi
namespace _2DGAMELIB
{
private bool flag;
public class Swi
{
private bool flag;
private Color OnColor = Color.Red;
private Color OnColor = Color.Red;
private List<Color> colors;
private List<Color> colors;
public bool Flag => flag;
public bool Flag => flag;
public Swi(Color OnColor)
{
this.OnColor = OnColor;
}
public Swi(Color OnColor)
{
this.OnColor = OnColor;
}
public Swi(ref 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 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++;
}
}
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++;
}
}
}
}

View File

@@ -3,403 +3,404 @@ using System.Drawing;
using System.IO;
using System.Linq;
namespace _2DGAMELIB;
public class Tex
namespace _2DGAMELIB
{
private Pars pars;
public class Tex
{
private Pars pars;
private ParT parT;
private ParT parT;
private Par feed;
private Par feed;
public int Space;
public int Space;
private string text;
private string text;
private double speed = 1.0;
private double speed = 1.0;
private Action<Tex> Action = delegate
{
};
private Action<Tex> Action = delegate
{
};
private MotV mv;
private MotV mv;
private bool f1;
private bool f1;
private bool f2;
private bool f2;
private double Count;
private double Count;
private int Max;
private int Max;
public Action<Tex> Done;
public Action<Tex> Done;
private byte a0;
private byte a0;
private byte a1;
private byte a1;
private string ConfigPath = Directory.GetCurrentDirectory() + "\\Config.ini";
private string ConfigPath = Directory.GetCurrentDirectory() + "\\Config.ini";
private bool FastText;
private bool FastText;
public Pars Pars => pars;
public Pars Pars => pars;
public ParT ParT => parT;
public ParT ParT => parT;
public Par Feed => feed;
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 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 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 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 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 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, 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, 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, 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);
}
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 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);
}
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 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 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 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 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();
}
public void Dispose()
{
pars.Dispose();
}
}
}

View File

@@ -1,27 +1,28 @@
using System.IO;
using System.Text;
namespace _2DGAMELIB;
public static class Text
namespace _2DGAMELIB
{
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 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 FromText(this string Path)
{
using FileStream fileStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
byte[] array = new byte[fileStream.Length];
fileStream.Read(array, 0, array.Length);
using StreamReader streamReader = new StreamReader(new MemoryStream(array), array.GetEncoding());
return streamReader.ReadToEnd();
}
public static string[] ReadLines(this string Path)
{
return Path.FromText().Replace("\r", "").Split('\n');
}
public static string[] ReadLines(this string Path)
{
return Path.FromText().Replace("\r", "").Split('\n');
}
}
}

View File

@@ -3,117 +3,118 @@ using System.ComponentModel;
using System.IO;
using System.Linq;
namespace _2DGAMELIB;
public class UI //: Form
namespace _2DGAMELIB
{
private Med Med;
public class UI //: Form
{
private Med Med;
private IContainer components;
private IContainer components;
private GlImage wpfImage1;
private GlImage wpfImage1;
//private System.Windows.Controls.Image hostedComponent1;
//private System.Windows.Controls.Image hostedComponent1;
private string ConfigPath = Directory.GetCurrentDirectory() + "\\Config.ini";
private string ConfigPath = Directory.GetCurrentDirectory() + "\\Config.ini";
private bool BigWindow;
private bool BigWindow;
public UI(Med Med)
{
this.Med = Med;
InitializeComponent();
}
public UI(Med Med)
{
this.Med = Med;
InitializeComponent();
}
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);
}
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);
}
private void UI_FormClosing()
{
Med.Drive = false;
}
private void UI_FormClosing()
{
Med.Drive = false;
}
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;
}
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);
}*/
/*
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 GlImage();
//this.hostedComponent1 = new System.Windows.Controls.Image();
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(_2DGAMELIB.UI));
this.wpfImage1 = new GlImage();
//this.hostedComponent1 = new System.Windows.Controls.Image();
//base.SuspendLayout();
//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.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";
//this.Text = "UI";
//base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
//base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
//base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
//base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
//base.Controls.Add(this.wpfImage1);
//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.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.FormClosing += new System.Windows.Forms.FormClosingEventHandler(UI_FormClosing);
//beauty
this.wpfImage1.Closing = delegate () { UI_FormClosing(); };
//beauty
this.wpfImage1.Closing = delegate () { UI_FormClosing(); };
//TODO fix?
//base.Load += new System.EventHandler(UI_Load);
UI_Load(null, null);
//base.Resize += new System.EventHandler(UI_Resize);
//base.ResumeLayout(false);
}
//TODO fix?
//base.Load += new System.EventHandler(UI_Load);
UI_Load(null, null);
//base.Resize += new System.EventHandler(UI_Resize);
//base.ResumeLayout(false);
}
}
}

View File

@@ -1,67 +1,68 @@
using System;
namespace _2DGAMELIB;
public static class Vec
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 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 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 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 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 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 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 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;
}
public static double Angle02π(this Vector2D v1, Vector2D v2)
{
double num = Angle(ref v1, ref v2);
if (Cross(ref v1, ref v2) < 0.0)
{
num = System.Math.PI * 2.0 - num;
}
return num;
}
}
}

View File

@@ -1,126 +1,127 @@
using System;
using System.Globalization;
namespace _2DGAMELIB;
[Serializable]
public struct Vector2D
namespace _2DGAMELIB
{
public double X;
[Serializable]
public struct Vector2D
{
public double X;
public double Y;
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 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(int value)
{
X = value;
Y = value;
}
public Vector2D(float value)
{
X = value;
Y = value;
}
public Vector2D(float value)
{
X = value;
Y = value;
}
public Vector2D(double 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(int x, int y)
{
X = x;
Y = y;
}
public Vector2D(float x, float 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 Vector2D(double x, double y)
{
X = x;
Y = y;
}
public double Length()
{
return System.Math.Sqrt(X * X + Y * Y);
}
public double Length()
{
return System.Math.Sqrt(X * X + Y * Y);
}
public double LengthSquared()
{
return 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 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 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)
{
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 *(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 *(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);
}
public static Vector2D operator /(Vector2D value, double scale)
{
return new Vector2D(value.X / scale, value.Y / scale);
}
}
}

View File

@@ -1,23 +1,24 @@
using System;
namespace _2DGAMELIB;
[Serializable]
public struct Vector2D_2
namespace _2DGAMELIB
{
public Vector2D v1;
[Serializable]
public struct Vector2D_2
{
public Vector2D v1;
public Vector2D v2;
public Vector2D v2;
public Vector2D_2(Vector2D v1, Vector2D v2)
{
this.v1 = v1;
this.v2 = 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;
}
public Vector2D_2(ref Vector2D v1, ref Vector2D v2)
{
this.v1 = v1;
this.v2 = v2;
}
}
}

View File

@@ -1,189 +1,190 @@
using System;
using System.Globalization;
namespace _2DGAMELIB;
[Serializable]
public struct Vector3D
namespace _2DGAMELIB
{
public double X;
[Serializable]
public struct Vector3D
{
public double X;
public double Y;
public double Y;
public double Z;
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 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(double value)
{
X = value;
Y = value;
Z = value;
}
public Vector3D(Vector2D value, double z)
{
X = value.X;
Y = value.Y;
Z = z;
}
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(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 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 Length()
{
return System.Math.Sqrt(X * X + Y * Y + Z * Z);
}
public double LengthSquared()
{
return 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 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 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)
{
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 *(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 *(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 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 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 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 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 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 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(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;
}
public bool Equals(ref Vector3D value)
{
if (X == value.X && Y == value.Y)
{
return Z == value.Z;
}
return false;
}
}
}

View File

@@ -1,211 +1,212 @@
using System;
using System.Globalization;
namespace _2DGAMELIB;
[Serializable]
public struct Vector4D
namespace _2DGAMELIB
{
public double X;
[Serializable]
public struct Vector4D
{
public double X;
public double Y;
public double Y;
public double Z;
public double Z;
public double W;
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 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(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(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(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(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(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 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 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 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 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 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)
{
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 *(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 *(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 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 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 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 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 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 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(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;
}
public bool Equals(ref Vector4D value)
{
if (X == value.X && Y == value.Y && Z == value.Z)
{
return W == value.W;
}
return false;
}
}
}

View File

@@ -6,146 +6,146 @@ using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Text;
namespace _2DGAMELIB;
public enum MouseButtons {
None = 0,
Left = 1,
Right = 2,
Middle = 4,
Button4 = 8,
Button5 = 16
}
public class GlImage
namespace _2DGAMELIB
{
public enum MouseButtons {
None = 0,
Left = 1,
Right = 2,
Middle = 4,
Button4 = 8,
Button5 = 16
}
//yeah this is a little bit sketchy
public static unsafe GLFW.Window PtrToWindow(IntPtr source)
public class GlImage
{
var sourceRef = __makeref(source);
var dest = default(GLFW.Window);
var destRef = __makeref(dest);
*(IntPtr*)&destRef = *(IntPtr*)&sourceRef;
return __refvalue(destRef, GLFW.Window);
}
public GLFW.Window window;
private uint shader_program;
private uint texture;
private uint vertex_buf;
private uint vao;
//yeah this is a little bit sketchy
public static unsafe GLFW.Window PtrToWindow(IntPtr source)
{
var sourceRef = __makeref(source);
var dest = default(GLFW.Window);
var destRef = __makeref(dest);
*(IntPtr*)&destRef = *(IntPtr*)&sourceRef;
return __refvalue(destRef, GLFW.Window);
}
public GLFW.Window window;
private uint shader_program;
private uint texture;
private uint vertex_buf;
private uint vao;
public GlImage() { }
public GlImage() { }
public void ImageSetting() { }
public void ImageSetting() { }
public System.Drawing.Point GetCursorPoint() {
double x, y;
Glfw.GetCursorPosition(window, out x, out y);
return new System.Drawing.Point((int)x, (int)y);
}
public System.Drawing.Point GetCursorPoint() {
double x, y;
Glfw.GetCursorPosition(window, out x, out y);
return new System.Drawing.Point((int)x, (int)y);
}
public MouseButtons GetMouseButtons() {
MouseButtons btns = 0;
public MouseButtons GetMouseButtons() {
MouseButtons btns = 0;
if (Glfw.GetMouseButton(window, MouseButton.Left) == InputState.Press)
btns |= MouseButtons.Left;
if (Glfw.GetMouseButton(window, MouseButton.Left) == InputState.Press)
btns |= MouseButtons.Left;
if (Glfw.GetMouseButton(window, MouseButton.Right) == InputState.Press)
btns |= MouseButtons.Right;
if (Glfw.GetMouseButton(window, MouseButton.Right) == InputState.Press)
btns |= MouseButtons.Right;
if (Glfw.GetMouseButton(window, MouseButton.Middle) == InputState.Press)
btns |= MouseButtons.Middle;
if (Glfw.GetMouseButton(window, MouseButton.Middle) == InputState.Press)
btns |= MouseButtons.Middle;
if (Glfw.GetMouseButton(window, MouseButton.Button4) == InputState.Press)
btns |= MouseButtons.Button4;
if (Glfw.GetMouseButton(window, MouseButton.Button4) == InputState.Press)
btns |= MouseButtons.Button4;
if (Glfw.GetMouseButton(window, MouseButton.Button5) == InputState.Press)
btns |= MouseButtons.Button5;
if (Glfw.GetMouseButton(window, MouseButton.Button5) == InputState.Press)
btns |= MouseButtons.Button5;
return btns;
}
return btns;
}
public delegate void ShouldCloseCallback();
public delegate void ShouldCloseCallback();
public ShouldCloseCallback Closing = delegate () { };
public MouseButtonCallback Click = delegate (IntPtr window, MouseButton button, InputState state, ModifierKeys modifiers) { };
public MouseCallback Move = delegate (IntPtr window, double x, double y) { };
public SizeCallback Resize = delegate (IntPtr window, int width, int height) { };
public MouseCallback Scroll = delegate (IntPtr window, double x, double y) { };
public MouseEnterCallback Leave = delegate (IntPtr window, bool entered) { };
public ShouldCloseCallback Closing = delegate () { };
public MouseButtonCallback Click = delegate (IntPtr window, MouseButton button, InputState state, ModifierKeys modifiers) { };
public MouseCallback Move = delegate (IntPtr window, double x, double y) { };
public SizeCallback Resize = delegate (IntPtr window, int width, int height) { };
public MouseCallback Scroll = delegate (IntPtr window, double x, double y) { };
public MouseEnterCallback Leave = delegate (IntPtr window, bool entered) { };
public void SetTitle(string title) {
Glfw.SetWindowTitle(window, title);
}
public void SetTitle(string title) {
Glfw.SetWindowTitle(window, title);
}
public void PollEvents() {
Glfw.PollEvents();
if (Glfw.WindowShouldClose(window))
Closing();
}
public void SetBitmap(Bitmap bmp)
{
Gl.UseProgram(shader_program);
Gl.Viewport(0, 0, bmp.Width, bmp.Height);
public void PollEvents() {
Glfw.PollEvents();
if (Glfw.WindowShouldClose(window))
Closing();
}
public void SetBitmap(Bitmap bmp)
{
Gl.UseProgram(shader_program);
Gl.Viewport(0, 0, bmp.Width, bmp.Height);
Gl.ActiveTexture(TextureUnit.Texture0);
Gl.BindTexture(TextureTarget.Texture2d, texture);
Gl.ActiveTexture(TextureUnit.Texture0);
Gl.BindTexture(TextureTarget.Texture2d, texture);
BitmapData data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Gl.TexImage2D(TextureTarget.Texture2d, 0, InternalFormat.Rgba8, bmp.Width, bmp.Height, 0, OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
bmp.UnlockBits(data);
BitmapData data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Gl.TexImage2D(TextureTarget.Texture2d, 0, InternalFormat.Rgba8, bmp.Width, bmp.Height, 0, OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
bmp.UnlockBits(data);
int res_pos = Gl.GetUniformLocation(shader_program, "res");
Gl.Uniform2(res_pos, (float)bmp.Width, (float)bmp.Height);
int res_pos = Gl.GetUniformLocation(shader_program, "res");
Gl.Uniform2(res_pos, (float)bmp.Width, (float)bmp.Height);
Gl.BindBuffer(BufferTarget.ArrayBuffer, vertex_buf);
uint vert_pos = (uint)Gl.GetAttribLocation(shader_program, "vertPos");
Gl.EnableVertexAttribArray(vert_pos);
Gl.BindBuffer(BufferTarget.ArrayBuffer, vertex_buf);
uint vert_pos = (uint)Gl.GetAttribLocation(shader_program, "vertPos");
Gl.EnableVertexAttribArray(vert_pos);
Gl.BindVertexArray(vao);
Gl.VertexAttribPointer(
vert_pos,
2,
VertexAttribType.Float,
false,
0,
IntPtr.Zero
);
Gl.BindVertexArray(vao);
Gl.VertexAttribPointer(
vert_pos,
2,
VertexAttribType.Float,
false,
0,
IntPtr.Zero
);
Gl.DrawArrays(PrimitiveType.TriangleStrip, 0, 4);
Glfw.SwapBuffers(window);
}
Gl.DrawArrays(PrimitiveType.TriangleStrip, 0, 4);
Glfw.SwapBuffers(window);
}
public void BitmapSetting(Bitmap bmp)
{
Glfw.WindowHint(Hint.ClientApi, ClientApi.OpenGL);
Glfw.WindowHint(Hint.ContextVersionMajor, 3);
Glfw.WindowHint(Hint.ContextVersionMinor, 3);
Glfw.WindowHint(Hint.OpenglProfile, Profile.Core);
Glfw.WindowHint(Hint.Doublebuffer, true);
Glfw.WindowHint(Hint.Decorated, true);
Glfw.WindowHint(Hint.OpenglForwardCompatible, true);
public void BitmapSetting(Bitmap bmp)
{
Glfw.WindowHint(Hint.ClientApi, ClientApi.OpenGL);
Glfw.WindowHint(Hint.ContextVersionMajor, 3);
Glfw.WindowHint(Hint.ContextVersionMinor, 3);
Glfw.WindowHint(Hint.OpenglProfile, Profile.Core);
Glfw.WindowHint(Hint.Doublebuffer, true);
Glfw.WindowHint(Hint.Decorated, true);
Glfw.WindowHint(Hint.OpenglForwardCompatible, true);
window = Glfw.CreateWindow(bmp.Width, bmp.Height, "yayy", Monitor.None, GLFW.Window.None);
window = Glfw.CreateWindow(bmp.Width, bmp.Height, "yayy", Monitor.None, GLFW.Window.None);
Glfw.SetWindowSizeCallback(window, Resize);
Glfw.SetMouseButtonCallback(window, Click);
Glfw.SetCursorPositionCallback(window, Move);
Glfw.SetScrollCallback(window, Scroll);
Glfw.SetCursorEnterCallback(window, Leave);
Glfw.SetWindowSizeCallback(window, Resize);
Glfw.SetMouseButtonCallback(window, Click);
Glfw.SetCursorPositionCallback(window, Move);
Glfw.SetScrollCallback(window, Scroll);
Glfw.SetCursorEnterCallback(window, Leave);
GCHandle handle = GCHandle.Alloc(this);
Glfw.SetWindowUserPointer(window, GCHandle.ToIntPtr(handle));
GCHandle handle = GCHandle.Alloc(this);
Glfw.SetWindowUserPointer(window, GCHandle.ToIntPtr(handle));
Gl.Initialize();
Glfw.MakeContextCurrent(window);
Gl.Initialize();
Glfw.MakeContextCurrent(window);
string[] vertexShaderSource = {
@"
string[] vertexShaderSource = {
@"
#version 100
precision mediump float;
@@ -156,10 +156,10 @@ void main()
gl_Position = vec4(vertPos, 0.0, 1.0);
}
"
};
};
string[] fragmentShaderSource = {
@"
string[] fragmentShaderSource = {
@"
#version 100
precision mediump float;
@@ -174,151 +174,153 @@ void main()
gl_FragColor = texture2D(sTexture, tc);
}
"
};
};
uint vertexShader = Gl.CreateShader(ShaderType.VertexShader);
Gl.ShaderSource(vertexShader, vertexShaderSource);
Gl.CompileShader(vertexShader);
uint vertexShader = Gl.CreateShader(ShaderType.VertexShader);
Gl.ShaderSource(vertexShader, vertexShaderSource);
Gl.CompileShader(vertexShader);
uint fragmentShader = Gl.CreateShader(ShaderType.FragmentShader);
Gl.ShaderSource(fragmentShader, fragmentShaderSource);
Gl.CompileShader(fragmentShader);
uint fragmentShader = Gl.CreateShader(ShaderType.FragmentShader);
Gl.ShaderSource(fragmentShader, fragmentShaderSource);
Gl.CompileShader(fragmentShader);
shader_program = Gl.CreateProgram();
Gl.AttachShader(shader_program, vertexShader);
Gl.AttachShader(shader_program, fragmentShader);
Gl.LinkProgram(shader_program);
shader_program = Gl.CreateProgram();
Gl.AttachShader(shader_program, vertexShader);
Gl.AttachShader(shader_program, fragmentShader);
Gl.LinkProgram(shader_program);
int length;
StringBuilder stringBuilder = new StringBuilder(10000);
Gl.GetShaderInfoLog(fragmentShader, 10000, out length, stringBuilder);
System.Diagnostics.Debug.WriteLine(stringBuilder);
stringBuilder.Clear();
Gl.GetShaderInfoLog(vertexShader, 10000, out length, stringBuilder);
System.Diagnostics.Debug.WriteLine(stringBuilder);
stringBuilder.Clear();
Gl.GetProgramInfoLog(shader_program, 10000, out length, stringBuilder);
System.Diagnostics.Debug.WriteLine(stringBuilder);
stringBuilder.Clear();
int length;
StringBuilder stringBuilder = new StringBuilder(10000);
Gl.GetShaderInfoLog(fragmentShader, 10000, out length, stringBuilder);
System.Diagnostics.Debug.WriteLine(stringBuilder);
stringBuilder.Clear();
Gl.GetShaderInfoLog(vertexShader, 10000, out length, stringBuilder);
System.Diagnostics.Debug.WriteLine(stringBuilder);
stringBuilder.Clear();
Gl.GetProgramInfoLog(shader_program, 10000, out length, stringBuilder);
System.Diagnostics.Debug.WriteLine(stringBuilder);
stringBuilder.Clear();
Gl.UseProgram(shader_program);
Gl.UseProgram(shader_program);
Gl.Uniform1(Gl.GetUniformLocation(shader_program, "sTexture"), 0);
Gl.Uniform1(Gl.GetUniformLocation(shader_program, "sTexture"), 0);
texture = Gl.GenTexture();
texture = Gl.GenTexture();
Gl.ActiveTexture(TextureUnit.Texture0);
Gl.BindTexture(TextureTarget.Texture2d, texture);
Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureWrapS, TextureWrapMode.ClampToEdge);
Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureWrapT, TextureWrapMode.ClampToEdge);
Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureMagFilter, TextureMagFilter.Nearest);
Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureMinFilter, TextureMagFilter.Nearest);
Gl.ActiveTexture(TextureUnit.Texture0);
Gl.BindTexture(TextureTarget.Texture2d, texture);
Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureWrapS, TextureWrapMode.ClampToEdge);
Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureWrapT, TextureWrapMode.ClampToEdge);
Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureMagFilter, TextureMagFilter.Nearest);
Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureMinFilter, TextureMagFilter.Nearest);
float[] buf = { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f };
vertex_buf = Gl.GenBuffer();
Gl.BindBuffer(BufferTarget.ArrayBuffer, vertex_buf);
Gl.BufferData(BufferTarget.ArrayBuffer, (uint)(sizeof(float) * buf.Length), buf, BufferUsage.StaticDraw);
float[] buf = { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f };
vertex_buf = Gl.GenBuffer();
Gl.BindBuffer(BufferTarget.ArrayBuffer, vertex_buf);
Gl.BufferData(BufferTarget.ArrayBuffer, (uint)(sizeof(float) * buf.Length), buf, BufferUsage.StaticDraw);
vao = Gl.GenVertexArray();
}
}
/*
public class WPFImage : ElementHost
{
public GlImage gl_img;
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;
gl_img = new GlImage();
vao = Gl.GenVertexArray();
}
}
public void PollEvents() {
gl_img.PollEvents();
}
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);
}
/*
public class WPFImage : ElementHost
{
public GlImage gl_img;
[DllImport("Kernel32.dll")]
public static extern void CopyMemory(IntPtr Destination, IntPtr Source, int ByteSize);
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;
gl_img = new GlImage();
}
public void PollEvents() {
gl_img.PollEvents();
}
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);
//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);
gl_img.SetBitmap(bmp);
}
gl_img.SetBitmap(bmp);
}
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;
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;
gl_img.BitmapSetting(bmp);
}
gl_img.BitmapSetting(bmp);
}
}
*/
*/
}

View File

@@ -1,66 +1,67 @@
using System.Drawing;
namespace _2DGAMELIB;
public static class _Con
namespace _2DGAMELIB
{
public static Vector2D ToVector2D(this Point Point)
{
return new Vector2D(Point.X, Point.Y);
}
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(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 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 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(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 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 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(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 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 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(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);
}
public static SizeF ToSizeF(ref Vector2D Vector)
{
return new SizeF((float)Vector.X, (float)Vector.Y);
}
}
}