本文整理汇总了C#中TickCount类的典型用法代码示例。如果您正苦于以下问题:C# TickCount类的具体用法?C# TickCount怎么用?C# TickCount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TickCount类属于命名空间,在下文中一共展示了TickCount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapGrhEffectSeekPosition
/// <summary>
/// Initializes a new instance of the <see cref="MapGrhEffectSeekPosition"/> class.
/// </summary>
/// <param name="grh">Grh to draw.</param>
/// <param name="position">Position to draw on the map.</param>
/// <param name="target">The destination position.</param>
/// <param name="speed">How fast this object moves towards the target in pixels per second.</param>
public MapGrhEffectSeekPosition(Grh grh, Vector2 position, Vector2 target, float speed)
: base(grh, position)
{
speed = speed / 1000f;
_startTime = TickCount.Now;
_startPosition = position;
_targetPosition = target;
// Calculate the angle between the position and target
var diff = position - target;
var angle = Math.Atan2(diff.Y, diff.X);
var cos = Math.Cos(angle);
var sin = Math.Sin(angle);
// Multiply the normalized direction vector (the cos and sine values) by the speed to get the velocity
// to use for each elapsed millisecond
_velocity = -new Vector2((float)(cos * speed), (float)(sin * speed));
// Precalculate the amount of time it will take to hit the target. This way, we can check if we have reached
// the destination simply by checking the current time.
var dist = Vector2.Distance(position, target);
var reqTime = (int)Math.Ceiling(dist / speed);
_endTime = (TickCount)(_startTime + reqTime);
}
示例2: HandleDraw
/// <summary>
/// When overridden in the derived class, draws the graphics to the control.
/// </summary>
/// <param name="currentTime">The current time.</param>
protected override void HandleDraw(TickCount currentTime)
{
base.HandleDraw(currentTime);
if (DesignMode)
return;
if (_drawingManager.RenderWindow == null)
return;
if (Grh == null)
return;
Grh.Update(currentTime);
m.Update(currentTime);
_drawingManager.Update(currentTime);
var sb = _drawingManager.BeginDrawWorld(_camera);
if (sb == null)
return;
// Change the view
var oldView = RenderWindow.GetView();
_drawView.Reset(new FloatRect(Camera.Min.X, Camera.Min.Y, Camera.Size.X, Camera.Size.Y));
RenderWindow.SetView(_drawView);
try
{
try
{
Grh.Draw(sb, Vector2.Zero, Color.White);
}
catch (LoadingFailedException)
{
// A LoadingFailedException is generally fine here since it probably means the graphic file was invalid
// or does not exist
}
// Draw the walls
if (Walls != null)
{
foreach (var wall in Walls)
{
var rect = wall.ToRectangle();
RenderRectangle.Draw(sb, rect, _autoWallColor);
}
}
m.Draw(sb, Camera);
}
finally
{
_drawingManager.EndDrawWorld();
// Restore the view
RenderWindow.SetView(oldView);
}
}
示例3: Update
/// <summary>
/// Updates the <see cref="MapGrh"/>.
/// </summary>
/// <param name="currentTime">Current game time.</param>
public override void Update(TickCount currentTime)
{
base.Update(currentTime);
if (IsAlive)
UpdateEffect(currentTime);
}
示例4: Update
/// <summary>
/// Updates the World.
/// </summary>
public virtual void Update()
{
// Get the current time
var currentTime = GetTime();
// Check if this is the very first update - if so, bring the timer up to date
if (_isFirstUpdate)
{
_lastUpdateTime = currentTime;
_isFirstUpdate = false;
}
// Grab the update rate
var updateRate = GameData.WorldPhysicsUpdateRate;
// Check if we fell too far behind
if (currentTime - _lastUpdateTime > _maxUpdateDeltaTime)
{
const string errmsg = "Fell too far behind in updates to catch up. Jumping ahead to current time.";
if (log.IsWarnEnabled)
log.Warn(errmsg);
// Push the time ahead to a bit before the current time
_lastUpdateTime = (TickCount)(currentTime - updateRate - 1);
}
// Keep updating until there is not enough delta time to fit into the updateRate
while (currentTime > _lastUpdateTime + updateRate)
{
UpdateMaps(updateRate);
_lastUpdateTime += (uint)updateRate;
}
}
示例5: GetTimeStamp
/// <summary>
/// Gets the time stamp.
/// </summary>
/// <param name="currentTime">The time to get the time stamp for.</param>
/// <returns>The time stamp for the given time.</returns>
public static ushort GetTimeStamp(TickCount currentTime)
{
unchecked
{
return (ushort)((currentTime >> 3) % (MaxTimeStampSize + 1));
}
}
示例6: Update
/// <summary>
/// Updates the GUISettings.
/// </summary>
/// <param name="currentTime">Current time.</param>
public void Update(TickCount currentTime)
{
if (_lastSaveTime + _saveFrequency > currentTime)
return;
_lastSaveTime = currentTime;
AsyncSave();
}
示例7: Update
/// <summary>
/// Updates the server time.
/// </summary>
/// <param name="currentTime">The current game time. Used to determine if enough time has elapsed since
/// the last update.</param>
public void Update(TickCount currentTime)
{
if (currentTime - _lastUpdateTime < UpdateRate)
return;
_lastUpdateTime = currentTime;
_updateQuery.Execute();
}
示例8: TimeElapsed
public bool TimeElapsed(TickCount currentTick)
{
if (currentTick.Elapsed(storedTime, this.interval)) {
return true;
} else {
return false;
}
}
示例9: ItemEntity
public ItemEntity(MapEntityIndex mapEntityIndex, Vector2 pos, Vector2 size, GrhIndex graphicIndex, TickCount currentTime)
: base(pos, size)
{
Amount = 0;
((IDynamicEntitySetMapEntityIndex)this).SetMapEntityIndex(mapEntityIndex);
_grh = new Grh(GrhInfo.GetData(graphicIndex), AnimType.Loop, currentTime);
}
示例10: MapGrh
/// <summary>
/// Initializes a new instance of the <see cref="MapGrh"/> class.
/// </summary>
/// <param name="reader">The reader to read the values from.</param>
/// <param name="currentTime">The current time.</param>
/// <exception cref="ArgumentNullException"><paramref name="reader" /> is <c>null</c>.</exception>
public MapGrh(IValueReader reader, TickCount currentTime)
{
if (reader == null)
throw new ArgumentNullException("reader");
_grh = new Grh(null, AnimType.Loop, currentTime);
ReadState(reader);
}
示例11: MapNpcBase
public MapNpcBase(DataManager.Maps.MapNpc rawNpc)
{
this.rawNpc = rawNpc;
Darkness = -2;
Mobility = new bool[16];
TimeMultiplier = 1000;
AttackTimer = new TickCount(Core.GetTickCount().Tick);
PauseTimer = new TickCount(Core.GetTickCount().Tick);
}
示例12: OnTimeElapsed
public void OnTimeElapsed(TickCount currentTick)
{
storedTime = currentTick;
return;
PMU.Sockets.IPacket packet = PMU.Sockets.TcpPacket.CreatePacket("keepalive");
foreach (Network.Client client in Network.ClientManager.GetAllClients()) {
Network.Messenger.SendDataTo(client, packet);
}
}
示例13: UpdateEffect
/// <summary>
/// When overridden in the derived class, performs the additional updating that this <see cref="MapGrhEffect"/>
/// needs to do such as checking if it is time to kill the effect. This method should be overridden instead of
/// <see cref="MapGrh.Update"/>. This method will not be called after the effect has been killed.
/// </summary>
/// <param name="currentTime">Current game time.</param>
protected override void UpdateEffect(TickCount currentTime)
{
if (_terminateWhenDoneLooping && Grh.AnimType == AnimType.None)
{
Kill(true);
return;
}
if (TickCount.Now >= _expireTime)
Kill(true);
}
示例14: IPSocket
/// <summary>
/// Initializes a new instance of the <see cref="IPSocket"/> class.
/// </summary>
/// <param name="conn">The <see cref="NetConnection"/> that this <see cref="IPSocket"/> is for.</param>
IPSocket(NetConnection conn)
{
_timeCreated = TickCount.Now;
_conn = conn;
var addressBytes = _conn.RemoteEndPoint.Address.GetAddressBytes();
_address = IPAddressHelper.IPv4AddressToUInt(addressBytes, 0);
_addressStr = IPAddressHelper.ToIPv4Address(_address) + ":" + _conn.RemoteEndPoint.Port;
}
示例15: GrhDataUpdaterProgressForm
/// <summary>
/// Initializes a new instance of the <see cref="GrhDataUpdaterProgressForm"/> class.
/// </summary>
/// <param name="total">The total number of items.</param>
public GrhDataUpdaterProgressForm(int total)
{
InitializeComponent();
_total = total;
_startTime = TickCount.Now;
progBar.Minimum = 0;
progBar.Maximum = total;
progBar.Value = 0;
}