Daily update on 20221027 by Nitload Youmu

This commit is contained in:
Youmu Konpaku
2022-10-28 02:14:58 +08:00
parent 7526459170
commit befe556288
42 changed files with 209 additions and 227 deletions
@@ -1,4 +1,5 @@
using StgSharp; using StgSharp;
using StgSharp.Geometry;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@@ -12,7 +13,7 @@ namespace Debug
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
Console.WriteLine(typeof(PointOnLine).BaseType.ToString());
} }
} }
@@ -10,7 +10,7 @@ namespace StgSharp.Control
{ {
public class Bind public class Bind
{ {
public void Simple(Point p, GeometryI g) public void Simple(IPoint p, IGeometry g)
{ {
if (g!=null) if (g!=null)
{ {
@@ -23,11 +23,11 @@ namespace StgSharp.Control
/// </summary> /// </summary>
/// <param name="p">绑定的点</param> /// <param name="p">绑定的点</param>
/// <param name="c">被限定的圆</param> /// <param name="c">被限定的圆</param>
public void Complex(Point p, Circle c) public void Complex(IPoint p, Circle c)
{ {
c._bindPoint = p; c._bindPoint = p;
} }
public void Complex(Point p, Line l) public void Complex(IPoint p, Line l)
{ {
l.EndingPoint = p; l.EndingPoint = p;
} }
@@ -1,4 +1,5 @@
using System; using StgSharp.Geometry;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -8,6 +9,9 @@ namespace StgSharp.Control
{ {
public class Create public class Create
{ {
public void Geometry(IPoint center, float radius, float angle, int num)
{
}
} }
} }
@@ -0,0 +1,36 @@
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Control
{
public abstract class Pool
{
private LinkedList _pool01;
private LinkedList _pool02;
private LinkedList _pool03;
private LinkedList _pool04;
public Pool()
{
}
public void Creat()
{
for (int i = 0; i < 4; i++)
{
}
}
}
}
@@ -1,4 +1,5 @@
using StgSharp.Logic; using StgSharp.Geometry;
using StgSharp.Logic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -7,165 +8,39 @@ using System.Threading.Tasks;
namespace StgSharp.Entity namespace StgSharp.Entity
{ {
internal unsafe class Bullet : LinkedObject public class Bullet : LinkedObject
{ {
private IPoint _location;
//子弹的缩放比例 public IPoint Location
private float _size;
public float Size
{ {
get { return _size; } get { return _location; }
set set { _location = value; }
{
if (value > 0)
{
_size = value;
this.Radius = DefualtRadius * Size;
}
else
{
throw new ArgumentException("Size cannot be smaller than zero!");
}
}
} }
//该种类子弹的默认大小 private float _x;
private static float _defualtRadius; private float _y;
public static float DefualtRadius public float X
{
get { return _defualtRadius; }
set { _defualtRadius = value; }
}
//子弹的实际判定半径
private float _radius;
public float Radius
{
get { return _radius; }
set { _radius = value; }
}
//子弹x轴运动的函数表达
private float[] _xVelocity;
public float[] XVelocity
{
get { return _xVelocity; }
set
{
if (value.Length == 10)
{
_xVelocity = value;
}
else
{
throw new ArgumentException("Too many or too few parameters!");
}
}
}
//子弹y轴运动的函数表达
private float[] _yVelocity;
public float[] YVelocity
{
get { return _yVelocity; }
set
{
if (value.Length == 10)
{
_yVelocity = value;
}
else
{
throw new ArgumentException("Too many or too few parameters!");
}
}
}
private float* _x;
//xy坐标
public float* X
{ {
get { return _x; } get { return _x; }
set { _x = value; } set { _x = value; }
} }
private float* _y; public float Y
public float* Y
{ {
get { return _y; } get { return _y; }
set { _y = value; } set { _y = value; }
} }
private uint _beginTick;
public uint BeginTick
{
get { return _beginTick; }
set { _beginTick = value; }
}
public Bullet() public Bullet()
{ {
} }
//通过传入的时间刻计算位移并更新位置坐标 public void OnRender()
public void move(uint tick)
{ {
float deltaTick = tick - _beginTick;
float deltaX = 0;
for (int i = 0; i < 10; i++)
{
deltaX += _xVelocity[i];
deltaX *= deltaTick;
}
deltaX += _xVelocity[10];
*_x += deltaX;
float deltaY = 0;
for (int i = 0; i < 10; i++)
{
deltaY += _yVelocity[i];
deltaY *= deltaTick;
}
deltaY += _yVelocity[10];
*_y += deltaY;
}
/// <summary>
/// 修改自身路径,修改条件由外部逻辑判断触发
/// </summary>
public void ChangeVelocity(float[] XSpeed, float[] YSpeed)
{
if (XSpeed != null)
{
if (XSpeed.Length == 10)
{
this._xVelocity = XSpeed;
}
else
{
throw new Exception("The amount of parameters should be 10!");
}
}
if (YSpeed != null)
{
if (YSpeed.Length == 10)
{
this._yVelocity = YSpeed;
}
else
{
throw new Exception("The amount of parameters should be 10!");
}
}
} }
@@ -1,4 +1,5 @@
using System; using StgSharp.Geometry;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -24,7 +25,24 @@ namespace StgSharp.Entity
set { _y = value; } set { _y = value; }
} }
private IPoint _location;
public IPoint Location
{
get { return _location; }
set { _location = value; }
}
public Enemy()
{
}
public void OnRender()
{
}
@@ -9,9 +9,9 @@ namespace StgSharp.Entity
{ {
internal unsafe class Launcher internal unsafe class Launcher
{ {
private Point _location; private IPoint _location;
public Point Location public IPoint Location
{ {
get { return _location; } get { return _location; }
set { _location = value; } set { _location = value; }
@@ -26,22 +26,32 @@ namespace StgSharp.Entity
private float _y; private float _y;
public float YPosition public float Y
{ {
get { return _y; } get { return _y; }
set { _y = value; } set { _y = value; }
} }
private Bullet _launchType;
public Launcher() public Bullet LaunchType
{ {
get { return _launchType; }
set { _launchType = value; }
} }
public void Bind(Point loc) public Launcher(Bullet launchType, IPoint loc)
{ {
_launchType = launchType;
_location = loc;
} }
public void Launch()
{
}
} }
@@ -184,7 +184,7 @@ namespace StgSharp.Entity
{ {
if (_keyboardState.IsKeyDown(Key.Z)) if (_keyboardState.IsKeyDown(Key.Z))
{ {
_launcherAtLow.Launch();
} }
} }
@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Game
{
internal class Class1
{
}
}
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Game
{
public class CoreInfo
{
public static readonly string _coreSignature;
public static readonly string _coreName;
internal string CoreEdition
{
get { return _coreName; }
}
internal string CoreSignature
{
get { return _coreSignature; }
}
public void ShowVersion()
{
Console.WriteLine($"StgSharp core: {_coreName}");
Console.WriteLine($"StgSharp core signature: {_coreSignature}");
}
}
}
@@ -72,7 +72,13 @@ namespace StgSharp.Geometry
readonly private Counter<uint> tickCounter; readonly private Counter<uint> tickCounter;
readonly private uint beginTick; readonly private uint beginTick;
public ComplexOperationHandler complexOperationHandler;
public event ComplexOperationHandler ComplexOperation
{
add { complexOperationHandler += value; }
remove { complexOperationHandler -= value; }
}
/// <summary> /// <summary>
/// 创建一个圆的快速方法 /// 创建一个圆的快速方法
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry namespace StgSharp.Geometry
{ {
internal interface IGeometry public interface IGeometry
{ {
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry namespace StgSharp.Geometry
{ {
internal class PointCommon : LinkedObject, IPoint public class PointCommon : LinkedObject, IPoint
{ {
private readonly float x0; private readonly float x0;
private readonly float y0; private readonly float y0;
@@ -83,12 +83,15 @@ namespace StgSharp.Geometry
} }
public PointCommon(float x,float y,Counter<uint> tickCounter) public PointCommon(float x,float y,float angle,Counter<uint> tickCounter)
{ {
_x = x; _x = x;
x0 = x; x0 = x;
_y = y; _y = y;
y0 = y; y0 = y;
angle0 = angle;
_tickCounter = tickCounter; _tickCounter = tickCounter;
beginTick = _tickCounter.Value; beginTick = _tickCounter.Value;
} }
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StgSharp.Geometry namespace StgSharp.Geometry
{ {
public unsafe class PointOnCircle :LinkedObject, IPoint public class PointOnCircle :LinkedObject, IPoint
{ {
private Circle _bindedItem; private Circle _bindedItem;
@@ -49,8 +49,7 @@ namespace StgSharp.Geometry
set { _angle = value; } set { _angle = value; }
} }
private float _rate;
private float rate;
public PointOnLine(IPoint beginPoint, IPoint endPoint, float rate, int number) public PointOnLine(IPoint beginPoint, IPoint endPoint, float rate, int number)
{ {
@@ -59,7 +58,7 @@ namespace StgSharp.Geometry
_angle = (float)(Math.Atan2(endPoint.Y - beginPoint.Y, endPoint.X - beginPoint.Y)); _angle = (float)(Math.Atan2(endPoint.Y - beginPoint.Y, endPoint.X - beginPoint.Y));
rate = rate * number; _rate = rate * number;
this._y = beginPoint.Y + rate * (endPoint.Y - beginPoint.Y); this._y = beginPoint.Y + rate * (endPoint.Y - beginPoint.Y);
this._x = beginPoint.X + rate * (endPoint.X - beginPoint.X); this._x = beginPoint.X + rate * (endPoint.X - beginPoint.X);
} }
@@ -68,8 +67,8 @@ namespace StgSharp.Geometry
{ {
_angle = (float)(Math.Atan2(_endPoint.Y - _beginPoint.Y, _endPoint.X - _beginPoint.Y)); _angle = (float)(Math.Atan2(_endPoint.Y - _beginPoint.Y, _endPoint.X - _beginPoint.Y));
this._y = _beginPoint.Y + rate * (_endPoint.Y - _beginPoint.Y); this._y = _beginPoint.Y + _rate * (_endPoint.Y - _beginPoint.Y);
this._x = _beginPoint.X + rate * (_endPoint.X - _beginPoint.X); this._x = _beginPoint.X + _rate * (_endPoint.X - _beginPoint.X);
} }
} }
} }
@@ -14,6 +14,11 @@ namespace StgSharp.Logic
private float _topBorder; private float _topBorder;
private float _bottomBorder; private float _bottomBorder;
private EntityContainer left;
private EntityContainer right;
private EntityContainer top;
private EntityContainer bottom;
public int Limit public int Limit
{ {
get { return _limit; } get { return _limit; }
@@ -45,13 +50,33 @@ namespace StgSharp.Logic
{ {
} }
//Move an entity from one container to another one
public void Move(LinkedObject target, EntityContainer targetContainer) public void MoveLeft(LinkedObject target)
{ {
target.Previous = target.Next; target.Previous = target.Next;
target.Next = target.Previous; target.Next = target.Previous;
targetContainer.Add(target); left.Add(target);
}
public void MoveRight(LinkedObject target)
{
target.Previous = target.Next;
target.Next = target.Previous;
right.Add(target);
}
public void MoveUp(LinkedObject target)
{
target.Previous = target.Next;
target.Next = target.Previous;
top.Add(target);
}
public void Movebottom(LinkedObject target)
{
target.Previous = target.Next;
target.Next = target.Previous;
bottom.Add(target);
} }
//What should a container do on each rendering frame //What should a container do on each rendering frame
@@ -7,15 +7,9 @@ using System.Threading.Tasks;
namespace StgSharp.Logic namespace StgSharp.Logic
{ {
public class GeometryContainer public class GeometryContainer:LinkedList,IContainer
{ {
private LinkedList _container;
public LinkedList Container
{
get { return _container; }
set { _container = value; }
}
private float _leftBorder; private float _leftBorder;
@@ -33,20 +27,28 @@ namespace StgSharp.Logic
set { _rightBorder = value; } set { _rightBorder = value; }
} }
private float _upBorder; private float _topBorder;
public float UpBorder public float TopBorder
{ {
get { return _upBorder; } get { return _topBorder; }
set { _upBorder = value; } set { _topBorder = value; }
} }
private float _downBorder; private float _bottomBorder;
public float DownBorder public float BottomBorder
{ {
get { return _downBorder; } get { return _bottomBorder; }
set { _downBorder = value; } set { _bottomBorder = value; }
}
private int _limit;
public int Limit
{
get { return _limit; }
set { _limit = value; }
} }
public GeometryContainer() public GeometryContainer()
@@ -54,9 +56,9 @@ namespace StgSharp.Logic
} }
public void Add(LinkedObject t) public void OnRender()
{ {
Container.Add(t);
} }
} }
@@ -11,7 +11,7 @@ namespace StgSharp.Logic
protected LinkedObject _heading; protected LinkedObject _heading;
protected LinkedObject _ending; protected LinkedObject _ending;
private LinkedObject _cache; private LinkedObject _cache;
private Counter<int> _amountCounter; private Counter<uint> _amountCounter;
public LinkedObject Heading public LinkedObject Heading
{ {
@@ -29,7 +29,7 @@ namespace StgSharp.Logic
get { return _cache; } get { return _cache; }
set { _cache = value; } set { _cache = value; }
} }
public Counter<int> AmountCounter public Counter<uint> AmountCounter
{ {
get { return _amountCounter; } get { return _amountCounter; }
set { _amountCounter = value; } set { _amountCounter = value; }
@@ -38,7 +38,7 @@ namespace StgSharp.Logic
//构造器 //构造器
public LinkedList() public LinkedList()
{ {
this._amountCounter = new Counter<int>(); this._amountCounter = new Counter<uint>();
_amountCounter.Value = 0; _amountCounter.Value = 0;
_ending = null; _ending = null;
_heading = null; _heading = null;
@@ -7,14 +7,14 @@ using System.Threading.Tasks;
namespace StgSharp.Logic namespace StgSharp.Logic
{ {
internal class PointContainer : LinkedList<IPoint> internal class PointContainer : LinkedList, IContainer
{ {
private Counter<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;
private int _limit;
public float LeftBorder public float LeftBorder
{ {
@@ -37,30 +37,11 @@ namespace StgSharp.Logic
set { _bottomBorder = value; } set { _bottomBorder = value; }
} }
public LinkedList Container public int Limit
{ {
get { return _container; } get { return _limit; }
set { _container = value; } set { _limit = 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);
} }
} }
} }
@@ -46,10 +46,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Control\Bind.cs" /> <Compile Include="Control\Bind.cs" />
<Compile Include="Control\Pool.cs" />
<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\CoreInfo.cs" />
<Compile Include="Geometry\ComplexOperationHandler.cs" /> <Compile Include="Entity\ComplexOperationHandler.cs" />
<Compile Include="Geometry\IGeometry.cs" /> <Compile Include="Geometry\IGeometry.cs" />
<Compile Include="Geometry\IPoint.cs" /> <Compile Include="Geometry\IPoint.cs" />
<Compile Include="Geometry\PointCommon.cs" /> <Compile Include="Geometry\PointCommon.cs" />
@@ -1 +1 @@
9cd073825ba9a2a4cf5ce2e7b5c36ea49b8f1483 ad761ca55fb448d4a1c942b7a73d038bfb5ad3dc