daily update on 20221107 by nitload youmu

This commit is contained in:
Nitload
2022-11-08 00:18:18 +08:00
parent 64d4d2534e
commit 849f7582f8
28 changed files with 169 additions and 690 deletions
@@ -1,7 +1,6 @@
using StgSharp.Entity;
using StgSharp.Geometry;
using StgSharp.Logic;
using StgSharp.Pool;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -17,7 +16,7 @@ namespace StgSharp.Control
private static LinkedObject cache;
public static void Geometry(IPoint center, float radius, float angle, int num)
public static void Geometry(Point center, float radius, float angle, int num)
{
}
@@ -26,7 +25,7 @@ namespace StgSharp.Control
/// 创建一个子弹并将其绑定在一个指定的点上
/// </summary>
/// <param name="point"></param>
public static void Bullet(IPoint point)
public static void Bullet(Point point)
{
Pool.bulletContainer.Add(new Bullet(point));
}
@@ -47,7 +46,7 @@ namespace StgSharp.Control
for (int i = begin; i < end; i++)
{
cache--;
Pool.bulletContainer.Add(new Bullet(cache as IPoint));
Pool.bulletContainer.Add(new Bullet(cache as Point));
}
}
@@ -95,7 +94,7 @@ namespace StgSharp.Control
}
public static void Circle(IPoint c, float r)
public static void Circle(Point c, float r)
{
}
}
@@ -1,5 +1,6 @@
using StgSharp.Logic;
using StgSharp.Pool;
using StgSharp.Entity;
using StgSharp.Geometry;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -14,43 +15,47 @@ namespace StgSharp.Control
public static Counter<uint> tickCounter
= new Counter<uint>();
internal static Collector topCollector
=new Collector(side.top,1000);
internal static Collector bottomCollector
=new Collector(side.bottom,-1000);
internal static Collector leftCollector
= new Collector(side.left, -600);
internal static Collector rightCollector
= new Collector(side.right,600);
internal static Counter<uint> entityCounter
internal static Counter<uint> collectCounter
=new Counter<uint>();
internal static LinkedList entityContainer
= new LinkedList(entityCounter);
internal static Logic.LinkedList<LinkedObject> topCollector
= new Logic.LinkedList<LinkedObject>(collectCounter);
internal static Logic.LinkedList<LinkedObject> bottomCollector
=new Logic.LinkedList<LinkedObject>(collectCounter);
internal static Logic.LinkedList<LinkedObject> leftCollector
=new Logic.LinkedList<LinkedObject>(collectCounter);
internal static Logic.LinkedList<LinkedObject> rightCollector
= new Logic.LinkedList<LinkedObject>(collectCounter);
internal static Counter<uint> bulletCounter
=new Counter<uint>();
internal static LinkedList bulletContainer
= new LinkedList(bulletCounter);
internal static Logic.LinkedList<Bullet> bulletContainer
= new Logic.LinkedList<Bullet>(bulletCounter);
internal static Counter<uint> entityCounter
=new Counter<uint>();
internal static Logic.LinkedList<Entity.Entity> entityContainer
= new Logic.LinkedList<Entity.Entity>(entityCounter);
internal static Counter<uint> gemoetryCounter
=new Counter<uint>();
internal static LinkedList geometryContainer
= new LinkedList(gemoetryCounter);
internal static Logic.LinkedList<Geometry.Geometry> geometryContainer
= new Logic.LinkedList<Geometry.Geometry>(gemoetryCounter);
internal static Counter<uint> pointCounter
=new Counter<uint>();
internal static LinkedList pointContainer
= new LinkedList(pointCounter);
internal static Logic.LinkedList<Point> pointContainer
= new Logic.LinkedList<Point>(pointCounter);
static Pool()
{
}
public static void Creat()
public static void OnRender()
{
}
}
@@ -10,9 +10,9 @@ namespace StgSharp.Entity
{
public class Bullet : LinkedObject
{
internal IPoint _location;
internal Point _location;
public IPoint Location
public Point Location
{
get { return _location; }
set { _location = value; }
@@ -41,7 +41,7 @@ namespace StgSharp.Entity
set { _radius = value; }
}
public Bullet(IPoint p)
public Bullet(Point p)
{
_location = p;
}
@@ -0,0 +1,14 @@
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Entity
{
internal class Entity:LinkedObject
{
}
}
@@ -8,17 +8,17 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry
{
public unsafe class Circle :LinkedObject, IGeometry
public unsafe class Circle :Geometry
{
private IPoint _center;
private Point _center;
public IPoint Center
public Point Center
{
get { return _center; }
set { _center = value; }
}
internal IPoint _bindPoint;
internal Point _bindPoint;
private float _radius;
public float Radius
@@ -87,7 +87,7 @@ namespace StgSharp.Geometry
/// <param name="center">圆心</param>
/// <param name="radius">半径</param>
/// <param name="counter">游戏刻计数器</param>
public Circle(IPoint center, float radius,Counter<uint> counter)
public Circle(Point center, float radius,Counter<uint> counter)
{
this._center = center;
this._radius = radius;
@@ -106,7 +106,7 @@ namespace StgSharp.Geometry
/// <param name="counter">游戏刻计数器</param>
/// <param name="rFunc">半径的时间函数</param>
/// <param name="roFunc">角速度时间函数</param>
public Circle(IPoint center, float radius, Counter<uint> counter, float[] rFunc, float[] roFunc)
public Circle(Point center, float radius, Counter<uint> counter, float[] rFunc, float[] roFunc)
{
this._center = center;
this._radius = radius;
@@ -123,7 +123,7 @@ namespace StgSharp.Geometry
/// </summary>
/// <param name="c">作为圆心的点</param>
/// <param name="b">在圆周上的点</param>
public Circle(IPoint c,IPoint b)
public Circle(Point c,Point b)
{
this._center = c;
this. _bindPoint = b;
@@ -141,22 +141,13 @@ namespace StgSharp.Geometry
}
}
public void Add(float angle,uint number,GeometryContainer geometryPool)
{
PointOnCircle p;
for (int i = 0; i < number; i++)
{
p = new PointOnCircle(this, angle, number);
geometryPool.Add(p);
}
}
/// <summary>
/// 将圆心绑定到一个新的点上;
/// </summary>
/// <param name="p">想要绑定的圆心</param>
public void Bind(IPoint p)
public void Bind(Point p)
{
_center = p;
}
@@ -8,10 +8,10 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry
{
internal class FreeCurve : LinkedObject, IGeometry
internal class FreeCurve : Geometry
{
private IPoint _center;
private Point _center;
private float[] _xExpression;
private float[] _yExpression;
@@ -28,7 +28,7 @@ namespace StgSharp.Geometry
}
public IPoint Center
public Point Center
{
get { return _center; }
set { _center = value; }
@@ -38,7 +38,7 @@ namespace StgSharp.Geometry
public FreeCurve(IPoint c, float[] x, float[] y)
public FreeCurve(Point c, float[] x, float[] y)
{
if (x.Length==10)
{
@@ -59,7 +59,7 @@ namespace StgSharp.Geometry
}
}
public void Bind(IPoint p)
public void Bind(Point p)
{
_center = p;
}
@@ -0,0 +1,21 @@
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometry
{
public class Geometry:LinkedObject
{
public static Geometry operator ++(Geometry g)
{
return g.Next as Geometry;
}
public static Geometry operator --(Geometry g)
{
return g.Previous as Geometry;
}
}
}
@@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometry
{
public interface IGeometry
{
void Bind(IPoint p);
void OnRender();
event ComplexOperationHandler ComplexOperation;
}
}
@@ -1,24 +0,0 @@
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();
}
abstract class a
{
}
}
@@ -7,19 +7,19 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry
{
public class Line:LinkedObject,IGeometry
public class Line:Geometry
{
private IPoint _beginPoint;
private Point _beginPoint;
public IPoint BeginPoint
public Point BeginPoint
{
get { return _beginPoint; }
set { _beginPoint = value; }
}
private IPoint _endingPoint;
private Point _endingPoint;
public IPoint EndingPoint
public Point EndingPoint
{
get { return _endingPoint; }
set { _endingPoint = value; }
@@ -51,27 +51,13 @@ namespace StgSharp.Geometry
/// </summary>
/// <param name="begin"></param>
/// <param name="end"></param>
public Line(IPoint begin, IPoint end)
public Line(Point begin, Point end)
{
_beginPoint = begin;
_endingPoint = end;
}
public void AddPoint(float step,GeometryContainer geometryPool)
{
if(step < _length)
{
PointOnLine p;
int number = (int)(_length / step);
for (int i = 0; i <number ; i++)
{
p = new PointOnLine(_beginPoint,_endingPoint,step,i);
geometryPool.Add(p);
}
}
}
public void OnRender()
{
@@ -81,14 +67,5 @@ namespace StgSharp.Geometry
}
public void Bind(IPoint p)
{
_beginPoint = p;
}
public void Bind(IPoint p,IPoint q)
{
_beginPoint = p;
}
}
}
@@ -0,0 +1,54 @@
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometry
{
public class Point:LinkedObject
{
internal float _x;
internal float _y;
internal float _angle;
public float X
{
get { return _x; }
set{ _x = value; }
}
public float Y
{
get { return _y; }
set { _y = value; }
}
float Angle
{
get { return _angle; }
set { _angle = value; }
}
public virtual void OnRender()
{
}
public static Point operator ++(Point a)
{
return a._next as Point;
}
public static Point operator --(Point a)
{
return a._previous as Point;
}
}
}
@@ -8,34 +8,12 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry
{
internal class PointCommon : LinkedObject, IPoint
internal class PointCommon : Point
{
private readonly float x0;
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];
@@ -98,7 +76,7 @@ namespace StgSharp.Geometry
}
public void OnRender()
public override void OnRender()
{
uint tick=_tickCounter.Value-beginTick;
@@ -121,13 +99,6 @@ namespace StgSharp.Geometry
public static PointCommon operator ++(PointCommon a)
{
return a._next as PointCommon;
}
public static PointCommon operator --(PointCommon a)
{
return a._previous as PointCommon;
}
}
}
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry
{
public class PointOnCircle :LinkedObject, IPoint
public class PointOnCircle :Point
{
private Circle _bindedItem;
@@ -18,30 +18,8 @@ namespace StgSharp.Geometry
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 _angle;
public float Angle
{
get { return _angle; }
set { _angle = value; }
}
/// <summary>
///
@@ -57,7 +35,7 @@ namespace StgSharp.Geometry
}
public void OnRender()
public override void OnRender()
{
_angle = _angle0 + _bindedItem.Angle;
this._x = (float)(_bindedItem.Center.X + _bindedItem.Radius * Math.Cos(_angle));
@@ -8,51 +8,29 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry
{
public class PointOnLine : LinkedObject, IPoint
public class PointOnLine : Point
{
private IPoint _beginPoint;
private Point _beginPoint;
public IPoint BeginPoint
public Point BeginPoint
{
get { return _beginPoint; }
set { _beginPoint = value; }
}
private IPoint _endPoint;
private Point _endPoint;
public IPoint EndPoint
public Point EndPoint
{
get { return _endPoint; }
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;
public float Angle
{
get { return _angle; }
set { _angle = value; }
}
private float _rate;
public PointOnLine(IPoint beginPoint, IPoint endPoint, float rate, int number)
public PointOnLine(Point beginPoint, Point endPoint, float rate, int number)
{
_beginPoint = beginPoint;
_endPoint = endPoint;
@@ -64,7 +42,7 @@ namespace StgSharp.Geometry
this._x = beginPoint.X + rate * (endPoint.X - beginPoint.X);
}
public void OnRender()
public override void OnRender()
{
_angle = (float)(Math.Atan2(_endPoint.Y - _beginPoint.Y, _endPoint.X - _beginPoint.Y));
@@ -1,32 +0,0 @@
using StgSharp.Pool;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Logic
{
public interface IContainer
{
float LeftBorder { get; set; }
float RightBorder { get; set; }
float TopBorder { get; set; }
float BottomBorder { get; set; }
int Limit { get; set; }
IContainer Top { get; set; }
IContainer Bottom { get; set; }
IContainer Left { get; set; }
IContainer Right { get; set; }
void Add(LinkedObject o);
}
}
@@ -6,25 +6,25 @@ using System.Threading.Tasks;
namespace StgSharp.Logic
{
public class LinkedList
public class LinkedList<T> where T : LinkedObject
{
protected LinkedObject _heading = null;
protected LinkedObject _ending;
protected LinkedObject _cache;
protected T _heading = null;
protected T _ending;
protected T _cache;
protected Counter<uint> _amountCounter;
public virtual LinkedObject Heading
public virtual T Heading
{
get { return _heading; }
set { _heading = value; }
}
public virtual LinkedObject Ending
public virtual T Ending
{
get { return _ending; }
set { _ending = value; }
}
public LinkedObject Cache
public T Cache
{
get { return _cache; }
set { _cache = value; }
@@ -47,7 +47,7 @@ namespace StgSharp.Logic
}
public void Add(LinkedObject target)
public void Add(T target)
{
if (_ending != null)
{
@@ -74,7 +74,7 @@ namespace StgSharp.Logic
_cache = null;
for (int i = 1; i < id; i++)
{
_cache = _cache.Next;
_cache = _cache.Next as T;
}
_cache.Previous = _cache.Next;
_cache.Next = _cache.Previous;
@@ -87,7 +87,7 @@ namespace StgSharp.Logic
/// 快速删除链表中已知名称的一个实例。由于不能判别实例是否存在于链表中故安全性较低。在对安全性有要求的情况下应当使用Remove_s方法。
/// </summary>
/// <param name="target"></param>
public void Remove(LinkedObject target)
public void Remove(T target)
{
target.Previous = target.Next;
target.Next = target.Previous;
@@ -103,7 +103,7 @@ namespace StgSharp.Logic
/// </summary>
/// <param name="target"></param>
/// <exception cref="Exception"></exception>
public void Remove_s(LinkedObject target)
public void Remove_s(T target)
{
bool a = true;
_cache = _heading;
@@ -1,121 +0,0 @@
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Pool
{
public class Collector : LinkedList, IContainer
{
private readonly float _topBorder;
private readonly float _bottomBorder;
private readonly float _leftBorder;
private readonly float _rightBorder;
private readonly IContainer _top;
private readonly IContainer _bottom;
private readonly IContainer _left;
private readonly IContainer _right;
private readonly Counter<int> _counter;
private readonly int _limit;
public float TopBorder
{
get { return _topBorder; }
set { }
}
public float BottomBorder
{
get { return _bottomBorder; }
set { }
}
public float LeftBorder
{
get { return _leftBorder; }
set { }
}
public float RightBorder
{
get { return _rightBorder; }
set { }
}
public IContainer Top
{
get { return _top; }
set { }
}
public IContainer Bottom
{
get { return _bottom; }
set { }
}
public IContainer Left
{
get { return _left; }
set { }
}
public IContainer Right
{
get { return _right; }
set { }
}
public Counter<int> Counter
{
get;
set;
}
public int Limit
{
get { return _limit; }
set { }
}
public Collector(side s,float b)
{
switch (s)
{
case side.top:
_bottomBorder = b;
break;
case side.bottom:
_topBorder = b;
break;
case side.left:
_rightBorder = b;
break;
case side.right:
_leftBorder = b;
break;
default:
break;
}
}
}
public enum side
{
top,
bottom,
left,
right,
}
}
@@ -1,111 +0,0 @@
using StgSharp.Pool;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Logic
{
internal class EntityContainer:LinkedList,IContainer
{
private int _limit;
protected float _leftBorder;
protected float _rightBorder;
protected float _topBorder;
protected float _bottomBorder;
public int Limit
{
get { return _limit; }
set { _limit = value; }
}
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 static IContainer _top;
public static IContainer _bottom;
public static IContainer _left;
public static IContainer _right;
public IContainer Top
{
get { return _top; }
set { }
}
public IContainer Bottom
{
get { return _bottom; }
set { }
}
public IContainer Left
{
get { return _left; }
set { }
}
public IContainer Right
{
get { return _right; }
set { }
}
public EntityContainer(float top,float bottom,float left,float right)
{
_topBorder = top;
_bottomBorder = bottom;
_leftBorder = left;
_rightBorder = right;
this._amountCounter = new Counter<uint>();
_amountCounter.Value = 0;
_heading = null;
}
public EntityContainer(IContainer t, IContainer b, IContainer l, IContainer r)
{
_top = t;
_topBorder = t.BottomBorder;
_bottom = b;
_bottomBorder = b.TopBorder;
_left= l;
_leftBorder = l.RightBorder;
_right = r;
_rightBorder = r.LeftBorder;
}
//What should a container do on each rendering frame
//This method should be overriden
public void OnRender()
{
//坐标刷新
//边界判定
//碰撞判定
}
}
}
@@ -1,104 +0,0 @@
using StgSharp.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Logic
{
public class GeometryContainer:LinkedList,IContainer
{
private float _leftBorder;
public float LeftBorder
{
get { return _leftBorder; }
set { _leftBorder = value; }
}
private float _rightBorder;
public float RightBorder
{
get { return _rightBorder; }
set { _rightBorder = value; }
}
private float _topBorder;
public float TopBorder
{
get { return _topBorder; }
set { _topBorder = value; }
}
private float _bottomBorder;
public float BottomBorder
{
get { return _bottomBorder; }
set { _bottomBorder = value; }
}
private int _limit;
private IContainer _top;
private IContainer _bottom;
private IContainer _left;
private IContainer _right;
public IContainer Top
{
get { return _top; }
set { _top = value; }
}
public IContainer Left
{
get { return _left; }
set { _left = value; }
}
public IContainer Right
{
get { return _right; }
set { _right = value; }
}
public IContainer Bottom
{
get { return _bottom; }
set { _bottom = value; }
}
public int Limit
{
get { return _limit; }
set { _limit = value; }
}
public GeometryContainer(IContainer t, IContainer b, IContainer l, IContainer r)
{
_top = t;
_bottom = b;
_left = l;
_right = r;
_topBorder=t.BottomBorder;
_bottomBorder=b.TopBorder;
_leftBorder=l.RightBorder;
_rightBorder=r.LeftBorder;
}
public void OnRender()
{
}
}
}
@@ -1,93 +0,0 @@
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, IContainer
{
private float _leftBorder;
private float _rightBorder;
private float _topBorder;
private float _bottomBorder;
private IContainer _left;
private IContainer _right;
private IContainer _top;
private IContainer _bottom;
private int _limit;
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 IContainer Left
{
get { return _left; }
set { _left = value; }
}
public IContainer Right
{
get { return _right; }
set { _right = value; }
}
public IContainer Top
{
get { return _top; }
set { _top = value; }
}
public IContainer Bottom
{
get { return _bottom; }
set { _bottom = value; }
}
public int Limit
{
get { return _limit; }
set { _limit = value; }
}
public PointContainer(float top,float bottom,float left,float right)
{
_topBorder = top;
_bottomBorder = bottom;
_leftBorder = left;
_rightBorder = right;
}
public PointContainer(IContainer t,IContainer b,IContainer l,IContainer r)
{
_top = t;
_bottom = b;
_left = l;
_right = r;
}
}
}
@@ -48,17 +48,15 @@
<Compile Include="Control\Bind.cs" />
<Compile Include="Control\Pool.cs" />
<Compile Include="Control\Create.cs" />
<Compile Include="Entity\Entity.cs" />
<Compile Include="Entity\Reward.cs" />
<Compile Include="Entity\Enemy.cs" />
<Compile Include="Game\CoreInfo.cs" />
<Compile Include="Control\ComplexOperationHandler.cs" />
<Compile Include="Geometry\Geometry.cs" />
<Compile Include="Geometry\FreeCurve.cs" />
<Compile Include="Geometry\IGeometry.cs" />
<Compile Include="Geometry\IPoint.cs" />
<Compile Include="Geometry\Point.cs" />
<Compile Include="Geometry\PointCommon.cs" />
<Compile Include="Logic\IContainer.cs" />
<Compile Include="Pool\Collector.cs" />
<Compile Include="Pool\PointContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Entity\Bullet.cs" />
<Compile Include="Entity\Player.cs" />
@@ -67,8 +65,6 @@
<Compile Include="Geometry\PointOnLine.cs" />
<Compile Include="Geometry\PointOnCircle.cs" />
<Compile Include="Geometry\Line.cs" />
<Compile Include="Pool\GeometryContainer.cs" />
<Compile Include="Pool\EntityContainer.cs" />
<Compile Include="Logic\Counter.cs" />
<Compile Include="Logic\LinkedList.cs" />
<Compile Include="Logic\LinkedObject.cs" />