Files
stgsharp/封存/.Net Framework/Stg_Sharp/Stg_Sharp/Geometries/PointCommon.cs
T

105 lines
2.2 KiB
C#

using StgSharp.Entities;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometries
{
internal class PointCommon : Point
{
private readonly float x0;
private readonly float y0;
private float angle0;
private float[] _xVelocity = new float[10];
public float[] XVelocity
{
get { return _xVelocity; }
set
{
if (value.Length == 10)
{
_xVelocity = value;
}
else
{
throw new Exception("Parameters are too many or too few!");
}
}
}
private float[] _yVelocity = new float[10] ;
public float[] YVelocity
{
get { return _yVelocity; }
set
{
if (value.Length == 10)
{
_yVelocity = value;
}
else
{
throw new Exception("Parameters are too many or too few!");
}
}
}
private uint beginTick;
private static Counter<uint> _tickCounter;
public static Counter<uint> TickCounter
{
get { return _tickCounter; }
}
public PointCommon(float x,float y,float angle,Counter<uint> tickCounter)
{
_x = x;
x0 = x;
_y = y;
y0 = y;
angle0 = angle;
_tickCounter = tickCounter;
beginTick = _tickCounter.Value;
}
public override void OnRender()
{
uint tick=_tickCounter.Value-beginTick;
float d = 0;
for (int i = 0; i < 9; i++)
{
d += _xVelocity[i];
d *= tick;
}
_x += (d += _xVelocity[9]);
d = 0;
for (int i = 0; i < 9; i++)
{
d += _yVelocity[i];
d += tick;
}
_y += (d += _yVelocity[9]);
}
}
}