Daily update on 20221103 by Nitload .Youmu

This commit is contained in:
Nitload
2022-11-04 02:14:19 +08:00
parent 7b5ddb0d99
commit 9d2548b309
24 changed files with 188 additions and 140 deletions
@@ -1,7 +1,11 @@
using StgSharp.Geometry;
using StgSharp.Entity;
using StgSharp.Geometry;
using StgSharp.Logic;
using StgSharp.Pool;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
@@ -9,9 +13,62 @@ namespace StgSharp.Control
{
static public class Create
{
private static LinkedObject cache;
public static void Geometry(IPoint center, float radius, float angle, int num)
{
}
/// <summary>
/// 创建一个子弹并将其绑定在一个指定的点上
/// </summary>
/// <param name="point"></param>
public static void Bullet(IPoint point)
{
BulletPool.mainContainer.Add(new Bullet(point));
}
/// <summary>
/// 创建一组子弹,并将其绑定在点池的一组点上
/// 顺序是从最后创建的点向前计数
/// </summary>
/// <param name="begin">起始序号</param>
/// <param name="end">终点序号</param>
public static void Bullet(int begin, int end)
{
cache = PointPool.mainCotainer.Ending;
for (int i = 1; i < begin; i++)
{
cache--;
}
for (int i = begin; i < end; i++)
{
cache--;
BulletPool.mainContainer.Add(new Bullet(cache as IPoint));
}
}
/// <summary>
/// 在新创建的一个或一组圆的其中一个上创建一组子弹
/// </summary>
/// <param name="order"></param>
/// <param name="count"></param>
/// <param name="angle"></param>
public static void Bullet(int order,uint count,float angle)
{
cache=PointPool.mainCotainer.Ending;
for (int i = 1; i < count; i++)
{
cache--;
}
for (uint i = 0; i < count; i++)
{
PointOnCircle p = new PointOnCircle(cache as Circle, angle, i);
PointPool.mainCotainer.Add(p);
BulletPool.mainContainer.Add(new Bullet(p));
}
}
}
@@ -41,9 +41,9 @@ namespace StgSharp.Entity
set { _radius = value; }
}
public Bullet()
public Bullet(IPoint p)
{
_location = p;
}
public void OnRender()
@@ -51,6 +51,13 @@ namespace StgSharp.Entity
}
public static Bullet operator ++(Bullet a)
{
return a._next as Bullet;
}
public static Bullet operator --(Bullet a)
{
return a._previous as Bullet;
}
}
}
@@ -1,4 +1,5 @@
using StgSharp.Geometry;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -7,7 +8,7 @@ using System.Threading.Tasks;
namespace StgSharp.Entity
{
internal class Enemy
internal class Enemy:LinkedObject
{
private float _x;
@@ -41,10 +42,17 @@ namespace StgSharp.Entity
public void OnRender()
{
}
public static Enemy operator ++(Enemy a)
{
return a._next as Enemy;
}
}
public static Enemy operator --(Enemy a)
{
return a._next as Enemy;
}
}
}
@@ -79,5 +79,8 @@ namespace StgSharp.Entity
_v *= 2.0f;
}
}
}
@@ -1,4 +1,5 @@
using StgSharp.Logic;
using StgSharp.Entity;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -205,5 +206,8 @@ namespace StgSharp.Geometry
}
}
}
@@ -1,4 +1,5 @@
using StgSharp.Logic;
using StgSharp.Entity;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -65,6 +66,12 @@ namespace StgSharp.Geometry
public void OnRender()
{
}
}
}
@@ -16,4 +16,9 @@ namespace StgSharp.Geometry
void OnRender();
}
abstract class a
{
}
}
@@ -1,4 +1,5 @@
using StgSharp.Logic;
using StgSharp.Entity;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -117,5 +118,16 @@ namespace StgSharp.Geometry
}
_y += (d += _yVelocity[9]);
}
public static PointCommon operator ++(PointCommon a)
{
return a._next as PointCommon;
}
public static PointCommon operator --(PointCommon a)
{
return a._previous as PointCommon;
}
}
}
@@ -1,4 +1,5 @@
using StgSharp.Logic;
using StgSharp.Entity;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -62,5 +63,10 @@ namespace StgSharp.Geometry
this._x = (float)(_bindedItem.Center.X + _bindedItem.Radius * Math.Cos(_angle));
this._y = (float)(_bindedItem.Center.X + _bindedItem.Radius * Math.Sin(_angle));
}
}
}
@@ -1,4 +1,5 @@
using StgSharp.Logic;
using StgSharp.Entity;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -70,5 +71,8 @@ namespace StgSharp.Geometry
this._y = _beginPoint.Y + _rate * (_endPoint.Y - _beginPoint.Y);
this._x = _beginPoint.X + _rate * (_endPoint.X - _beginPoint.X);
}
}
}
@@ -31,5 +31,14 @@ namespace StgSharp.Logic
_next = value;
}
}
public static LinkedObject operator ++(LinkedObject a)
{
return a._next;
}
public static LinkedObject operator --(LinkedObject a)
{
return a._previous;
}
}
}
@@ -1,110 +0,0 @@
using StgSharp.Entity;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Pool
{
internal class BulletContainer : 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 BulletContainer(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 BulletContainer(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()
{
//坐标刷新
//边界判定
//碰撞判定
}
}
}
@@ -4,12 +4,13 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Pool
{
internal class BulletPool:IPool
public class BulletPool:IPool
{
internal static IContainer _topCollector;
@@ -40,15 +41,15 @@ namespace StgSharp.Pool
//用一个实体容器存放各种各样的实体,太不安全了,
//写这种代码的人是个大SB。
static BulletContainer mainContainer;
static BulletContainer grazeContainer;
internal static EntityContainer mainContainer;
internal static EntityContainer grazeContainer;
public BulletPool(Collector t, Collector b, Collector l, Collector r)
{
mainContainer = new BulletContainer(1000,-1000,-600,600);
mainContainer = new EntityContainer(1000,-1000,-600,600);
grazeContainer = new BulletContainer(1000,400,-150,150);
grazeContainer = new EntityContainer(1000,400,-150,150);
mainContainer.Top = _topCollector;
mainContainer.Bottom = _bottomCollector;
@@ -66,25 +67,60 @@ namespace StgSharp.Pool
_rightCollector = r;
}
private static Bullet cache;
protected static Bullet cache;
public static void OnRender()
{
Bullet end=mainContainer.Ending as Bullet;
cache = mainContainer.Heading as Bullet;
do
Bullet end=grazeContainer.Ending as Bullet;
if (end != null)
{
if (cache.X - cache.Radius < grazeContainer.LeftBorder
|| cache.X + cache.Radius < grazeContainer.RightBorder
|| cache.Y - cache.Radius < grazeContainer.TopBorder
|| cache.Y + cache.Radius < grazeContainer.RightBorder)
cache = grazeContainer.Heading as Bullet;
do
{
grazeContainer.Add(cache);
}
if ( cache.X + cache.Radius < grazeContainer.LeftBorder
|| cache.X - cache.Radius < grazeContainer.RightBorder
|| cache.Y + cache.Radius < grazeContainer.TopBorder
|| cache.Y - cache.Radius < grazeContainer.RightBorder)
{
grazeContainer.Remove(cache);
}
cache = cache.Next as Bullet;
cache = cache.Next as Bullet;
} while (cache == end);
} while (true);
}
end=mainContainer.Ending as Bullet;
if (end != null)
{
cache = mainContainer.Heading as Bullet;
do
{
if (cache.X - cache.Radius < grazeContainer.LeftBorder
|| cache.X + cache.Radius < grazeContainer.RightBorder
|| cache.Y - cache.Radius < grazeContainer.TopBorder
|| cache.Y + cache.Radius < grazeContainer.RightBorder)
{
grazeContainer.Add(cache);
}
cache = cache.Next as Bullet;
} while (cache == end);
}
}
/// <summary>
/// 所有需要添加的功能应当写在这里
/// </summary>
public virtual void ExtendRender()
{
}
}
}
@@ -57,7 +57,7 @@
<Compile Include="Geometry\IPoint.cs" />
<Compile Include="Geometry\PointCommon.cs" />
<Compile Include="Logic\IContainer.cs" />
<Compile Include="Pool\BulletContainer.cs" />
<Compile Include="Pool\BulletPool.cs" />
<Compile Include="Pool\Collector.cs" />
<Compile Include="Pool\PointContainer.cs" />
<Compile Include="Pool\PointPool.cs" />