Daily update on 20221026 by Nitload Youmu

This commit is contained in:
Youmu Konpaku
2022-10-27 01:52:13 +08:00
parent 6d979bdb1f
commit 7526459170
31 changed files with 360 additions and 218 deletions
@@ -1,6 +1,7 @@
using StgSharp; using StgSharp;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -11,6 +12,7 @@ namespace Debug
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
} }
} }
@@ -25,23 +25,11 @@ namespace StgSharp.Control
/// <param name="c">被限定的圆</param> /// <param name="c">被限定的圆</param>
public void Complex(Point p, Circle c) public void Complex(Point p, Circle c)
{ {
c.ComplexBind += this.ac; c._bindPoint = p;
} }
public void ac(Point p,Circle c)
{
float r = (float)Math.Sqrt
((p.X - c.Center.X) * (p.X - c.Center.X)
- (p.Y - c.Center.Y) * (p.Y - c.Center.Y));
c.Radius= r;
}
public void Complex(Point p, Line l) public void Complex(Point p, Line l)
{ {
l.EndingPoint = p;
}
public void al(Point p, Line l)
{
} }
} }
} }
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StgSharp.Entity namespace StgSharp.Entity
{ {
internal unsafe class Bullet : LinkedTarget internal unsafe class Bullet : LinkedObject
{ {
//子弹的缩放比例 //子弹的缩放比例
@@ -7,16 +7,18 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry namespace StgSharp.Geometry
{ {
public unsafe class Circle : GeometryI public unsafe class Circle :LinkedObject, IGeometry
{ {
private Point _center; private IPoint _center;
public Point Center public IPoint Center
{ {
get { return _center; } get { return _center; }
set { _center = value; } set { _center = value; }
} }
internal IPoint _bindPoint;
private float _radius; private float _radius;
public float Radius public float Radius
{ {
@@ -78,7 +80,7 @@ namespace StgSharp.Geometry
/// <param name="center">圆心</param> /// <param name="center">圆心</param>
/// <param name="radius">半径</param> /// <param name="radius">半径</param>
/// <param name="counter">游戏刻计数器</param> /// <param name="counter">游戏刻计数器</param>
public Circle(Point center, float radius,Counter<uint> counter) public Circle(IPoint center, float radius,Counter<uint> counter)
{ {
this._center = center; this._center = center;
this._radius = radius; this._radius = radius;
@@ -97,7 +99,7 @@ namespace StgSharp.Geometry
/// <param name="counter">游戏刻计数器</param> /// <param name="counter">游戏刻计数器</param>
/// <param name="rFunc">半径的时间函数</param> /// <param name="rFunc">半径的时间函数</param>
/// <param name="roFunc">角速度时间函数</param> /// <param name="roFunc">角速度时间函数</param>
public Circle(Point center, float radius, Counter<uint> counter, float[] rFunc, float[] roFunc) public Circle(IPoint center, float radius, Counter<uint> counter, float[] rFunc, float[] roFunc)
{ {
this._center = center; this._center = center;
this._radius = radius; this._radius = radius;
@@ -109,6 +111,17 @@ namespace StgSharp.Geometry
this.RotateFunc = roFunc; this.RotateFunc = roFunc;
} }
/// <summary>
/// 通过两个点创建一个完全定义的圆实例
/// </summary>
/// <param name="c">作为圆心的点</param>
/// <param name="b">在圆周上的点</param>
public Circle(IPoint c,IPoint b)
{
this._center = c;
this. _bindPoint = b;
}
public void SetMotion(float[] rFunc, float[] roFunc) public void SetMotion(float[] rFunc, float[] roFunc)
{ {
if (rFunc!=null) if (rFunc!=null)
@@ -131,36 +144,60 @@ namespace StgSharp.Geometry
} }
} }
public override void OnRender()
{
float a = 0;
float tick = tickCounter.Value - beginTick;
for (int i = 0; i < 9; i++)
{
a += _rotateFunc[i];
a *= tick;
}
_angle=a+ _rotateFunc[9];
float b = 0;
for (int i = 0; i < 9; i++)
{
b += _radiusFunc[i];
b*= tick;
}
_radius=b+ _radiusFunc[9];
}
/// <summary> /// <summary>
/// 将圆心绑定到一个新的点上; /// 将圆心绑定到一个新的点上;
/// </summary> /// </summary>
/// <param name="p"></param> /// <param name="p">想要绑定的圆心</param>
public override void Bind(Point p) public void Bind(IPoint p)
{ {
_center = p; _center = p;
} }
//需要一个将点绑定在圆周上 //需要一个将点绑定在圆周上
public void OnRender()
{
float a = 0;
float tick = tickCounter.Value - beginTick;
if (_rotateFunc!=null)
{
for (int i = 0; i < 9; i++)
{
a += _rotateFunc[i];
a *= tick;
}
_angle = a + _rotateFunc[9];
}
if (_bindPoint!=null)
{
float r = (float)
Math.Sqrt((_bindPoint.X - _center.X) * (_bindPoint.X - _center.X)
+ (_bindPoint.Y - _center.Y) * (_bindPoint.Y - _center.Y));
_radius= r;
}
else if (_radiusFunc!=null)
{
float b = 0;
for (int i = 0; i < 9; i++)
{
b += _radiusFunc[i];
b *= tick;
}
_radius=b+ _radiusFunc[9];
}
}
} }
} }
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometry
{
public delegate void ComplexOperationHandler();
}
@@ -1,58 +0,0 @@
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometry
{
public class GeometryI : LinkedTarget
{
public new LinkedTarget Previous
{
get { return this.Previous; }
set
{
if (value is GeometryI)
{
_previous = value;
}
}
}
public new LinkedTarget Next
{
get { return this.Next; }
set
{
if (value is GeometryI)
{
_next = value;
}
}
}
public delegate void ComplexBindHandler(Point sender, Circle sender2);
protected ComplexBindHandler complexBindHandler;
internal event ComplexBindHandler ComplexBind
{
add { this.complexBindHandler += value; }
remove { this.complexBindHandler -= value; }
}
public virtual void OnRender()
{
}
public virtual void Bind(Point p)
{
}
}
}
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometry
{
internal interface IGeometry
{
void Bind(IPoint p);
void OnRender();
event ComplexOperationHandler ComplexOperation;
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometry
{
public interface IPoint
{
float X { get; set; }
float Y { get; set; }
float Angle { get; set; }
void OnRender();
}
}
@@ -7,19 +7,19 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry namespace StgSharp.Geometry
{ {
public class Line:GeometryI public class Line:LinkedObject,IGeometry
{ {
private Point _beginPoint; private IPoint _beginPoint;
public Point BeginPoint public IPoint BeginPoint
{ {
get { return _beginPoint; } get { return _beginPoint; }
set { _beginPoint = value; } set { _beginPoint = value; }
} }
private Point _endingPoint; private IPoint _endingPoint;
public Point EndingPoint public IPoint EndingPoint
{ {
get { return _endingPoint; } get { return _endingPoint; }
set { _endingPoint = value; } set { _endingPoint = value; }
@@ -33,10 +33,17 @@ namespace StgSharp.Geometry
set { _length = value; } set { _length = value; }
} }
public ComplexOperationHandler complexOperationHandler;
public event ComplexOperationHandler ComplexOperation
{
add { complexOperationHandler += value; }
remove { complexOperationHandler -= value; }
}
public Line() public Line()
{ {
_beginPoint = new Point();
} }
/// <summary> /// <summary>
@@ -44,7 +51,7 @@ namespace StgSharp.Geometry
/// </summary> /// </summary>
/// <param name="begin"></param> /// <param name="begin"></param>
/// <param name="end"></param> /// <param name="end"></param>
public Line(Point begin, Point end) public Line(IPoint begin, IPoint end)
{ {
_beginPoint = begin; _beginPoint = begin;
_endingPoint = end; _endingPoint = end;
@@ -66,7 +73,7 @@ namespace StgSharp.Geometry
} }
public override void OnRender() public void OnRender()
{ {
_length = (float) _length = (float)
Math.Sqrt((_endingPoint.X - _beginPoint.X) * (_endingPoint.X - _beginPoint.X) Math.Sqrt((_endingPoint.X - _beginPoint.X) * (_endingPoint.X - _beginPoint.X)
@@ -74,8 +81,12 @@ namespace StgSharp.Geometry
} }
public void Bind(IPoint p)
{
_beginPoint = p;
}
public override void Bind(Point p) public void Bind(IPoint p,IPoint q)
{ {
_beginPoint = p; _beginPoint = p;
} }
@@ -1,48 +0,0 @@
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometry
{
/// <summary>
/// 不直接使用该类型的实例
/// </summary>
public class Point : LinkedTarget
{
protected float _x;
public float X
{
get { return _x; }
set { _x = value; }
}
protected float _y;
public float Y
{
get { return _y; }
set { _y = value; }
}
public new LinkedTarget Next
{
get { return this.Next; }
set
{
if (value is Point)
{
this.Next = value;
}
}
}
public virtual void OnRender()
{
}
}
}
@@ -7,11 +7,35 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry namespace StgSharp.Geometry
{ {
internal class PointCommon:Point internal class PointCommon : LinkedObject, IPoint
{ {
private readonly float x0; private readonly float x0;
private readonly float y0; private readonly float y0;
protected float _x;
protected float _y;
public float X
{
get { return _x; }
set { _x = value; }
}
public float Y
{
get { return _y; }
set { _y = value; }
}
private float angle0;
private float _angle;
public float Angle
{
get { return _angle; }
set { _angle = value; }
}
private float[] _xVelocity = new float[10]; private float[] _xVelocity = new float[10];
public float[] XVelocity public float[] XVelocity
@@ -70,7 +94,7 @@ namespace StgSharp.Geometry
} }
public override void OnRender() public void OnRender()
{ {
uint tick=_tickCounter.Value-beginTick; uint tick=_tickCounter.Value-beginTick;
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry namespace StgSharp.Geometry
{ {
public unsafe class PointOnCircle : Point public unsafe class PointOnCircle :LinkedObject, IPoint
{ {
private Circle _bindedItem; private Circle _bindedItem;
@@ -17,6 +17,22 @@ namespace StgSharp.Geometry
set { _bindedItem = value; } set { _bindedItem = value; }
} }
protected float _x;
public float X
{
get { return _x; }
set { _x = value; }
}
protected float _y;
public float Y
{
get { return _y; }
set { _y = value; }
}
private float _angle0; private float _angle0;
private float _angle; private float _angle;
@@ -40,7 +56,7 @@ namespace StgSharp.Geometry
} }
public override void OnRender() public void OnRender()
{ {
_angle = _angle0 + _bindedItem.Angle; _angle = _angle0 + _bindedItem.Angle;
this._x = (float)(_bindedItem.Center.X + _bindedItem.Radius * Math.Cos(_angle)); this._x = (float)(_bindedItem.Center.X + _bindedItem.Radius * Math.Cos(_angle));
@@ -1,4 +1,5 @@
using System; using StgSharp.Logic;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -6,24 +7,40 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry namespace StgSharp.Geometry
{ {
public class PointOnLine : Point public class PointOnLine : LinkedObject, IPoint
{ {
private Point _beginPoint; private IPoint _beginPoint;
public Point BeginPoint public IPoint BeginPoint
{ {
get { return _beginPoint; } get { return _beginPoint; }
set { _beginPoint = value; } set { _beginPoint = value; }
} }
private Point _endPoint; private IPoint _endPoint;
public Point EndPoint public IPoint EndPoint
{ {
get { return _endPoint; } get { return _endPoint; }
set { _endPoint = value; } set { _endPoint = value; }
} }
protected float _x;
public float X
{
get { return _x; }
set { _x = value; }
}
protected float _y;
public float Y
{
get { return _y; }
set { _y = value; }
}
private float _angle; private float _angle;
public float Angle public float Angle
@@ -35,7 +52,7 @@ namespace StgSharp.Geometry
private float rate; private float rate;
public PointOnLine(Point beginPoint, Point endPoint, float rate, int number) public PointOnLine(IPoint beginPoint, IPoint endPoint, float rate, int number)
{ {
_beginPoint = beginPoint; _beginPoint = beginPoint;
_endPoint = endPoint; _endPoint = endPoint;
@@ -47,7 +64,7 @@ namespace StgSharp.Geometry
this._x = beginPoint.X + rate * (endPoint.X - beginPoint.X); this._x = beginPoint.X + rate * (endPoint.X - beginPoint.X);
} }
public override void OnRender() public void OnRender()
{ {
_angle = (float)(Math.Atan2(_endPoint.Y - _beginPoint.Y, _endPoint.X - _beginPoint.Y)); _angle = (float)(Math.Atan2(_endPoint.Y - _beginPoint.Y, _endPoint.X - _beginPoint.Y));
@@ -6,19 +6,18 @@ using System.Threading.Tasks;
namespace StgSharp.Logic namespace StgSharp.Logic
{ {
internal class EntityContainer internal class EntityContainer:LinkedList,IContainer
{ {
private Counter<int> _limit; private int _limit;
private float _leftBorder; private float _leftBorder;
private float _rightBorder; private float _rightBorder;
private float _topBorder; private float _topBorder;
private float _bottomBorder; private float _bottomBorder;
private LinkedList _container;
public LinkedList Container public int Limit
{ {
get { return _container; } get { return _limit; }
set { _container = value; } set { _limit = value; }
} }
public float LeftBorder public float LeftBorder
@@ -42,27 +41,12 @@ namespace StgSharp.Logic
set { _bottomBorder = value; } set { _bottomBorder = value; }
} }
public EntityContainer(Counter<int> counter) public EntityContainer()
{ {
this._limit = counter;
this.Container = new LinkedList(_limit);
}
public void Add(LinkedTarget t)
{
if (true) //对target类型进行判断,应当只是实体
{
_container.Add(t);
}
}
public void RemoveAt(int id)
{
_container.Remove(id);
} }
//Move an entity from one container to another one //Move an entity from one container to another one
public void Move(LinkedTarget target, EntityContainer targetContainer) public void Move(LinkedObject target, EntityContainer targetContainer)
{ {
target.Previous = target.Next; target.Previous = target.Next;
target.Next = target.Previous; target.Next = target.Previous;
@@ -79,10 +63,7 @@ namespace StgSharp.Logic
//碰撞判定 //碰撞判定
} }
public void ReportCapacity()
{
Console.WriteLine(_limit.Value);
}
} }
} }
@@ -54,7 +54,7 @@ namespace StgSharp.Logic
} }
public void Add(LinkedTarget t) public void Add(LinkedObject t)
{ {
Container.Add(t); Container.Add(t);
} }
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Logic
{
internal interface IContainer
{
float LeftBorder { get; set; }
float RightBorder { get; set; }
float TopBorder { get; set; }
float BottomBorder { get; set; }
int Limit { get; set; }
}
}
@@ -8,23 +8,23 @@ namespace StgSharp.Logic
{ {
public class LinkedList public class LinkedList
{ {
protected LinkedTarget _heading; protected LinkedObject _heading;
protected LinkedTarget _ending; protected LinkedObject _ending;
private LinkedTarget _cache; private LinkedObject _cache;
private Counter<int> _amountCounter; private Counter<int> _amountCounter;
public LinkedTarget Heading public LinkedObject Heading
{ {
get { return _heading; } get { return _heading; }
set { _heading = value; } set { _heading = value; }
} }
public LinkedTarget Ending public LinkedObject Ending
{ {
get { return _ending; } get { return _ending; }
set { _ending = value; } set { _ending = value; }
} }
public LinkedTarget Cache public LinkedObject Cache
{ {
get { return _cache; } get { return _cache; }
set { _cache = value; } set { _cache = value; }
@@ -36,16 +36,16 @@ namespace StgSharp.Logic
} }
//构造器 //构造器
public LinkedList(Counter<int> counter) public LinkedList()
{ {
this._amountCounter = counter; this._amountCounter = new Counter<int>();
_amountCounter.Value = 0; _amountCounter.Value = 0;
_ending = null; _ending = null;
_heading = null; _heading = null;
} }
public void Add(LinkedTarget target) public void Add(LinkedObject target)
{ {
if (_ending != null) if (_ending != null)
{ {
@@ -85,7 +85,7 @@ namespace StgSharp.Logic
/// 快速删除链表中已知名称的一个实例。由于不能判别实例是否存在于链表中故安全性较低。在对安全性有要求的情况下应当使用Remove_s方法。 /// 快速删除链表中已知名称的一个实例。由于不能判别实例是否存在于链表中故安全性较低。在对安全性有要求的情况下应当使用Remove_s方法。
/// </summary> /// </summary>
/// <param name="target"></param> /// <param name="target"></param>
public void Remove(LinkedTarget target) public void Remove(LinkedObject target)
{ {
target.Previous = target.Next; target.Previous = target.Next;
target.Next = target.Previous; target.Next = target.Previous;
@@ -99,7 +99,7 @@ namespace StgSharp.Logic
/// </summary> /// </summary>
/// <param name="target"></param> /// <param name="target"></param>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public void Remove_s(LinkedTarget target) public void Remove_s(LinkedObject target)
{ {
bool a = true; bool a = true;
_cache = _heading; _cache = _heading;
@@ -7,11 +7,11 @@ using System.Threading.Tasks;
namespace StgSharp.Logic namespace StgSharp.Logic
{ {
public class LinkedTarget public class LinkedObject
{ {
protected LinkedTarget _previous; protected LinkedObject _previous;
public LinkedTarget Previous public LinkedObject Previous
{ {
get { return _previous; } get { return _previous; }
set set
@@ -24,9 +24,9 @@ namespace StgSharp.Logic
} }
} }
protected LinkedTarget _next; protected LinkedObject _next;
public LinkedTarget Next public LinkedObject Next
{ {
get { return _next; } get { return _next; }
set set
@@ -0,0 +1,66 @@
using StgSharp.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Logic
{
internal class PointContainer : LinkedList<IPoint>
{
private Counter<int> _limit;
private float _leftBorder;
private float _rightBorder;
private float _topBorder;
private float _bottomBorder;
private LinkedList _container;
public float LeftBorder
{
get { return _leftBorder; }
set { _leftBorder = value; }
}
public float RightBorder
{
get { return _rightBorder; }
set { _rightBorder = value; }
}
public float TopBorder
{
get { return _topBorder; }
set { _topBorder = value; }
}
public float BottomBorder
{
get { return _bottomBorder; }
set { _bottomBorder = value; }
}
public LinkedList Container
{
get { return _container; }
set { _container = value; }
}
public void Add(LinkedObject t)
{
if (true) //对target类型进行判断,应当只是实体
{
_container.Add(t);
}
}
public void RemoveAt(int id)
{
_container.Remove(id);
}
public PointContainer(Counter<int> counter)
{
this._limit = counter;
this.Container = new LinkedList(_limit);
}
}
}
@@ -49,7 +49,12 @@
<Compile Include="Control\Create.cs" /> <Compile Include="Control\Create.cs" />
<Compile Include="Entity\Enemy.cs" /> <Compile Include="Entity\Enemy.cs" />
<Compile Include="Game\Class1.cs" /> <Compile Include="Game\Class1.cs" />
<Compile Include="Geometry\ComplexOperationHandler.cs" />
<Compile Include="Geometry\IGeometry.cs" />
<Compile Include="Geometry\IPoint.cs" />
<Compile Include="Geometry\PointCommon.cs" /> <Compile Include="Geometry\PointCommon.cs" />
<Compile Include="Logic\IContainer.cs" />
<Compile Include="Logic\PointContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Entity\Bullet.cs" /> <Compile Include="Entity\Bullet.cs" />
<Compile Include="Entity\Player.cs" /> <Compile Include="Entity\Player.cs" />
@@ -58,17 +63,14 @@
<Compile Include="Geometry\PointOnLine.cs" /> <Compile Include="Geometry\PointOnLine.cs" />
<Compile Include="Geometry\PointOnCircle.cs" /> <Compile Include="Geometry\PointOnCircle.cs" />
<Compile Include="Geometry\Line.cs" /> <Compile Include="Geometry\Line.cs" />
<Compile Include="Geometry\Point.cs" />
<Compile Include="Geometry\GeometryI.cs" />
<Compile Include="Logic\GeometryContainer.cs" /> <Compile Include="Logic\GeometryContainer.cs" />
<Compile Include="Logic\EntityContainer.cs" /> <Compile Include="Logic\EntityContainer.cs" />
<Compile Include="Logic\Counter.cs" /> <Compile Include="Logic\Counter.cs" />
<Compile Include="Logic\LinkedList.cs" /> <Compile Include="Logic\LinkedList.cs" />
<Compile Include="Logic\LinkedTarget.cs" /> <Compile Include="Logic\LinkedObject.cs" />
</ItemGroup> <Compile Include="UI\Option.cs" />
<ItemGroup>
<Folder Include="UI\" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<ItemGroup> <ItemGroup>
<None Include="OpenTK.dll.config" /> <None Include="OpenTK.dll.config" />
<None Include="packages.config" /> <None Include="packages.config" />
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.UI
{
public class Option
{
public SelectEventHandler selectEventHandler;
public event SelectEventHandler SelectEvent
{
add { this.selectEventHandler += value; }
remove { this.selectEventHandler -= value; }
}
public void HighLight()
{
}
public void LowLight()
{
}
}
public delegate void SelectEventHandler();
}